You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/components/rst_parser.rst
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,17 @@
1
-
Simplified reStructuredText Parser
2
-
==================================
1
+
RST directive Parser
2
+
====================
3
3
4
4
The :ref:`analyse <analyse>` module provides a simplified parser for reStructuredText (reST) directives using the ``Lark`` parsing library.
5
5
It is designed to only parse the RST text extracted by :ref:`RST markers <analyse_rst>`, focusing on specific directive types and their associated options and content.
6
6
By doing so, the parser avoids the complexity of a full reST parser while still capturing the essential structure needed for Sphinx-Needs integration from the source code.
7
7
8
-
The parser does't have the Sphinx-Needs directive validation logic. It only checks the syntax of the RST directives and extracts the directive type, argument, options, and content.
8
+
The parser doesn't have the Sphinx-Needs directive validation logic. It only checks the syntax of the RST directives and extracts:
9
+
- directive type
10
+
- argument (title)
11
+
- options
12
+
- content
13
+
14
+
These extracted data will be furthered used with :external+needs:ref:`add_need <api>` function to create Sphinx-Needs items in ``src-trace`` directive.
Copy file name to clipboardExpand all lines: src/sphinx_codelinks/analyse/sn_rst_parser.py
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,11 @@
1
-
"""Test script for RST directive Lark parser."""
1
+
"""Parse reStructuredText (RST) directives using the Lark parser.
2
+
3
+
This module provides functionality to parse RST directive blocks and extract their components,
4
+
such as directive type, title, options, and content for further use by add_need() in src-trace directive.
5
+
"""
2
6
3
7
# ruff: noqa: N802
4
-
# TODO: Not sure Lark is the right tool for this job since the it has a few limitations such as lack of support for dynamic indentation levels while extracting leading spaces in content.
8
+
# TODO: Not sure Lark is the right tool for this job since it has a few limitations such as lack of support for dynamic indentation levels while extracting leading spaces in content.
5
9
# Consider switching to Visitor instead of Transformer to have more control on resolving the tree or implement a custom parser if needed.
0 commit comments