Skip to content

docs(smartui): fix broken syntax in code snippets across SDK docs - #3264

Open
chaitanyas-maker wants to merge 1 commit into
LambdaTest:stagefrom
chaitanyas-maker:docs/smartui-code-snippet-syntax-fixes
Open

docs(smartui): fix broken syntax in code snippets across SDK docs#3264
chaitanyas-maker wants to merge 1 commit into
LambdaTest:stagefrom
chaitanyas-maker:docs/smartui-code-snippet-syntax-fixes

Conversation

@chaitanyas-maker

Copy link
Copy Markdown
Contributor

What this fixes

I ran every fenced code block in the SmartUI doc set (1,317 blocks across 103 pages) through the real interpreters — python3 compile, node --check, ruby -c, json.loads — and fixed every block that could not parse. Five defect families came out, each reproduced live.

1. The .smartui.json config sample is invalid JSON (7 SDK pages)

enableJavaScript": true is missing its opening quote in the Cypress, Playwright, Puppeteer, Selenium-JS, Selenium-Ruby, TestCafe and WebdriverIO pages, and visual": true in the Espresso page.

Verified live against the CLI:

# documented config
[smartui] Error: Expected property name or '}' in JSON at position 7

# same config with the quote restored
✔ Screenshots captured successfully
✔ Finalized build

This one blocks onboarding outright — a user pasting the documented config cannot start.

2. Missing opening quote inside code (8 files, Java / JavaScript / Ruby)

smartuiSnapshot(driver, HomePage-Header"), By.id(content"), System.getenv(PROJECT_TOKEN"), new File(path/to/document.pdf"), page.navigate(https://example.com"), Map<String, Object">, and others.

3. Curly quotes in Cypress snippets (12 blocks)

cy.smartuiSnapshot(‘Screenshot Name’, options); fails with SyntaxError: Invalid or unexpected token.

4. JavaScript object literals inside Python blocks (Selenium and Playwright Python SDK)

# documented — SyntaxError, "class" is reserved in Python
options = { ignoreDOM: { class: ["Class-1"] } }

# fixed
options = { "ignoreDOM": { "class": ["Class-1"] } }

The other bare keys (id, xpath, cssSelector) parse but raise NameError at runtime. This also retags 23 fences that were marked ```rb or ```py while containing Python, so highlighting was wrong too.

5. Corrupted operators

async t ="> { should be async t => { (TestCafe), and gem 'lambdatest-selenium-driver', '~"> 1.0' should be '~> 1.0' (Ruby SDK).

Also fixed

  • ffrom playwright.sync_api import ... typo in the Playwright Python quickstart
  • Unclosed let config = { object in selenium-visual-regression.md
  • Python using backticks where a string literal was intended in the Remote executor URL
  • Two missing closing fences (smartui-appium-hooks.md, smartui-cli-env-variables.md) that left <TabItem> markup rendering inside code blocks
  • A Java block tagged ```javascript
  • Broken fence titles of the form title="... to ignore by" ID"

Likely root cause

36bc2ac3 "best practice section update for smartui docs" (10 Nov 2025, 42 files, 8,863 insertions) introduced families 1 and 2; f153c312 "fixes for tabs" introduced family 5. The signature — a dropped opening " combined with a spurious " inserted before > — looks like a bad HTML-entity decode in a bulk automated edit rather than hand-typing. These have been published for over eight months and are live on testmuCom today.

Verification

After this change, every Python, Ruby and JSON config block in the SmartUI doc set parses, and no file has an unbalanced code fence. The remaining JavaScript parse failures are deliberate partial fragments (bare 'LT:Options': { ... } objects and curl commands in js-tagged blocks), not defects.

Suggested follow-up

A CI step that syntax-checks fenced code blocks would stop this recurring. Happy to raise that separately if useful.

Audited all 1,317 fenced code blocks on the SmartUI doc set by running
them through the real interpreters (python3, node --check, ruby -c,
json.loads). Fixes every block that could not parse.

Five defect families, all reproduced live:

1. Missing opening quote in the .smartui.json config sample, in 7 SDK
   pages plus espresso. Verified live: the documented config aborts the
   CLI with "Expected property name or '}' in JSON at position 7"; with
   the quote restored the same config captures a build successfully.

2. Missing opening quote inside code, e.g. smartuiSnapshot(driver,
   HomePage-Header"), By.id(content"), System.getenv(PROJECT_TOKEN"),
   new File(path/to/document.pdf"). Java, JavaScript and Ruby.

3. Curly quotes instead of straight quotes in 12 Cypress snippets,
   which fail with "Invalid or unexpected token".

4. JavaScript object literals inside Python blocks, e.g.
   { ignoreDOM: { class: [...] } }. Bare "class" is a SyntaxError in
   Python; the other bare keys raise NameError. Also retags 23 fences
   that were marked rb or py while containing Python.

5. Corrupted operators: "async t =\"> {" should be "async t => {", and
   gem '~"> 1.0' should be '~> 1.0'.

Also fixes: the "ffrom" typo in the Playwright Python quickstart, an
unclosed config object in selenium-visual-regression, Python backticks
used where a string was intended, two missing closing fences that left
TabItem markup rendering inside code blocks, a Java block tagged as
javascript, and broken fence titles of the form title="... by" ID".

After these changes every Python, Ruby and JSON config block in the
SmartUI doc set parses. The remaining JavaScript parse failures are
deliberate partial fragments (bare object literals and curl commands),
not defects.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0197inyHsQ3V3CxPicLLvFJy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant