Rust documentation helper that helps a Rust crate developer generate a file
llms.txt
that helps provide context to large language models (LLMs).
Thanks to excellent work by the Rust team, rustdoc team, and rustdoc-md team.
Install:
cargo install rustdoc-llms
Use the tool when you're working on a crate and you want to document it:
The tool creates two files:
-
target/doc/foo_bar.json
(this uses your own crate naming convention) -
target/doc/llms.txt
(this is a markdown file created by rustdoc-md)
If you like, you can copy these files to the top level of your repository, which can make the files easier to find for search engines and AI systems:
cp target/doc/foo_bar.json llms.json
cp target/doc/llms.txt llms.txt
This Rust crate is deliberately small and simple. The purpose is to make it
slightly-easier to generate llms
based on what's currently easy and available
for Rust crate developers.
Currently this tool calls existing command line interfaces, using cargo
and
rustdoc-md
with specialized compiler flags. If this tool is useful in
practice, then I intend to iterate to add command line arguments, options,
tests, and the like.
Pull requests are welcome. Issues are welcome.
If you want to help in other ways, or provide constructive criticism, or ask questions directly, then please feel free to contact me. I'm Joel Parker Henderson and my email is joel@joelparkerhenderson.com.
This implements the help description here.
Step 1: Generate JSON documentation:
RUSTC_BOOTSTRAP=1 RUSTDOCFLAGS="-Z unstable-options --output-format json" cargo doc --no-deps
Step 2: Convert from JSON into Markdown:
rustdoc-md --path target/doc/foo_bar.json --output target/doc/foo_bar.md
Step 3: Copy from Markdown file into LLMs file:
cp target/doc/foo_bar.json llms.json
cp target/doc/foo_bar.md llms.txt