Skip to content

Fix Console service variable in web docs examples#1507

Merged
ChiragAgg5k merged 1 commit into
masterfrom
fix-console-doc-example-variable
May 6, 2026
Merged

Fix Console service variable in web docs examples#1507
ChiragAgg5k merged 1 commit into
masterfrom
fix-console-doc-example-variable

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

What\n- Avoid generating const console in web docs examples for the Console service\n- Use consoleService for that service so console.log(result) still references the global console\n\n## Why\nThe generated Console SDK PR appwrite/sdk-for-console#89 received feedback that docs/examples/console/suggest-queries.md shadows the global console object and breaks the example at runtime.\n\n## Verification\n- php example.php web\n- composer lint-twig

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 6, 2026

Greptile Summary

This PR fixes the const console global-shadowing bug in generated JavaScript documentation examples by adding console to the JS reserved-keyword list and piping | escapeKeyword into the service variable name in the web, node, and deno templates. When the Console service is generated, the variable name becomes xconsole instead of console, leaving console.log(result) intact.

  • src/SDK/Language/JS.php: adds 'console' to getKeywords() so escapeKeyword produces xconsole for the Console service.
  • templates/web/docs/example.md.twig, templates/node/docs/example.md.twig, templates/deno/docs/example.md.twig: both the variable declaration and every subsequent usage now pass through | escapeKeyword.

Confidence Score: 5/5

The three changed templates all correctly apply the escaping filter in both declaration and usage sites; the keyword addition in JS.php is targeted and does not affect any other generated identifiers.

The changes are narrow and correct: console is added to the reserved-keyword list, and both occurrences of the service variable (declaration and call site) in each of the three templates are updated consistently. No logic paths are left unguarded within the files touched by this PR.

No files in this diff require special attention.

Important Files Changed

Filename Overview
src/SDK/Language/JS.php Adds 'console' to the JS reserved-keyword list so escapeKeyword renames it to xconsole in generated examples
templates/web/docs/example.md.twig Applies `
templates/node/docs/example.md.twig Applies `
templates/deno/docs/example.md.twig Applies `

Reviews (3): Last reviewed commit: "Fix console service docs example variabl..." | Re-trigger Greptile

Comment thread templates/web/docs/example.md.twig Outdated
@ChiragAgg5k ChiragAgg5k force-pushed the fix-console-doc-example-variable branch from d975e96 to 5f4fc24 Compare May 6, 2026 06:32
@ChiragAgg5k ChiragAgg5k force-pushed the fix-console-doc-example-variable branch from 5f4fc24 to 287fff2 Compare May 6, 2026 06:38
@ChiragAgg5k ChiragAgg5k merged commit 2ed7674 into master May 6, 2026
56 of 57 checks passed
@ChiragAgg5k ChiragAgg5k deleted the fix-console-doc-example-variable branch May 6, 2026 06:54
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