Skip to content

feat: Improve syntax parser flexibility and align skill docs#221

Merged
Aarebecca merged 5 commits intomainfrom
refactor/skills
Mar 20, 2026
Merged

feat: Improve syntax parser flexibility and align skill docs#221
Aarebecca merged 5 commits intomainfrom
refactor/skills

Conversation

@Aarebecca
Copy link
Copy Markdown
Contributor

@Aarebecca Aarebecca commented Mar 15, 2026

Summary

  • support the ellipsis Infographic... keyword variant and allow syntax examples without code fences
  • recognize True and False boolean literals, and ignore # and // comments during parsing
  • default node ids to their labels when ids are omitted, then refresh the related docs and skill prompts to match the updated syntax behavior
  • resolve unknown template names to the closest registered template key before parsing options
  • apply the resolved template key consistently to template defaults, parsed data, and stored template metadata
  • add unit coverage for typo-tolerant template lookup and fallback behavior in both options parsing and template registry utilities

Testing

  • npx vitest run __tests__/unit/syntax/parse-syntax.test.ts

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the flexibility and user-friendliness of the syntax parser. By introducing support for implicit template declarations, case-insensitive boolean literals, and ignoring comments and code fences, the parser becomes more resilient to diverse input formats. Additionally, it streamlines node identification by defaulting missing IDs to labels, and ensures all related documentation and skill prompts are aligned with these improved capabilities, making the system easier to use and understand.

Highlights

  • Syntax Parser Flexibility: The parser now supports more flexible input, including the 'Infographic...' keyword variant, syntax examples without code fences, and ignores '#' and '//' comments during parsing.
  • Boolean Literal Recognition: The parser can now recognize 'True' and 'False' boolean literals, making the syntax more robust to variations in input.
  • Node ID Defaulting: Missing node IDs will now default to their corresponding labels, reducing the need for explicit ID declarations in certain cases.
  • Documentation and Skill Alignment: The related documentation and skill prompts have been updated to reflect the new syntax behaviors and provide clearer guidance.
Changelog
  • tests/unit/syntax/parse-syntax.test.ts
    • Added tests for defaulting missing item/node IDs to their labels when explicit relations exist.
    • Added tests for inferring templates from a bare first line and handling unknown root keys.
    • Added tests to confirm that markdown code fences and comment-only lines are ignored during parsing.
    • Added tests to verify case-insensitive parsing of boolean values.
  • site/src/content/learn/infographic-syntax.en.md
    • Updated an example to demonstrate that node IDs can be omitted and will default to their labels.
  • site/src/content/learn/infographic-syntax.md
    • Updated an example in the Chinese documentation to demonstrate that node IDs can be omitted and will default to their labels.
  • skills/infographic-creator/SKILL.md
    • Revised the Chinese syntax rules and examples for various infographic templates, including list-*, sequence-*, hierarchy-*, compare-*, chart-*, and relation-*.
    • Updated descriptions for template, data, and theme fields.
    • Added a 'Self-check list' section for output validation.
  • skills/infographic-syntax-creator/SKILL.md
    • Refined the rules for compare-* templates, specifically distinguishing between binary comparison types and others regarding root node counts.
  • skills/infographic-syntax-creator/references/prompt.md
    • Restructured the prompt document, adding sections for '语法示例' (Syntax Examples) and '自检清单' (Self-check list).
    • Updated and clarified syntax rules, including indentation, icon usage, value types, and palette format.
    • Provided more detailed guidance and examples for main data field selection across different template types.
    • Revised the '生成流程' (Generation Process) steps and '输出格式' (Output Format) instructions.
  • src/syntax/index.ts
    • Introduced ALLOWED_ROOT_KEYS to define valid top-level syntax elements.
    • Implemented assignMissingNodeIds to automatically assign node IDs from labels if IDs are not explicitly provided.
    • Added inferTemplateFromBareFirstLine to allow the parser to infer the template from the first line if no explicit 'infographic' or 'template' keyword is present.
    • Integrated the new ID assignment and template inference logic into the main parseSyntax function.
    • Updated root key validation to use the new ALLOWED_ROOT_KEYS set.
  • src/syntax/mapper.ts
    • Added normalizeBooleanLiteral to handle case-insensitive 'True' and 'False' values.
    • Modified parseScalar and mapWithSchema to correctly parse and validate boolean values regardless of their casing.
  • src/syntax/parser.ts
    • Added helper functions isCommentLine and isCodeFenceLine to identify comment lines and markdown code fences.
    • Updated parseSyntaxToAst to ignore lines identified as comments or code fences, improving parsing robustness.
  • src/syntax/types.ts
    • Added implicit_template to the SyntaxErrorCode enum to support warnings for inferred templates.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly improves the flexibility of the syntax parser by adding support for case-insensitive boolean literals, ignoring comments and code fences, and defaulting node IDs from labels. The changes are well-tested and the documentation has been updated to reflect the new behavior. I have a couple of suggestions to improve code maintainability in tests and to address a minor inconsistency in parsing boolean-like values.

Comment thread __tests__/unit/syntax/parse-syntax.test.ts
Comment thread __tests__/unit/syntax/parse-syntax.test.ts
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 15, 2026

Codecov Report

❌ Patch coverage is 98.25581% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.62%. Comparing base (27d239a) to head (e23a8bc).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/syntax/mapper.ts 84.21% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #221      +/-   ##
==========================================
+ Coverage   46.29%   46.62%   +0.32%     
==========================================
  Files         341      342       +1     
  Lines       28109    28261     +152     
  Branches     2310     2368      +58     
==========================================
+ Hits        13014    13177     +163     
+ Misses      15083    15072      -11     
  Partials       12       12              
Flag Coverage Δ
infographic 46.62% <98.25%> (+0.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/options/parser.ts 96.66% <100.00%> (+3.39%) ⬆️
src/syntax/index.ts 96.99% <100.00%> (+2.52%) ⬆️
src/syntax/parser.ts 88.33% <100.00%> (+0.33%) ⬆️
src/syntax/types.ts 100.00% <ø> (ø)
src/templates/registry.ts 86.66% <100.00%> (+6.66%) ⬆️
src/templates/utils.ts 100.00% <100.00%> (ø)
src/syntax/mapper.ts 67.69% <84.21%> (+1.09%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Aarebecca Aarebecca changed the title Improve syntax parser flexibility and align skill docs feat: Improve syntax parser flexibility and align skill docs Mar 16, 2026
@Aarebecca Aarebecca merged commit ea238f5 into main Mar 20, 2026
3 checks passed
@Aarebecca Aarebecca deleted the refactor/skills branch March 20, 2026 07:57
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.

2 participants