You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The order of the `clientsExamples` list matters: it's the order in which the language tabs are presented for each code example.
@@ -18,13 +18,18 @@ There are two sections that need to updated when new languages are added.
18
18
[params.clientsConfig]
19
19
"Python"={quickstartSlug="redis-py"}
20
20
"Node.js"={quickstartSlug="nodejs"}
21
-
"Java-sync"={quickstartSlug="jedis"}
22
-
"Java-async"={quickstartSlug="lettuce"}
23
-
"Java-reactive"={quickstartSlug="lettuce"}
21
+
"Java-Sync"={quickstartSlug="jedis"}
22
+
"Lettuce-Sync"={quickstartSlug="lettuce"}
23
+
"Java-Async"={quickstartSlug="lettuce"}
24
+
"Java-Reactive"={quickstartSlug="lettuce"}
24
25
"Go"={quickstartSlug="go"}
25
-
"C#"={quickstartSlug="dotnet"}
26
+
"C"={quickstartSlug="hiredis"}
27
+
"C#-Sync"={quickstartSlug="dotnet"}
28
+
"C#-Async"={quickstartSlug="dotnet"}
26
29
"RedisVL"={quickstartSlug="redis-vl"}
27
30
"PHP"={quickstartSlug="php"}
31
+
"Rust-Sync"={quickstartSlug="rust"}
32
+
"Rust-Async"={quickstartSlug="rust"}
28
33
```
29
34
30
35
This configuration, along with the configuration steps below, is used to control the behavior of the Hugo shortcode that was developed to show tabbed code examples.
@@ -36,7 +41,7 @@ A shortcode is a simple snippet inside a content file that Hugo will render usin
36
41
37
42
The folder `data/components` contains one component configuration file for each supported language. These files contain information about the GitHub repos that house the code examples.
38
43
39
-
Here is the configuration file for Python, `redis_py.json`:
44
+
Here is the configuration file for Python, `redis_py.json`:
40
45
41
46
```json
42
47
{
@@ -65,15 +70,20 @@ Register your component file by adding it to the `clients` array in the `index.j
65
70
Here is an example:
66
71
```json
67
72
"clients": [
68
-
"nredisstack",
73
+
"nredisstack_sync",
74
+
"nredisstack_async",
69
75
"go_redis",
70
76
"node_redis",
71
77
"php",
72
78
"redis_py",
73
79
"jedis",
80
+
"lettuce_sync",
74
81
"lettuce_async",
75
82
"lettuce_reactive",
76
-
"redis_vl"
83
+
"redis_vl",
84
+
"redis_rs_sync",
85
+
"redis_rs_async",
86
+
"hi_redis"
77
87
]
78
88
```
79
89
@@ -99,14 +109,18 @@ PREFIXES = {
99
109
'java-async': '//',
100
110
'java-reactive': '//',
101
111
'go': '//',
112
+
'c': '//',
102
113
'c#': '//',
103
114
'redisvl': '#',
104
-
'php': '//'
115
+
'php': '//',
116
+
'rust': '//'
105
117
}
106
118
```
107
119
108
120
The `TEST_MARKER` dictionary maps programming languages to test framework annotations, which allows the parser to filter such source code lines out. The `PREFIXES` dictionary maps each language to its comment prefix. Python, for example, uses a hashtag (`#`) to start a comment.
109
121
122
+
⚠️ **CRITICAL**: The `PREFIXES` dictionary is **essential** for the example parser to work. If you add a new language, you **must** add an entry to this dictionary, or examples will fail to process with an "Unknown language" error. This is the most commonly missed step when adding a new language.
123
+
110
124
## Understand special comments in the example source code files
111
125
112
126
Each code example uses special comments, such as `HIDE_START` and `REMOVE_START`, to control how the examples are displayed. The following list gives an explanation:
@@ -130,10 +144,12 @@ Add a source code file to an appropriate client repo. Consult the /data/componen
130
144
131
145
| Programming Language | GitHub Repo | Default directory |
This allows the same language to appear multiple times in the tab interface with different implementations.
257
+
This allows the same language to appear multiple times in the tab interface with different implementations. The order of checks matters: more specific paths (e.g., `lettuce-sync`) should be checked before generic ones (e.g., `Java-Sync`).
257
258
258
259
**Outputs**:
259
260
- Copies files to `examples/{example_id}/local_{filename}`
3. ✅ `data/components/index.json`- Register the component
2179
+
2180
+
**Build System**:
2181
+
4. ✅ `build/components/example.py`-**CRITICAL**: Add to `PREFIXES` dictionary
2182
+
5. ✅ `build/components/example.py`- Add to `TEST_MARKER` dictionary (if language has test annotations)
2183
+
6. ✅ `build/local_examples.py`- Add file extension mapping to `EXTENSION_TO_LANGUAGE`
2184
+
7. ✅ `build/local_examples.py`- Add language to `LANGUAGE_TO_CLIENT` mapping
2185
+
2186
+
**Optional (if Jupyter notebook support is needed)**:
2187
+
8. ⚠️ `build/jupyterize/jupyterize.py`- Add to `KERNEL_SPECS` dictionary
2188
+
9. ⚠️ `build/jupyterize/jupyterize_config.json`- Add language-specific boilerplate and unwrap patterns
2189
+
2190
+
**Documentation**:
2191
+
10. ✅ `build/tcedocs/SPECIFICATION.md`- Update examples and checklist
2192
+
11. ✅ `build/tcedocs/README.md`- Update tables and examples
2193
+
2194
+
### Pre-existing Examples
2195
+
2196
+
**Important**: Before adding a new language, check if examples already exist in the repository:
2197
+
- Look in`local_examples/client-specific/{language}/`for local examples
2198
+
- Check the client repository for remote examples
2199
+
- Verify the component configuration points to the correct example directory
2200
+
2201
+
For C (hiredis), there was already a `landing.c` example in`local_examples/client-specific/c/` that was ready to be processed once the language was properly configured.
2202
+
2203
+
### Language-Specific Comment Prefixes
2204
+
2205
+
Different languages use different comment styles. When adding a language, ensure the correct prefix is used:
2206
+
2207
+
| Language | Prefix | Example |
2208
+
|----------|--------|---------|
2209
+
| Python |`#` | `# EXAMPLE: my_example` |
2210
+
| C |`//`|`//EXAMPLE: my_example`|
2211
+
| Java |`//`|`//EXAMPLE: my_example`|
2212
+
| Go |`//`|`//EXAMPLE: my_example`|
2213
+
| C# | `//` | `// EXAMPLE: my_example` |
2214
+
|PHP|`//`|`//EXAMPLE: my_example`|
2215
+
| Rust |`//`|`//EXAMPLE: my_example`|
2216
+
| Node.js |`//`|`//EXAMPLE: my_example`|
2217
+
2218
+
**Critical**: The `PREFIXES` dictionary uses **lowercase** language names as keys, but the `Example`class converts the language to lowercase before accessing it (line 57in`example.py`).
2219
+
2220
+
### Verification Steps
2221
+
2222
+
After adding a new language, verify the integration:
2223
+
2224
+
```bash
2225
+
# 1. Check that the language is recognized
2226
+
grep -r "c" build/components/example.py # Should find 'c': '//' in PREFIXES
0 commit comments