Docs-to-Markdown [D2M]
docs-to-md (d2m) converts ReadTheDocs/Sphinx documentation sites into clean
Markdown files — useful as input for LLMs, RAG pipelines, or offline reading.
It discovers every page linked from a project's table of contents, downloads the pages concurrently, and converts each one with a pluggable engine:
| Engine | Description | Needs a key? |
|---|---|---|
local |
Offline HTML → Markdown via markdownify (default, zero config) |
No |
jina |
Hosted Jina Reader API (r.jina.ai) |
JINA_API_KEY |
openai |
Any OpenAI-compatible chat API — Ollama reader-lm, OpenAI, vLLM… |
OPENAI_API_KEY |
Install
pip install docs-to-md
# or run directly with uv
uvx docs-to-md --help
Usage
d2m readthedocs <root-url> [OPTIONS]
Options:
-o, --output-dir PATH Directory the <project>/ output is written to
[default: output]
-n, --name TEXT Project name (default: derived from the URL)
-e, --engine local | jina | openai [default: local]
-k, --api-key TEXT API key (or JINA_API_KEY / OPENAI_API_KEY / D2M_API_KEY)
--api-base TEXT OpenAI-compatible base URL [default: http://localhost:11434/v1]
-m, --model TEXT Model for the openai engine [default: reader-lm]
-c, --concurrency INT Max parallel requests [default: 4]
--timeout FLOAT Per-request timeout in seconds [default: 30]
--retries INT Retries on 429/5xx/network errors [default: 3]
--save-html Also keep the downloaded HTML under html/
-v, --verbose Debug logging
Examples
# offline, no keys needed
d2m readthedocs https://example-sphinx-basic.readthedocs.io/en/latest/
# Jina Reader API (export JINA_API_KEY=... first)
d2m readthedocs https://example-sphinx-basic.readthedocs.io/en/latest/ -e jina
# local Ollama model (`ollama pull reader-lm`, serving on :11434)
d2m readthedocs https://example-sphinx-basic.readthedocs.io/en/latest/ \
-e openai --api-base http://localhost:11434/v1 -m reader-lm
Output layout:
output/
└── <project>/
├── index.md
├── <page>.md
└── html/ # only with --save-html
└── <page>.html
Library use
import asyncio
from docs_to_md import LocalConverter, convert_readthedocs
result = asyncio.run(
convert_readthedocs(
"https://example-sphinx-basic.readthedocs.io/en/latest/",
converter=LocalConverter(),
output_dir="output",
)
)
for page in result.failed:
print("failed:", page.url, page.error)
Jina API rate limits
Get an API key from Jina. Unauthenticated requests to
r.jina.ai are heavily rate-limited (20 RPM) and may be rejected — export
JINA_API_KEY (or pass --api-key) for reliable results.
Development
This project is managed with uv.
uv sync # create .venv and install all deps (incl. dev group)
uv run pytest # run the offline test suite (network calls are mocked)
uv run ruff check # lint
uv run ruff format # format
uv build # build wheel + sdist
Pre-commit hooks (ruff + hygiene checks):
uv run pre-commit install
uv run pre-commit run --all-files
Metadata
Release files for docs-to-md 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| docs_to_md-0.2.0.tar.gz | 9.0 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| docs_to_md-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.5 kB
Release files / docs_to_md-0.2.0.tar.gz
| Download URL | docs_to_md-0.2.0.tar.gz |
|---|---|
| Size | 9.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f38408d81c112de49a6359445bc0027bc49e55ac4af866b547066844cb1d915f
|
|
BLAKE2b-256 checksum How to use checksums |
62b5ad38bf65e71c38877de87df8b97db5c475f52657698e2fa80ad86fa6b1c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logRelease files / docs_to_md-0.2.0-py3-none-any.whl
| Download URL | docs_to_md-0.2.0-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cea3bd44038522a56b7bfbaabaac4852d0cccd8f414d075a4f187e09ac5bebea
|
|
BLAKE2b-256 checksum How to use checksums |
55525a60219f6738c860b86593c4598216dfe40c5474429c260c4cfa75eb62d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logSecurity for docs-to-md 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for docs_to_md-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.