rhai-autodocs
Generate Markdown/MDX documentation from a rhai::Engine
instance.
Published with Mdbook.
Published with Docusaurus.
Features
- Export native Rust Rhai function and custom types documentation to a simple struct.
- Generate documentation as Markdown with HTML or MDX, for Mdbook and Docusaurus respectivly.
- Order functions in your docs with the
# rhai-autodocs:index:x
directive. - Split your docs in 'sections' using the
#
character in your docs that will be rendered as tabs. - Generate glossaries linking to the function definitions.
How to use
use exported_module;
use *;
// 1. Create a plugin module or any kind of Rhai API that supports documentation on functions and types.
/// My own module.
// 2. Generate the docs with autodocs. This library can be imported as a
// build dependency into your build script.
// A typical documentation generation workflow would look like this:
// Specify an environment variable that points to the directory
// where the documentation will be generated.
let docs_path = var.unwrap_or;
// Create a new engine and register all modules that need to have documentation generated
// for them. In this example, the module defined in the previous code block is registered
// into the engine, but you could register other functions and types ...
let mut engine = new;
engine.register_static_module;
/// Export the documentation as a [`ModuleDocumentation`]. You could stop here and generate
/// you own docs from this structure.
let docs = options
.include_standard_packages
.export
.expect;
/// Or you could use pre-defined templates for docusaurus or mdbook.
/// Here, documentation is generated for docusaurus with some options.
let mdx = docusaurus
.with_slug
.generate
.expect;
/// Iterate over the generated documentation for every modules.
for in mdx
For more details, check out the examples folder.
Generating your own documentation
You can pretty much use any templating system to generate documentation. However, this repository already generates documents based on handlebars with the handlebars-rust crate for docusaurus and mdbook. You can check the template folder to get inspired.