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
Kernel app examples currently use TypeScript/JavaScript and Python. Add a Go version only after the Go SDK has documented app framework support and the snippet has been tested against that SDK.
308
+
204
309
For Kernel app examples, follow this pattern:
205
310
206
311
<CodeGroup>
@@ -299,17 +404,19 @@ finally:
299
404
### Indentation
300
405
- TypeScript/JavaScript: 2 spaces
301
406
- Python: 4 spaces
407
+
- Go: tabs from `gofmt`
302
408
303
409
### String Quotes
304
410
- TypeScript/JavaScript: Single quotes `'` (except for avoiding escaping)
305
411
- Python: Double quotes `"`
412
+
- Go: Double quotes `"`
306
413
307
414
### Line Length
308
415
- Keep lines under 100 characters when possible
309
416
- Break long parameter lists across multiple lines
310
417
311
418
### Comments
312
-
- Use comments sparingly - code should be self-explanatory
419
+
- Use comments sparingly; keep code self-explanatory
313
420
- Add comments only for non-obvious logic or important context
314
421
- Never add comments like "NEW CODE:" or similar meta-comments
315
422
@@ -340,6 +447,10 @@ Always use `<CodeGroup>` with proper language labels:
340
447
```python Python
341
448
# Python code here
342
449
```
450
+
451
+
```go Go
452
+
// Go code here
453
+
```
343
454
</CodeGroup>
344
455
````
345
456
@@ -354,7 +465,9 @@ Before publishing a code example, verify:
354
465
-[ ] Includes error handling (for full examples)
355
466
-[ ] Includes cleanup code (for full examples)
356
467
-[ ] Uses proper indentation and formatting
357
-
-[ ] Both TypeScript and Python versions are provided (when applicable)
468
+
-[ ] TypeScript/JavaScript, Python, and Go versions are provided (when applicable)
469
+
-[ ] Go examples are formatted with `gofmt`
470
+
-[ ] Go examples are tested against the actual Go SDK before publishing
358
471
-[ ] Code has been tested or follows proven patterns
359
472
360
473
## Reference
@@ -363,4 +476,3 @@ See these files for examples:
363
476
-`introduction/create.mdx` - Standard browser creation pattern
364
477
-`apps/develop.mdx` - App development pattern
365
478
-`browsers/file-io.mdx` - Complex automation example
Copy file name to clipboardExpand all lines: README.md
+5-23Lines changed: 5 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,31 +11,13 @@ This is the documentation for the Kernel platform. It's connected to [onkernel.c
11
11
12
12
## Code Snippets
13
13
14
-
Code samples in the docs are generated from our OpenAPI spec so the examples stay in sync with the API. There are two ways the generator is invoked:
14
+
Code samples in the docs are authored inline in MDX. Keep SDK examples aligned with the SDK repos, and follow the standards in `.docs/code-example-guide.md` when adding or editing examples.
15
15
16
-
- Custom MDX tag: use `<OpenAPICodeGroup>get /api/v1/users</OpenAPICodeGroup>` (or omit the verb to use the default behavior).
16
+
When you add Go examples:
17
17
18
-
How the generator works (current behavior):
19
-
20
-
- The script is `.github/scripts/generate_code_samples.ts` and is executed with Bun. It fetches the OpenAPI spec from the URL configured at the top of that script.
21
-
- It reads `x-codeSamples` entries for each operation and extracts samples for TypeScript/JavaScript and Python. Samples are normalized and may be transformed by simple "overrides" (see the script for the override parsing and injection heuristics).
22
-
- It writes snippet files under `snippets/openapi/` as MDX files containing a `<CodeGroup>` with the generated code fences. It also updates any MDX files under `apps/` and `browsers/` that contain the inline or tag forms by replacing them with the generated `<CodeGroup>` blocks.
23
-
- The generator can produce a base snippet and additional variant snippets controlled by `.github/scripts/code_samples.config.json` (variants are keyed by `"method /path"`).
24
-
- The script also removes stale snippet files matching the `-.mdx` suffix pattern.
25
-
26
-
How it affects the repository:
27
-
28
-
- New or updated files are created under `snippets/openapi/*.mdx`.
29
-
- MDX pages in `apps/` and `browsers/` may be modified in-place to replace `<OpenAPICodeGroup>`/mustache tags with generated `<CodeGroup>` blocks.
30
-
- A GitHub Action (`.github/workflows/generate_code_snippets.yaml`) runs the script on push (except to `main`), commits any changes, and pushes them to the `gh_action_generated_docs` branch so Mintlify can deploy the generated docs.
31
-
32
-
Notes and gotchas:
33
-
34
-
- The generator runs remotely against the OpenAPI URL defined in the script, so it needs network access and the spec to include `x-codeSamples` for useful output.
35
-
- The override parsing and code injection are heuristic. Complex sample sources might not be transformed exactly as intended. See the script for details on how keys/`log` overrides are applied.
36
-
- The GitHub Action installs Bun and runs the script; if you run it locally, install Bun and run `bun run .github/scripts/generate_code_samples.ts` from the repo root.
37
-
38
-
Example: to add a snippet placeholder to a page, add `<OpenAPICodeGroup>get /api/v1/users</OpenAPICodeGroup>` and let the generator fill `snippets/openapi` and update the page during the next run.
18
+
- Test the snippet against the actual Go SDK, usually from a sibling `../kernel-go-sdk` checkout.
19
+
- Run `gofmt` on the extracted Go code before publishing.
20
+
- Note the validation you ran in the pull request description.
0 commit comments