Bug Report: RstParser does not remove standard reStructuredText directives
Description
RstParser.remove_directives() does not recognize standard reStructuredText directive syntax.
The current regex expects a backtick before the directive and does not handle the required space between .. and the directive name:
pattern = r"`\.\.([^:]+)::"Therefore, valid directives such as .. note:: remain in the parsed content.
Reproduction steps
- Create an instance of
RstParser. - Pass the following content to
remove_directives():Text before\n.. note:: Important information\nText after - Examine the returned string.
- Observe that the valid
.. note::directive marker remains unchanged.
Expected behavior
The parser should remove the standard reStructuredText directive marker while preserving useful inline content.
Expected result:
Text before\nImportant information\nText after
Actual Behavior with Screenshots
The method returns the directive unchanged:
Text before\n.. note:: Important information\nText after
This is a parser-level bug, so a UI screenshot is not available. A regression test can demonstrate the failure.
Operating system
Windows
What browsers are you seeing the problem on?
No response
What development environment are you experiencing this bug on?
Local dev server
Did you set the correct environment variables in the right path? List the environment variable names (not values please!)
No response
Provide any additional context for the Bug.
The existing test_remove_directives test uses the nonstandard form `..note::`. It therefore does not verify valid reStructuredText syntax such as .. note::.
Relevant files:
docsgpt/parser/file/rst_parser.pytests/parser/file/test_rst_parser.py
I am willing to add regression coverage and submit a focused PR.
Relevant log output
Have you spent some time to check if this bug has been raised before?
- I checked and didn't find similar issue
Are you willing to submit PR?
Yes, I am willing to submit a PR!
⚖️ Code of Conduct
- I agree to follow this project's Code of Conduct
Source: arc53/DocsGPT