Skip to main content

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 🚀

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 .gitignore file.

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:

  1. Mirror HTML content from https://react.dev/reference into <output_dir>/html/react.dev/reference/.
  2. Convert the main content of each HTML page into Markdown files within <output_dir>/markdown/react.dev/reference/.
  3. Generate a sitemap at <output_dir>/sitemap.txt listing the Markdown files (relative to the markdown directory) 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:

  1. Sitemap: The sitemap.txt provides a quick overview of the available documentation topics (via page titles) and their file paths.
  2. 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 `uv run mirror_docs.py <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 📜

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mirror_docs-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mirror_docs-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file mirror_docs-0.1.0.tar.gz.

File metadata

  • Download URL: mirror_docs-0.1.0.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

Hashes for mirror_docs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 61d9e8aa998054b7a1ae10d644297ba516bd37432177c10f89f9da4fab8a91f5
MD5 380b8e69e1cef87f24e3677d5abc95d3
BLAKE2b-256 67c40082f3f40a6c61d1fab9876018c3155a38aae83814e758f4d1f0e6b0786b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mirror_docs-0.1.0.tar.gz:

Publisher: publish.yaml on bioshazard/mirror-docs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mirror_docs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mirror_docs-0.1.0-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

Hashes for mirror_docs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 370a0666dc29f668fdd5c22acd321c456b2c5be1348954ede746305ee9a05e71
MD5 fd507bcf544e4c7b5f34e3837c81a850
BLAKE2b-256 d8625d78e99f34e1c5a7796c78eb122c363d19f74bc015b21e9bf9e2d9c9dbcc

See more details on using hashes here.

Provenance

The following attestation bundles were made for mirror_docs-0.1.0-py3-none-any.whl:

Publisher: publish.yaml on bioshazard/mirror-docs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page