Mirrors HTML documentation to Markdown for AI integration
Project description
mirror-docs 🪞📚
Description
mirror-docs is a Python CLI tool that helps you create an offline, token-efficient, local knowledge base of the documentation for frameworks and libraries used in your project.
It mirrors HTML documentation 🪞 from a specified web source, converts the relevant content to Markdown ✍️, and generates a structured sitemap 🗺️.
This speeds up development and improves the accuracy of AI coding assistants (like Cline) by providing them with targeted, relevant context directly from the official docs, reducing the need for external API calls and saving context window tokens.
Key Benefits ✨
- Reduced API/MCP Calls: Saves costs and avoids potential rate limits associated with external documentation lookups by AI assistants or developers.
- Token Efficiency: Markdown is significantly more compact than HTML, saving valuable context window space when feeding documentation to Large Language Models (LLMs).
- Speed & Offline Access: Provides instant local access to documentation, independent of internet connectivity.
- Contextual Relevance: Enables feeding specific, verified documentation sections to AI tools, leading to better, more accurate code generation and analysis.
- Version Alignment: Ensures the local documentation can match the specific version of the library/framework used in your project by mirroring from the corresponding documentation URL.
Usage 🚀
If you use uv you can run uvx in any repo:
uvx mirror-docs <url>
Or if working on this repo run the mirror_docs.py script using uv (or your preferred Python environment manager):
uv run mirror_docs.py <url> [--output-dir <output_directory>]
Arguments:
url: (Required) The full URL to the documentation path you want to mirror (e.g.,https://react.dev/reference/rsc).--output-dir: (Optional) The local directory where mirrored content will be stored. Defaults to.mirror-docs. It's recommended to add this directory to your project's.gitignorefile.
Example (Mirroring React Reference Docs):
# Run the tool (using default output directory '.mirror-docs')
uv run mirror_docs.py https://react.dev/reference
# Run the tool with a custom output directory
uv run mirror_docs.py https://react.dev/reference --output-dir my-react-docs
This will:
- Mirror HTML content from
https://react.dev/referenceinto<output_dir>/html/react.dev/reference/. - Convert the main content of each HTML page into Markdown files within
<output_dir>/markdown/react.dev/reference/. - Generate a sitemap at
<output_dir>/sitemap.txtlisting the Markdown files (relative to themarkdowndirectory) and their titles like:react.dev/reference/rsc/use-client.md :: 'use client' directive – React
Integrating with AI Assistants (like Cline) 🤖
The generated Markdown files and the sitemap.txt are powerful tools for providing context to AI assistants.
How it Works:
- Sitemap: The
sitemap.txtprovides a quick overview of the available documentation topics (via page titles) and their file paths. - Markdown Files: These contain the core documentation content in a token-efficient format.
Using a .clinerule:
You can instruct an AI assistant like Cline to leverage these local docs by creating a .clinerules/local_docs.md file in your project's root directory with content similar to this:
## Mirror Docs
When asked to "read in the docs for XYZ" you must read in `.mirror-docs/sitemap.txt`, then select the likely applicable paths based on the `:: <TITLE>` next to the paths. When you go to read in the relevant docs you have chosen, keep in mind those paths are relative to `.mirror-docs/markdown/`.
When asked to "pull down the docs for <url>", go ahead and run `uvx mirror-docs <url>`.
(Remember to adapt the base path in the rule if you use a custom --output-dir).
By providing this rule, you guide the AI to use the most relevant, version-specific, and token-efficient documentation available directly within your project.
Updating Documentation
Currently, updates require manually re-running the mirror_docs.py command for the specific documentation set. Future versions might include incremental update capabilities.
Memory Bank 🧠
The memory-bank/ directory contains documentation about this tool's design, implementation, and progress.
License 📜
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mirror_docs-0.1.4.tar.gz.
File metadata
- Download URL: mirror_docs-0.1.4.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bb4f64326e569467f1132ec2b4c11a9a2dad718689e3a415e876db175816fb8
|
|
| MD5 |
efb2b9c566c7e6547094644341563f81
|
|
| BLAKE2b-256 |
f46bc00c534a09a5d6598a77efbc964e29727cd92b2e344b19ba9f0a54f21b13
|
Provenance
The following attestation bundles were made for mirror_docs-0.1.4.tar.gz:
Publisher:
publish.yaml on bioshazard/mirror-docs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mirror_docs-0.1.4.tar.gz -
Subject digest:
6bb4f64326e569467f1132ec2b4c11a9a2dad718689e3a415e876db175816fb8 - Sigstore transparency entry: 200324884
- Sigstore integration time:
-
Permalink:
bioshazard/mirror-docs@10a7edccc5ab693c94e56db7e0c341dd9d1d94d3 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/bioshazard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@10a7edccc5ab693c94e56db7e0c341dd9d1d94d3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file mirror_docs-0.1.4-py3-none-any.whl.
File metadata
- Download URL: mirror_docs-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
947ad4fb3749dfb021aca86e9ee9b08f5168815de3f99794fb0ceba7773a4aba
|
|
| MD5 |
c22c2a27ee76250d17713e4e07b4321a
|
|
| BLAKE2b-256 |
be1f773e77ca9a3acdae722695ce927819ae8653cd501b660d515342b69116b2
|
Provenance
The following attestation bundles were made for mirror_docs-0.1.4-py3-none-any.whl:
Publisher:
publish.yaml on bioshazard/mirror-docs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mirror_docs-0.1.4-py3-none-any.whl -
Subject digest:
947ad4fb3749dfb021aca86e9ee9b08f5168815de3f99794fb0ceba7773a4aba - Sigstore transparency entry: 200324886
- Sigstore integration time:
-
Permalink:
bioshazard/mirror-docs@10a7edccc5ab693c94e56db7e0c341dd9d1d94d3 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/bioshazard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@10a7edccc5ab693c94e56db7e0c341dd9d1d94d3 -
Trigger Event:
release
-
Statement type: