DocsGPT
DocsGPT copied to clipboard
🐛 Bug Report: RST parser cleanup flattens code and changes numbers
📜 Description
RstParser cleans every .rst file before the text is stored. Two cleaners are on by default, and both change real content.
remove_whitespaces_excesstreats newlines and indentation as extra spaces and replaces them with two spaces. Paragraphs and code become one line.remove_characters_excessshortens any character repeated 4 or more times down to 3.100000becomes1000.
👟 Reproduction steps
- From the repo, run:
uv run python -c "from docsgpt.parser.file.rst_parser import RstParser; p=RstParser(); open('sample.rst','w',encoding='utf-8').write('Title\n=====\n\nThe budget is 100000.\n\n def add(a, b):\n return a + b\n\nParagraph two.\n'); print(p.parse_file('sample.rst'))"
- Read the printed text.
👍 Expected behavior
The amount stays 100000. The blank line stays. The function stays on two indented lines.
👎 Actual Behavior with Screenshots
The budget is 1000. def add(a, b): return a + b Paragraph two.
💻 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!)
None. The parser can be called on its own.
📃 Provide any additional context for the Bug.
File: docsgpt/parser/file/rst_parser.py. Both cleaners default to on inside parse_file. Tests check that the flags are on, but not that numbers and code survive.
📖 Relevant log output
['\n\nTitle - Chunk 1\nThe budget is 1000. def add(a, b): return a + b Paragraph two.']
👀 Have you spent some time to check if this bug has been raised before?
- [x] 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
- [x] I agree to follow this project's Code of Conduct
Hi @arc53-machine, Could you please assign this issue to me!
@sonu7089, you're assigned to this issue.
- Open a PR or post progress within 14 days; otherwise the issue will be available to others.
- Read
CONTRIBUTING.mdand add regression tests for numbers, blank lines and code indentation. - Include a screenshot or short recording showing the corrected parser output in your PR.
Automated triage. A maintainer will follow up.