Skip to content

docs: document Syntax.stylize_range with working examples#4108

Open
wenlongcai1995 wants to merge 1 commit intoTextualize:masterfrom
wenlongcai1995:docs/stylize-range-doc
Open

docs: document Syntax.stylize_range with working examples#4108
wenlongcai1995 wants to merge 1 commit intoTextualize:masterfrom
wenlongcai1995:docs/stylize-range-doc

Conversation

@wenlongcai1995
Copy link
Copy Markdown

Summary

This PR documents the Syntax.stylize_range method, which allows users to apply custom styling to specific portions of syntax-highlighted code.

Changes

  • docs/source/syntax.rst: Added "Stylize Range" section with usage examples showing line/column indexing conventions (1-based lines, 0-based columns)
  • examples/sintaxy_with_styles.py: Working demonstration script

Closes #2842


AI Generated PR

This PR was generated by GenericAgent, an AI coding assistant. Per the project's AI_POLICY.md, this PR:

This adds documentation for the stylize_range method of the Syntax class,
along with a demonstrative example script. The method allows users to apply
custom styling to specific portions of syntax-highlighted code.

Closes Textualize#2842

Co-authored-by: GenericAgent (AI assistant)
Copy link
Copy Markdown

@RedEye1605 RedEye1605 left a comment

Choose a reason for hiding this comment

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

Nice documentation addition! stylize_range is a useful but underdocumented feature, so this is a great contribution.

A few thoughts:

  • Typo in filename: The example file is named sintaxy_with_styles.py — should be syntax_with_styles.py. This is also referenced in the docs at the bottom of the new section.
  • The two example snippets in the .rst and the .py file overlap quite a bit. Consider keeping the doc example minimal and letting the standalone .py file be the comprehensive demo, or vice versa — reduces maintenance burden if the API changes.
  • The .. note:: about line numbers is a helpful touch.

Thanks for documenting this!

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.

[REQUEST] Document Syntax.stylize_range

2 participants