rhai-autodocs
: Generate API Documentation
rhai-autodocs
helps generate API documentation, in MarkDown or MDX format, for functions
registered inside an Engine
instance.
It is typically imported as a build dependency into the build script.
The MarkDown/MDX files can then be used to create a static documentation site using generators
such as mdbook
or Docusaurus.
On
crates.io
:rhai-autodocs
On
GitHub
:rhaiscript/rhai-autodocs
Usage
Cargo.toml
:
[dev-dependencies]
rhai = "1.20.0"
rhai-autodocs = "0.4" # use rhai-autodocs crate
build.rs
:
fn main() {
// Specify an environment variable that points to the directory
// where the documentation will be generated.
if let Ok(docs_path) = std::env::var("DOCS_DIR") {
let mut engine = rhai::Engine::new();
// register custom functions and types...
// or load packages...
let docs = rhai_autodocs::options()
.include_standard_packages(false)
.generate(&engine)
.expect("failed to generate documentation");
// Write the documentation to a file etc.
}
}