sphinx-markdown-builder icon indicating copy to clipboard operation
sphinx-markdown-builder copied to clipboard

`singlemarkdown` builder

Open akaihola opened this issue 7 months ago • 5 comments

Similar to the singlehtml built-in builder in Sphinx, the singlemarkdown builder collects all documentation pages together in a single .md file.

This is useful e.g. for providing documentation of a Python package to a language model / coding agent.

akaihola avatar May 17 '25 12:05 akaihola

Pull Request Test Coverage Report for Build 18984393558

Details

  • 136 of 150 (90.67%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.6%) to 97.747%

Changes Missing Coverage Covered Lines Changed/Added Lines %
sphinx_markdown_builder/singletranslator.py 12 16 75.0%
sphinx_markdown_builder/singlemarkdown.py 118 128 92.19%
<!-- Total: 136 150
Totals Coverage Status
Change from base Build 18555332874: -0.6%
Covered Lines: 911
Relevant Lines: 932

💛 - Coveralls

coveralls avatar May 17 '25 12:05 coveralls

@akaihola This seems like a nice addition. Can you address the failing tests? I think it is due to the use of the type hint str|None which is not supported by python 3.9. Python 3.9 is still a supported version, so I suggest to use the common approach Optional[str] for now.

liran-funaro avatar Jul 10 '25 21:07 liran-funaro

@akaihola This seems like a nice addition. Can you address the failing tests? I think it is due to the use of the type hint str|None which is not supported by python 3.9. Python 3.9 is still a supported version, so I suggest to use the common approach Optional[str] for now.

Fixed!

akaihola avatar Jul 16 '25 21:07 akaihola

This is great! I pulled it into an experimental PR to try and use it to generate a llms-full.txt and noticed an issue with how some of the headings were generated:

## Changelog

# Changelog

## 0.7.0

- Add `llms_txt_uri_template` configuration option to control the link behavior in `llms_txt_filename`.
  [#48](https://github.com/jdillard/sphinx-llms-txt/pull/48)

### 0.6.0

- Improve \_sources directory handling
  [#47](https://github.com/jdillard/sphinx-llms-txt/pull/47)

#### 0.5.3

- Make sphinx a required dependency since there are imports from Sphinx
  [#44](https://github.com/jdillard/sphinx-llms-txt/pull/44)

##### 0.5.2

- Remove support for singlehtml
  [#40](https://github.com/jdillard/sphinx-llms-txt/pull/40)

###### 0.5.1

- Only allow builders that have \_sources directory
  [#38](https://github.com/jdillard/sphinx-llms-txt/pull/38)

The headings look fine on the normal markdown builder for that page: https://sphinx-llms-txt--51.org.readthedocs.build/en/51/changelog.md

edit: I made a (AI generated) PR here: https://github.com/akaihola/sphinx-markdown-builder/pull/1

jdillard avatar Oct 28 '25 07:10 jdillard

Thanks @jdillard! Obviously the original behavior is wrong. I'd like to add a failing unit test for your example case in this PR, and then verify that jdillard/sphinx-llms-txt#51 fixes it. I'll also rebase on liran-funaro:main and solve the conflict in sphinx_markdown_builder/__init__.py. You'll need to then rebase your PR.

akaihola avatar Oct 31 '25 18:10 akaihola