Skip to main content

No project description provided

Project description

sphinx-llm

[!WARNING]
This repo is experimental. Use at your own risk!

The sphinx-llm package includes extensions for working with LLMs.

There are two categories of tools in this package.

One is extensions for leveraging LLMs as part of the Sphinx build process. This is useful for generating content that gets baked into the documentation. It it not intended to provide an interactive chat service in your documentation.

The other category is extensions for making your documentation easier for consumption by LLMs. This is useful when you want your project to be well indexed and represented in LLMs when users ask about projects in your domain.

Installation

pip install git+https://github.com/jacobtomlinson/sphinx-llm.git

Extensions

llms.txt Support

The llms.txt standard describes how you can provide documentation in a way that can be easily consumed by LLMs, either during model training or at inference time when using tools that search the web.

The standard describes that your documentation sitemap should be provided in markdown in llms.txt and then the entire documentation should be provided in markdown via a single file called llms-full.txt. Additionally each individual page on your website should also have a markdown version of the page at the same URL with an additional .md extension.

The sphinx_llm.txt extension automatically generates markdown files alongside HTML files during the Sphinx build process.

To use the extension add it to your conf.py:

# conf.py
# ...

extensions = [
    "sphinx_llm.txt",
]

When you build your documentation with sphinx-build (or make html), the extension will:

  1. Find all HTML files generated in the output directory
  2. Convert each HTML file to markdown format
  3. Save the markdown files with the same name plus an extra .md extension
  4. Concatenates all generated markdown into a single llms-full.txt file

For example, if your build generates:

  • _build/html/index.html
  • _build/html/apples.html

The extension will also create:

  • _build/html/index.html.md
  • _build/html/apples.html.md
  • _build/html/llms-full.txt

Note: This extension only works with HTML builders (like html and dirhtml).

Docref

To use this extension you need to have ollama running.

If you have a GPU then generation will be much faster, but it is optional. See the GitHub Actions for an example of using it in CI.

The sphinx_llm.docref extension adds a directive for summarising and referencing other pages in your documentation. Instead of just linking to a page the extension will generate a summary of the page being linked to and include that too.

To use the extension add it to your conf.py.

# conf.py
# ...

extensions = [
    "sphinx_llm.docref",
]

Then use the docref directive in your documents to reference other documents.

Testing page
============


.. docref:: apples
   
   Summary of apples page.

Then when you run sphinx-build (or make html) a summary will be generated and your source file will be updated too.

Testing page
============


.. docref:: apples
   :hash: 31ec12a54205539af3cde39b254ec766
   :model: llama3.2:3b
   
   Feeding apples to a friendly pig involves selecting ripe, pesticide-free apples, washing them thoroughly, cutting into manageable pieces, introducing them calmly, monitoring the pig's reaction, and cleaning up afterwards.

A hash of the referenced document is included to avoid generating summaries unnecessarily. But if the referenced page changes the summary will be regenerated.

You can also modify the summary if you need to clean up the language generated, and as long as the hash still matches the file it will be used.

Building the docs

Try it out yourself by building the example documentation.

uv run --dev sphinx-autobuild docs/source docs/build/html

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

sphinx_llm-0.1.0.tar.gz (252.2 kB view details)

Uploaded Source

Built Distribution

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

sphinx_llm-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sphinx_llm-0.1.0.tar.gz
  • Upload date:
  • Size: 252.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.7

File hashes

Hashes for sphinx_llm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 81082edbe31fe7194842e94796fa5c75c4dce66e6127fd713a3eaa497c56a16b
MD5 23d9a91c6eb2e08015ff680146ceb517
BLAKE2b-256 02ea3ac18558a1779fef5fad65cf5052f41037c3242d4e8f06b0c89cbf9066d3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sphinx_llm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.7

File hashes

Hashes for sphinx_llm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f609aef5bb80ecf750c7fc3a07c0a3d6b949dc441537a46fffe9a798d3d56408
MD5 89d712007edb4bb3eeb9d6d56c3a8e02
BLAKE2b-256 36e04238c97178d9b74b9962ad65e1398a88ee09fbd27129a664d4ccdf1e9ba8

See more details on using hashes here.

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