-
Notifications
You must be signed in to change notification settings - Fork 1
Support need items generation from marked RST in source code #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
We are currently using this feature (by using this branch instead of 1.1.0). I can confirm that this is working for us. Was finishing the implementation and getting this PR merged planned for 1.2? |
Didn't expect you tested it already! Very happy to receive such info, and thanks for it. I am currently working on its warning handling to be more user-friendly. And yes, this feature is planned for 1.2. |
3e9b795 to
01029db
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #44 +/- ##
==========================================
- Coverage 89.75% 89.55% -0.21%
==========================================
Files 29 31 +2
Lines 2548 2776 +228
Branches 297 335 +38
==========================================
+ Hits 2287 2486 +199
- Misses 165 184 +19
- Partials 96 106 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for generating Sphinx-Needs items from marked RST directives embedded in source code comments. It introduces a simplified RST directive parser using the Lark parsing library to extract and parse RST blocks, making it possible to define needs using full RST directive syntax within code comments.
Key Changes
- RST Parser Implementation: Added a new Lark-based parser (
sn_rst_parser.py) to parse RST directive syntax from extracted comment blocks, extracting directive types, titles, options, and content - Configuration Extensions: Extended
MarkedRstConfigwith three new fields (strip_leading_sequences,indented_spaces, andlink_options) to handle various comment styles and RST parsing requirements - Integration and Warning System: Integrated the parser into the analysis workflow with comprehensive error handling and warnings for invalid RST directives
Reviewed changes
Copilot reviewed 32 out of 33 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
src/sphinx_codelinks/analyse/sn_rst_parser.py |
New simplified RST parser module using Lark with grammar definitions, preprocessing, and transformation logic |
src/sphinx_codelinks/analyse/analyse.py |
Integration of RST parser into extraction workflow with warning handling and link option processing |
src/sphinx_codelinks/analyse/projects.py |
Extended warning collection to include RST parsing warnings from all projects |
src/sphinx_codelinks/analyse/models.py |
Extended MarkedRst model to include parsed need data |
src/sphinx_codelinks/analyse/utils.py |
Updated RST extraction logic with improved row offset calculation |
src/sphinx_codelinks/config.py |
Added new configuration fields for RST parsing behavior |
src/sphinx_codelinks/sphinx_extension/directives/src_trace.py |
Updated directive to handle both one-line needs and parsed RST blocks |
src/sphinx_codelinks/cmd.py |
Added call to update_warnings in analyse command |
tests/test_rst_parser.py |
Comprehensive test suite for RST parser with positive and negative test cases |
tests/test_analyse.py |
Added integration tests for RST extraction and parsing |
tests/fixture_files/analyse_rst.yml |
Test fixtures for various RST marker scenarios |
tests/conftest.py |
Added test infrastructure for fixture file parametrization |
tests/data/marked_rst/dummy_1.cpp |
Fixed spacing in inline RST marker |
tests/data/dcdc/charge/demo_2.cpp |
Added RST block example with proper markers |
docs/source/components/rst_parser.rst |
New documentation describing the simplified RST parser and its limitations |
docs/source/components/configuration.rst |
Documented new configuration options for RST parsing |
docs/source/components/analyse.rst |
Updated documentation with RST block examples |
docs/source/components/directive.rst |
Updated to reflect support for both one-line and RST block needs |
docs/source/development/change_log.rst |
Added release notes for new RST parsing feature |
pyproject.toml |
Added Lark dependency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
After running the tests I find a new file in my worktree |
ubmarco
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This valid and basic RST
.. spec:: comment in content
:option: value
:option2: value2
Content without blank line.leads to UnexpectedToken() parsing result.
Indentation spaces need to be configured if it's not 3 by default |
|
I have a bug report from this feature. I just started using When I use that as part of marked-rst, like so: It is not working properly and it emits: If I use it in a rst file, then it works fine so I know it's not the syntax. |
It is super interesting. The directive parser extracts the directive The updated documentation of this PR mentioned the limitation of this parser, but it could be misleading for users to think it can do things like what Sphinx does. I will talk to my colleagues about it, and thank you so much for your feedback. |
92def86 to
08c3dda
Compare
08c3dda to
555de94
Compare
Addressing #43 by adding simplified RST directive parser and feature to remove leading sequences of marked RST text
Documentation
docs/source/components/rst_parser.rst) describing the new simplified RST parser, its purpose, and limitations.RST block extraction and parsing:
MarkedRstConfigand related configuration files to support new fields:strip_leading_sequences,indented_spaces, andlink_optionsfor more stable RST extraction and parsing.Integration and warning handling:
analyse, including logic to handle parsing errors and report warnings.MarkedRstmodel to store parsed need data from RST blocks.