#scripting #scripting-engine #scripting-language #documentation

rhai-autodocs

Custom documentation generator for the Rhai scripting language

17 unstable releases (3 breaking)

0.4.3 Feb 5, 2024
0.4.1 Nov 1, 2023
0.1.7 May 3, 2023
0.1.6 Mar 23, 2023

#367 in Development tools

Download history 184/week @ 2023-11-03 163/week @ 2023-11-10 245/week @ 2023-11-17 239/week @ 2023-11-24 458/week @ 2023-12-01 247/week @ 2023-12-08 166/week @ 2023-12-15 102/week @ 2023-12-22 183/week @ 2023-12-29 105/week @ 2024-01-05 93/week @ 2024-01-12 132/week @ 2024-01-19 211/week @ 2024-01-26 191/week @ 2024-02-02 171/week @ 2024-02-09 434/week @ 2024-02-16

1,014 downloads per month
Used in 3 crates

MIT license

51KB
1K SLoC

rhai-autodocs

Generate Markdown/MDX documentation from a rhai::Engine instance.

Published with Mdbook. generated documentation for mdbook Published with Docusaurus. generated documentation for docusaurus

Features

  • Output Rhai documentation as Markdown w/ HTML and Docusaurus MDX.
  • Function ordering.
  • Rust docs 'sections' format with default Markdown format or displayed using tabs.

How to use

This library can be imported as a build dependency into your build script. A typical documentation generation would look like this:

// -- 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 ...

        let docs = rhai_autodocs::options()
            .include_standard_packages(false)
            .generate(&engine)
            .expect("failed to generate documentation");

        // Write the documentation in a file, or output to stdout, etc.
    }
}

You need to import the styles/default.css file and src/tabs.js script for everything to work correctly using the mdbook generation. (You can of course override the styles and javascript code if you wish)

For more details, see the examples.

Dependencies

~5MB
~95K SLoC