Skip to content

feat: support dotted path syntax - #218

Merged
Aarebecca merged 7 commits into
mainfrom
feat/dotted-path
Mar 5, 2026
Merged

Aarebecca merged 7 commits into
mainfrom
feat/dotted-path

Conversation

@Aarebecca

@Aarebecca Aarebecca commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor
  • 信息图语法支持点分隔路径写法
theme.base.text.fill #fff

等价于

theme
  base
    text
      fill #fff

对于降低嵌套非常有用。

  • 优化官网 Demo 效果
  • 导出图片支持移除背景

  • infographic syntax supports dot-separated path notation
theme.base.text.fill #fff

is equivalent to

theme
  base
    text
      fill #fff

Very useful for reducing nesting.

  • Optimize official website Demo effects
  • Support remove background when export image
@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 enhances the infographic syntax by adding a convenient dotted path notation, which simplifies the definition of nested configurations and improves readability. This feature is particularly useful for reducing boilerplate when dealing with deep configuration structures. Concurrently, the PR includes updates to the website's demo showcase to better handle theme changes, ensuring a consistent user experience.

Highlights

  • Dotted Path Syntax Support: Introduced support for a new dotted path syntax in infographic configurations, allowing users to define deeply nested properties more concisely, reducing the need for extensive indentation.
  • Website Demo Optimization: Optimized the official website's demo effects, specifically by integrating theme detection to ensure the Infographic component renders correctly based on the current theme.
Changelog
  • tests/unit/syntax/parse-syntax.test.ts
    • Added new test cases to validate the parsing of dotted key paths as nested objects.
    • Included tests for mixing dotted keys with traditional indented blocks.
    • Added a test case to ensure proper error reporting when dotted keys attempt to traverse list nodes.
  • site/src/components/Layout/HomePage/StreamingSyntaxShowcase.tsx
    • Integrated the useTheme hook to detect the current theme (dark/light).
    • Added a previewKey state to force re-rendering of the Infographic component when the display code is reset.
    • Conditionally applied the 'dark' theme to the Infographic component's initial options based on the detected theme.
  • site/src/content/learn/infographic-syntax.en.md
    • Added a new section detailing the 'Dotted Path Syntax', explaining its usage and benefits.
    • Provided examples demonstrating how to use dotted keys and how they can be mixed with indented blocks.
    • Included important notes regarding the intended use of dotted paths for object fields and error conditions for array traversal.
  • site/src/content/learn/infographic-syntax.md
    • Added a new section in Chinese detailing the 'Dotted Path Syntax', explaining its usage and benefits.
    • Provided examples demonstrating how to use dotted keys and how they can be mixed with indented blocks.
    • Included important notes regarding the intended use of dotted paths for object fields and error conditions for array traversal.
  • src/syntax/parser.ts
    • Introduced a new helper function assignObjectEntry to handle the logic for assigning values based on dotted key paths, creating intermediate objects as needed.
    • Implemented error handling within assignObjectEntry for invalid dotted key paths and attempts to assign under list values.
    • Modified the parseSyntaxToAst function to utilize assignObjectEntry for processing key-value pairs, enabling support for the new dotted path syntax.
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. ↩

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

Copy link
Copy Markdown
Contributor

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 introduces support for dotted path syntax in the infographic grammar, which is a great feature for reducing nesting. The implementation is well-structured and comes with corresponding tests and documentation updates. The optimizations to the website demo, including dark mode support and fixing re-rendering issues, are also valuable improvements.

I have found a critical security vulnerability related to prototype pollution in the new parsing logic. My review comments include specific suggestions to fix this. Please address these security concerns.

Comment thread src/syntax/parser.ts Resolved
Comment thread src/syntax/parser.ts Resolved
@codecov-commenter

codecov-commenter commented Mar 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.29%. Comparing base (15c788e) to head (3310cb7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/syntax/parser.ts 91.20% 8 Missing ⚠️
src/exporter/svg.ts 46.15% 7 Missing ⚠️
src/exporter/png.ts 0.00% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #218      +/-   ##
==========================================
+ Coverage   46.15%   46.29%   +0.13%     
==========================================
  Files         341      341              
  Lines       28005    28106     +101     
  Branches     2289     2310      +21     
==========================================
+ Hits        12926    13011      +85     
- Misses      15067    15083      +16     
  Partials       12       12              
Flag Coverage Δ
infographic 46.29% <83.33%> (+0.13%) ⬆️

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

Files with missing lines Coverage Δ
src/exporter/types.ts 100.00% <ø> (ø)
src/version.ts 100.00% <100.00%> (ø)
src/exporter/png.ts 4.44% <0.00%> (-0.11%) ⬇️
src/exporter/svg.ts 76.47% <46.15%> (-1.43%) ⬇️
src/syntax/parser.ts 88.00% <91.20%> (+1.36%) ⬆️
🚀 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

Copy link
Copy Markdown
Contributor Author

/gemini review

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

Copy link
Copy Markdown
Contributor

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 introduces two main features: support for dotted path syntax in the infographic language and the ability to export images without a background. While the dotted path implementation includes security checks to prevent prototype pollution, a local prototype pollution vulnerability has been identified. This is due to the omission of these checks for non-dotted keys in the assignObjectEntry function, which allows an attacker to manipulate the internal AST structure by providing a key named __proto__. Additionally, there is a suggestion to improve code maintainability by reducing duplication in the file download logic.

Comment thread src/syntax/parser.ts Resolved
Comment thread site/src/components/Infographic.tsx Resolved
@Aarebecca
Aarebecca merged commit c30aa55 into main Mar 5, 2026
3 checks passed
@Aarebecca
Aarebecca deleted the feat/dotted-path branch March 5, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants