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 sphinx-llm
# For extensions that use LLMs to generate text
pip install sphinx-llm[gen]
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:
- Find all HTML files generated in the output directory
- Convert each HTML file to markdown format
- Save the markdown files with the same name plus an extra
.mdextension - Concatenates all generated markdown into a single
llms-full.txtfile
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
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 sphinx_llm-0.1.1.tar.gz.
File metadata
- Download URL: sphinx_llm-0.1.1.tar.gz
- Upload date:
- Size: 252.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bff0b4650e9a80b2a27223b3b5b155a5e631c300d4fb6dcef1522168ac590a82
|
|
| MD5 |
ac88153cecd96c1265f892b1ecdad032
|
|
| BLAKE2b-256 |
9786644fc46ddc1721b93e7ac58e86b67a592ebfffae4b9a0939c115d56c44d3
|
File details
Details for the file sphinx_llm-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sphinx_llm-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6600289bd693913622ff2ca808020648ccc7786816cbb5db722765b34a7f2661
|
|
| MD5 |
fe30d6fc15da325d433ac5ba8ef9ecae
|
|
| BLAKE2b-256 |
96d5534e6a131aa5e3b6faccef3c7e5f7c64fb46bcfc114b7c76215210bc3fcb
|