DocsGPT icon indicating copy to clipboard operation
DocsGPT copied to clipboard

🐛 Bug Report: RST parser cleanup flattens code and changes numbers

Open sonu7089 opened this issue 1 month ago • 2 comments

📜 Description

RstParser cleans every .rst file before the text is stored. Two cleaners are on by default, and both change real content.

  • remove_whitespaces_excess treats newlines and indentation as extra spaces and replaces them with two spaces. Paragraphs and code become one line.
  • remove_characters_excess shortens any character repeated 4 or more times down to 3. 100000 becomes 1000.

👟 Reproduction steps

  1. 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'))"
  1. 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

sonu7089 avatar Oct 14 '26 18:10 sonu7089

Hi @arc53-machine, Could you please assign this issue to me!

sonu7089 avatar Oct 14 '26 18:10 sonu7089

@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.md and 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.

arc53-machine avatar Oct 14 '26 18:10 arc53-machine