Rhai Script Documentation Tool

The Rhai Script Documentation Tool, rhai-doc, takes a source directory and scans for Rhai script files (recursively), building a web-based documentation site for all functions defined.

Documentation is taken from MarkDown-formatted doc-comments on the functions.

Author: @semirix

Repo: on GitHub

Binary: on crates.io

Example: on rhai.rs

Install

cargo install rhai-doc

Flags and Options

Flag/OptionParameterDefaultDescription
-h, --helpprint help
-V, --versionprint version
-a, --allgenerate documentation for all functions, including private ones (default false)
-vuse multiple to set verbosity: 1=silent, 2,3 (default)=full
-c, --config<file>rhai.tomlset configuration file
-D, --dest<directory>distset destination directory for documentation output
-d, --dir<directory>current directoryset source directory for Rhai scripts
-p, --pages<directory>pagesset source directory for additional MarkDown page files to include

Commands

CommandDescriptionExample
nonegenerate documentationrhai-doc
newcreate a skeleton rhai.toml in the source directoryrhai-doc new

Configuration file

A configuration file, which is usually named rhai.toml, contains configuration options for rhai-doc and must be placed in the source directory.

A skeleton rhai.toml can be generated inside the source directory via the new command.

An alternate configuration file can be specified via the --config option.

Example

name = "My Rhai Project"                # project name
color = [246, 119, 2]                   # theme color
root = "/docs/"                         # root URL for generated site
index = "home.md"                       # this file becomes 'index.html'
icon = "logo.svg"                       # project icon
stylesheet = "my_stylesheet.css"        # custom stylesheet
code_theme = "atom-one-light"           # 'highlight.js' theme
code_lang = "ts"                        # default language for code blocks
extension = "rhai"                      # script extension
google_analytics = "G-ABCDEF1234"       # Google Analytics ID

[[links]]                               # external link for 'Blog'
name = "Blog"
link = "https://example.com/blog"

[[links]]                               # external link for 'Tools'
name = "Tools"
link = "https://example.com/tools"

Configuration Options

OptionValue typeDefaultDescription
namestringnonename of project – used as titles on documentation pages
colorRGB values (0-255) array[246, 119, 2]theme color for generated documentation
rootURL stringnoneroot URL generated as part of documentation
indexfile pathnonemain MarkDown file – becomes index.html
iconfile pathRhai iconproject icon
stylesheetfile pathnonecustom stylesheet
code_themetheme stringdefaulthighlight.js theme for syntax highlighting in code blocks
code_langlanguage stringtsdefault language for code blocks
extensionextension string.rhaiscript files extension (default .rhai)
google_analyticsID stringnoneGoogle Analytics ID
[[links]]tablenoneexternal links
namestringnone• title of external link
linkURL stringnone• URL of external link

MarkDown pages

By default, rhai-doc will generate documentation pages from a pages sub-directory under the scripts directory. The pages are assumed to be in MarkDown.

Alternatively, you can specify another location via the --pages option.