From dc3eb8833284a6a92cf4aa111feffe0f0d4a3e6a Mon Sep 17 00:00:00 2001 From: Igor Malinovskiy Date: Wed, 13 Nov 2024 17:31:23 +0100 Subject: [PATCH 1/3] Add support for multiple examples per client repo In Lettuce we have multiple APIs (async, reactive, etc) and should provide examples for each API variant. To achieve it multiple changes were introduced: - Add "label" attribute in clients configs and refer to the client example by label instead of language - Remove hardcoded mapping Label -> Lang from the config.toml - Prefix copied examples with client name to allow identical naming - Add configs for Lettuce Async and Reactive APIs --- build/components/component.py | 21 ++++++++++++++------ config.toml | 16 ++++++++------- data/components/go_redis.json | 1 + data/components/index.json | 2 ++ data/components/jedis.json | 1 + data/components/lettuce_async.json | 16 +++++++++++++++ data/components/lettuce_reactive.json | 16 +++++++++++++++ data/components/node_redis.json | 1 + data/components/nredisstack.json | 1 + data/components/redis_py.json | 1 + data/components/redis_vl.json | 3 ++- layouts/partials/tabbed-clients-example.html | 2 +- 12 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 data/components/lettuce_async.json create mode 100644 data/components/lettuce_reactive.json diff --git a/build/components/component.py b/build/components/component.py index 3047f8377..97c2b91c7 100644 --- a/build/components/component.py +++ b/build/components/component.py @@ -1,6 +1,8 @@ import logging import glob import os +import shutil + import semver import uuid from typing import Tuple @@ -514,13 +516,20 @@ def _copy_examples(self): if not example_id: continue - example_metadata = {'source': f} + example_metadata = { + 'source': f, + 'language': self.get('language').lower() + } + + base_path = os.path.join(dst, example_id) + mkdir_p(base_path) + rsync(example_metadata['source'], base_path) - mkdir_p(f'{dst}/{example_id}') - rsync(example_metadata['source'], f'{dst}/{example_id}/') + target_path = os.path.join(base_path, f'{self.get("id")}_{os.path.basename(f)}') + shutil.move(os.path.join(base_path, os.path.basename(f)), target_path) - example_metadata['target'] = f'{dst}/{example_id}/{os.path.basename(f)}' - e = Example(self.get('language'), example_metadata['target']) + example_metadata['target'] = target_path + e = Example(self.get('language'), target_path) example_metadata['highlight'] = e.highlight example_metadata['hidden'] = e.hidden example_metadata['named_steps'] = e.named_steps @@ -532,7 +541,7 @@ def _copy_examples(self): examples[example_id] = {} logging.info(f'Example {example_id} processed successfully.') - examples[example_id][self.get('language')] = example_metadata + examples[example_id][self.get('label')] = example_metadata def apply(self) -> None: logging.info(f'Applying client {self._id}') diff --git a/config.toml b/config.toml index 9d0f703d1..5cfbd0cb5 100644 --- a/config.toml +++ b/config.toml @@ -45,7 +45,7 @@ tagManagerId = "GTM-TKZ6J9R" gitHubRepo = "https://github.com/redis/docs" # Display and sort order for client examples -clientsExamples = ["Python", "Node.js", "Java", "Go", "C#", "RedisVL"] +clientsExamples = ["Python", "Node.js", "Java Sync", "Java Async", "Java Reactive", "Go", "C#", "RedisVL"] searchService = "/convai/api/search-service" ratingsService = "/docusight/api/rate" @@ -57,12 +57,14 @@ rdi_db_types = "cassandra|mysql|oracle|postgresql|sqlserver" rdi_cli_latest = "latest" [params.clientsConfig] -"Python"={lang="python", quickstartSlug="python/redis-py"} -"Node.js"={lang="javascript", quickstartSlug="nodejs"} -"Java"={lang="java", quickstartSlug="java/jedis"} -"Go"={lang="go", quickstartSlug="go"} -"C#"={lang="C#", quickstartSlug="dotnet"} -"RedisVL"={lang="python", quickstartSlug="python/redis-vl"} +"Python"={quickstartSlug="python/redis-py"} +"Node.js"={quickstartSlug="nodejs"} +"Java sync"={quickstartSlug="java/jedis"} +"Java async"={quickstartSlug="java/lettuce"} +"Java reactive"={quickstartSlug="java/lettuce"} +"Go"={quickstartSlug="go"} +"C#"={quickstartSlug="dotnet"} +"RedisVL"={quickstartSlug="python/redis-vl"} # Markup [markup] diff --git a/data/components/go_redis.json b/data/components/go_redis.json index ce46beca1..80fb21a60 100644 --- a/data/components/go_redis.json +++ b/data/components/go_redis.json @@ -3,6 +3,7 @@ "type": "client", "name": "go-redis", "language": "Go", + "label": "Go", "repository": { "git_uri": "https://github.com/redis/go-redis" }, diff --git a/data/components/index.json b/data/components/index.json index cd2dd4433..ff8b8f451 100644 --- a/data/components/index.json +++ b/data/components/index.json @@ -12,6 +12,8 @@ "node_redis", "redis_py", "jedis", + "lettuce_async", + "lettuce_reactive", "redis_vl" ], "assets": [], diff --git a/data/components/jedis.json b/data/components/jedis.json index 058ddc08a..4aa154ab5 100644 --- a/data/components/jedis.json +++ b/data/components/jedis.json @@ -3,6 +3,7 @@ "type": "client", "name": "jedis", "language": "Java", + "label": "Java Sync", "repository": { "git_uri": "https://github.com/redis/jedis" }, diff --git a/data/components/lettuce_async.json b/data/components/lettuce_async.json new file mode 100644 index 000000000..153f5c15d --- /dev/null +++ b/data/components/lettuce_async.json @@ -0,0 +1,16 @@ +{ + "id": "lettuce_async", + "type": "client", + "name": "lettuce_async", + "language": "Java", + "label": "Java Async", + "repository": { + "git_uri": "https://github.com/redis/lettuce" + }, + "examples": { + "git_uri": "/home/imalinovskyi/playground/lettuce-src", + "dev_branch": "doctests", + "path": "src/test/java/io/redis/examples/async", + "pattern": "*.java" + } +} \ No newline at end of file diff --git a/data/components/lettuce_reactive.json b/data/components/lettuce_reactive.json new file mode 100644 index 000000000..9116f8b88 --- /dev/null +++ b/data/components/lettuce_reactive.json @@ -0,0 +1,16 @@ +{ + "id": "lettuce_reactive", + "type": "client", + "name": "lettuce_reactive", + "language": "Java", + "label": "Java Reactive", + "repository": { + "git_uri": "https://github.com/redis/lettuce" + }, + "examples": { + "git_uri": "/home/imalinovskyi/playground/lettuce-src", + "dev_branch": "doctests", + "path": "src/test/java/io/redis/examples/reactive", + "pattern": "*.java" + } +} \ No newline at end of file diff --git a/data/components/node_redis.json b/data/components/node_redis.json index 79742c786..b1a5c4d1b 100644 --- a/data/components/node_redis.json +++ b/data/components/node_redis.json @@ -3,6 +3,7 @@ "type": "client", "name": "node-redis", "language": "Node.js", + "label": "Node.js", "repository": { "git_uri": "https://github.com/redis/node-redis" }, diff --git a/data/components/nredisstack.json b/data/components/nredisstack.json index 7e5271934..4283fdd49 100644 --- a/data/components/nredisstack.json +++ b/data/components/nredisstack.json @@ -3,6 +3,7 @@ "type": "client", "name": "NRedisStack", "language": "C#", + "label": "C#", "repository": { "git_uri": "https://github.com/redis/NRedisStack" }, diff --git a/data/components/redis_py.json b/data/components/redis_py.json index 801a09c66..dd93419c5 100644 --- a/data/components/redis_py.json +++ b/data/components/redis_py.json @@ -3,6 +3,7 @@ "type": "client", "name": "redis-py", "language": "Python", + "label": "Python", "repository": { "git_uri": "https://github.com/redis/redis-py" }, diff --git a/data/components/redis_vl.json b/data/components/redis_vl.json index befe6f452..bd0566723 100644 --- a/data/components/redis_vl.json +++ b/data/components/redis_vl.json @@ -2,7 +2,8 @@ "id": "redisvl", "type": "client", "name": "RedisVL", - "language": "RedisVL", + "language": "Python", + "label": "RedisVL", "repository": { "git_uri": "https://github.com/redis/redis-vl-python" }, diff --git a/layouts/partials/tabbed-clients-example.html b/layouts/partials/tabbed-clients-example.html index 42b127775..4d7fb5fa6 100644 --- a/layouts/partials/tabbed-clients-example.html +++ b/layouts/partials/tabbed-clients-example.html @@ -19,7 +19,7 @@ {{ range $client := $.Site.Params.clientsexamples }} {{ $example := index $clientExamples $client }} {{ $clientConfig := index $.Site.Params.clientsconfig $client }} - {{ $language := index $clientConfig "lang" }} + {{ $language := index $example "language" }} {{ $quickstartSlug := index $clientConfig "quickstartSlug" }} {{ if and ($example) (or (eq $lang "") (eq $lang $client)) }} From 0fbe9dc1ea02d58b730372ed11751ce59a63f54f Mon Sep 17 00:00:00 2001 From: Igor Malinovskiy Date: Wed, 13 Nov 2024 17:39:04 +0100 Subject: [PATCH 2/3] Fix lettuce path --- data/components/lettuce_async.json | 2 +- data/components/lettuce_reactive.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/components/lettuce_async.json b/data/components/lettuce_async.json index 153f5c15d..cc860f75c 100644 --- a/data/components/lettuce_async.json +++ b/data/components/lettuce_async.json @@ -8,7 +8,7 @@ "git_uri": "https://github.com/redis/lettuce" }, "examples": { - "git_uri": "/home/imalinovskyi/playground/lettuce-src", + "git_uri": "https://github.com/redis/lettuce", "dev_branch": "doctests", "path": "src/test/java/io/redis/examples/async", "pattern": "*.java" diff --git a/data/components/lettuce_reactive.json b/data/components/lettuce_reactive.json index 9116f8b88..b79aa9880 100644 --- a/data/components/lettuce_reactive.json +++ b/data/components/lettuce_reactive.json @@ -8,7 +8,7 @@ "git_uri": "https://github.com/redis/lettuce" }, "examples": { - "git_uri": "/home/imalinovskyi/playground/lettuce-src", + "git_uri": "https://github.com/redis/lettuce", "dev_branch": "doctests", "path": "src/test/java/io/redis/examples/reactive", "pattern": "*.java" From 123f843b2a5ebd83310f8753072419f0167d58c6 Mon Sep 17 00:00:00 2001 From: Igor Malinovskiy Date: Mon, 18 Nov 2024 15:30:11 +0100 Subject: [PATCH 3/3] Update config.toml Co-authored-by: andy-stark-redis <164213578+andy-stark-redis@users.noreply.github.com> --- config.toml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config.toml b/config.toml index 5cfbd0cb5..3a7915a03 100644 --- a/config.toml +++ b/config.toml @@ -57,14 +57,14 @@ rdi_db_types = "cassandra|mysql|oracle|postgresql|sqlserver" rdi_cli_latest = "latest" [params.clientsConfig] -"Python"={quickstartSlug="python/redis-py"} +"Python"={quickstartSlug="redis-py"} "Node.js"={quickstartSlug="nodejs"} -"Java sync"={quickstartSlug="java/jedis"} -"Java async"={quickstartSlug="java/lettuce"} -"Java reactive"={quickstartSlug="java/lettuce"} +"Java sync"={quickstartSlug="jedis"} +"Java async"={quickstartSlug="lettuce"} +"Java reactive"={quickstartSlug="lettuce"} "Go"={quickstartSlug="go"} "C#"={quickstartSlug="dotnet"} -"RedisVL"={quickstartSlug="python/redis-vl"} +"RedisVL"={quickstartSlug="redis-vl"} # Markup [markup]