-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Update docs for canonical #1519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7 issues found across 7 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/docs/scripts/sync-sdk-docs.js">
<violation number="1" location="packages/docs/scripts/sync-sdk-docs.js:55">
P2: The redirect handling has no maximum redirect limit. A redirect loop could cause stack overflow or hang the script indefinitely. Consider adding a redirect counter with a reasonable limit (e.g., 5-10 redirects).</violation>
<violation number="2" location="packages/docs/scripts/sync-sdk-docs.js:114">
P2: This converts Kotlin code blocks to Java, but Kotlin and Java are different languages with different syntax. If the SDK uses Kotlin, the code examples will have incorrect syntax highlighting. If this is intentional for some reason, add a comment explaining why.</violation>
</file>
<file name="packages/docs/v3/sdk/ruby.mdx">
<violation number="1" location="packages/docs/v3/sdk/ruby.mdx:45">
P2: The `x_language` parameter is set to `:typescript` but this is the Ruby SDK documentation. This should likely be `:ruby` to correctly identify the SDK language to the API.</violation>
</file>
<file name="packages/docs/v3/sdk/go.mdx">
<violation number="1" location="packages/docs/v3/sdk/go.mdx:610">
P2: Duration calculation is inverted. `start - end` will produce a negative duration since `start` occurs before `end`. Should be `end - start` for correct elapsed time.</violation>
</file>
<file name="packages/docs/v3/sdk/python.mdx">
<violation number="1" location="packages/docs/v3/sdk/python.mdx:49">
P3: Grammar issue: missing word "you" in the sentence. Should be "If you're using uv, you can follow these steps:"</violation>
</file>
<file name="packages/docs/v3/sdk/java.mdx">
<violation number="1" location="packages/docs/v3/sdk/java.mdx:25">
P3: Code block language identifier should be `groovy` or `kotlin` instead of `java` - this is Gradle build script syntax, not Java code.</violation>
<violation number="2" location="packages/docs/v3/sdk/java.mdx:400">
P2: Invalid Java syntax: the semicolon after `.onCompleteFuture()` terminates the statement, making the subsequent `.whenComplete(...)` call unreachable. This should be a method chain without the semicolon.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR adds comprehensive multi-language SDK documentation support to the Stagehand docs. The implementation includes:
Core Changes:
- Restructured
docs.jsonnavigation from simple groups to language-specific dropdowns (TypeScript, Python, Java, Go, Ruby) - Added canonical OpenAPI spec reference linking to Stainless-hosted documentation
- Created
language-selector.jsfor syncing language selection across sidebar and code blocks with sessionStorage persistence - Built
sync-sdk-docs.jsautomation script to pull SDK READMEs from GitHub and convert them to MDX
Technical Implementation:
The language selector uses DOM manipulation and MutationObservers to:
- Detect and sync sidebar dropdown changes with code block language selectors
- Persist user language preference across page navigation via sessionStorage
- Conditionally hide the version switcher for non-TypeScript languages
- Handle Mintlify's SPA navigation by observing URL changes
The sync script fetches READMEs from four SDK repos (Java, Python, Ruby, Go) and processes them by removing badges, converting relative links to absolute GitHub URLs, cleaning HTML tags, and adding MDX frontmatter with auto-sync notes.
Documentation Structure:
Each language dropdown includes SDK reference pages plus API Reference sections pointing to the canonical OpenAPI spec, alongside shared documentation for First Steps, Basics, Configuration, Best Practices, Integrations, and Migration Guides.
Confidence Score: 5/5
- Safe to merge - documentation-only changes with no runtime code impact
- This PR consists entirely of documentation updates and tooling scripts. The changes include: (1) restructuring docs.json navigation config to support multi-language dropdowns, (2) adding a client-side JavaScript file for UI enhancements, (3) creating a build-time script to sync SDK docs from GitHub, and (4) adding auto-generated SDK documentation files. None of these changes affect the core Stagehand runtime code. The JSON configuration follows valid Mintlify schema structure, the JavaScript is defensive with proper error handling, and the sync script uses standard Node.js APIs. No tests will break and no existing functionality is impacted.
- No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| packages/docs/docs.json | 5/5 | Added multi-language dropdown navigation structure and OpenAPI spec reference for Python, Java, Go, and Ruby SDKs |
| packages/docs/language-selector.js | 5/5 | Custom JavaScript that syncs language selection across sidebar dropdown and code blocks, with session storage persistence |
| packages/docs/scripts/sync-sdk-docs.js | 5/5 | Node script to fetch and process SDK READMEs from GitHub repos into MDX documentation files |
| packages/docs/v3/sdk/python.mdx | 5/5 | Auto-generated Python SDK documentation from browserbase/stagehand-python README |
| packages/docs/v3/sdk/go.mdx | 5/5 | Auto-generated Go SDK documentation from browserbase/stagehand-go README |
| packages/docs/v3/sdk/java.mdx | 5/5 | Auto-generated Java SDK documentation from browserbase/stagehand-java README |
| packages/docs/v3/sdk/ruby.mdx | 5/5 | Auto-generated Ruby SDK documentation from browserbase/stagehand-ruby README |
Sequence Diagram
sequenceDiagram
participant Dev as Developer
participant Script as sync-sdk-docs.js
participant GitHub as GitHub API
participant MDX as SDK MDX Files
participant Docs as docs.json
participant Browser as User Browser
participant LS as language-selector.js
Note over Dev,LS: Documentation Setup Flow
Dev->>Script: Run node scripts/sync-sdk-docs.js
Script->>GitHub: Fetch README.md for each SDK
GitHub-->>Script: Return README content
Script->>Script: Process README (remove badges, fix links)
Script->>MDX: Write processed MDX files
MDX-->>Script: Files created
Note over Dev,LS: User Interaction Flow
Browser->>Docs: Load documentation site
Docs->>Browser: Render multi-language dropdowns
Browser->>LS: Initialize language-selector.js
LS->>LS: Restore language from sessionStorage
LS->>Browser: Update dropdown & code blocks
Browser->>LS: User selects language (e.g., Python)
LS->>LS: Store selection in sessionStorage
LS->>Browser: Update sidebar dropdown text
LS->>Browser: Sync code block language
LS->>Browser: Hide/show version switcher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 issues found across 34 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/docs/v3/api-reference/java/sdk.mdx">
<violation number="1" location="packages/docs/v3/api-reference/java/sdk.mdx:400">
P2: Syntax error in code example: the semicolon after `.onCompleteFuture();` terminates the method chain prematurely, making `.whenComplete(...)` an invalid standalone statement. Remove the semicolon to fix the method chain.</violation>
</file>
<file name="packages/docs/v3/api-reference/python/sdk.mdx">
<violation number="1" location="packages/docs/v3/api-reference/python/sdk.mdx:49">
P2: Grammatical error: missing word "you" and comma. Should be "If you're using uv, you can follow these steps:"</violation>
</file>
<file name="packages/docs/v3/api-reference/go/sdk.mdx">
<violation number="1" location="packages/docs/v3/api-reference/go/sdk.mdx:282">
P2: Malformed code snippet - URL incorrectly embedded in function call. This looks like a sync error where a relative README link got converted to a full URL. Should be `param.Override[T](value)`.</violation>
<violation number="2" location="packages/docs/v3/api-reference/go/sdk.mdx:292">
P2: Malformed code example - URL incorrectly appears where a numeric argument should be. Should be `param.Override[stagehand.FooParams](12)`.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 issue found across 4 files (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/docs/v3/first-steps/quickstart.mdx">
<violation number="1" location="packages/docs/v3/first-steps/quickstart.mdx:15">
P2: Missing punctuation creates a run-on sentence. Add a period or semicolon after "TypeScript" to separate the two independent clauses.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
pirate
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, go ahead and merge once cubic comments are marked resolved or fixed
why
we need to update the docs to show new languages
what changed
test plan
Summary by cubic
Adds multi-language SDK docs with a sidebar language selector and synced code block languages, covering TypeScript, Python, Java, Go, and Ruby. Adds the canonical OpenAPI spec and auto-syncs SDK pages from GitHub READMEs.
New Features
Migration
Written for commit 833eb27. Summary will update on new commits.