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.
@@ -23,6 +23,7 @@ There are two sections that need to updated when new languages are added.
23
23
"Java-Async"={quickstartSlug="lettuce"}
24
24
"Java-Reactive"={quickstartSlug="lettuce"}
25
25
"Go"={quickstartSlug="go"}
26
+
"C"={quickstartSlug="hiredis"}
26
27
"C#-Sync"={quickstartSlug="dotnet"}
27
28
"C#-Async"={quickstartSlug="dotnet"}
28
29
"RedisVL"={quickstartSlug="redis-vl"}
@@ -81,7 +82,8 @@ Here is an example:
81
82
"lettuce_reactive",
82
83
"redis_vl",
83
84
"redis_rs_sync",
84
-
"redis_rs_async"
85
+
"redis_rs_async",
86
+
"hi_redis"
85
87
]
86
88
```
87
89
@@ -107,14 +109,18 @@ PREFIXES = {
107
109
'java-async': '//',
108
110
'java-reactive': '//',
109
111
'go': '//',
112
+
'c': '//',
110
113
'c#': '//',
111
114
'redisvl': '#',
112
-
'php': '//'
115
+
'php': '//',
116
+
'rust': '//'
113
117
}
114
118
```
115
119
116
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.
117
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
+
118
124
## Understand special comments in the example source code files
119
125
120
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:
@@ -138,6 +144,7 @@ Add a source code file to an appropriate client repo. Consult the /data/componen
138
144
139
145
| Programming Language | GitHub Repo | Default directory |
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