Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tool to auto-generate documentation for Rhai source code.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.txt
MIT
LICENSE-MIT.txt
NotificationsYou must be signed in to change notification settings

rhaiscript/rhai-doc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Licensecrates.iocrates.io

rhai-doc is a tool for auto-generating documentation forRhai scripts.

It supports writingMarkDown documentation indoc-comments ofRhai scripts and creatinggeneral-purpose documentation pages.

See an examplehere.

CLI Interface

USAGE:    rhai-doc.exe [OPTIONS] [SUBCOMMAND]OPTIONS:    -a, --all              Generate documentation for all functions, including private ones    -c, --config <FILE>    Set the configuration file [default: rhai.toml]    -d, --dir <DIR>        Set the Rhai scripts (*.rhai) directory [default: .]    -D, --dest <DIR>       Set the destination for the documentation output [default: dist]    -h, --help             Print help information    -p, --pages <DIR>      Set the directory where MarkDown (*.md) pages files are located [default:                           pages]    -v, --verbose          Use multiple to set the level of verbosity: 1 = silent, 2 (default) =                           full, 3 = debug    -V, --version          Print version informationSUBCOMMANDS:    help    Print this message or the help of the given subcommand(s)    new     Generates a new configuration file

Installation

Install fromcrates.io

cargo install rhai-doc

Install from source

cargo install --path.

Configuration File

To get started, you need a configuration file.

It is usually namedrhai.toml, or you can specify one via the--config option.

To generate a skeletonrhai.toml, use thenew command:

rhai-doc new

Example

version ="1.0"# version of this TOML filename ="My Rhai Project"# project namecolor = [246,119,2]# theme colorroot ="/docs/"# root URL for generated siteindex ="home.md"# this file becomes 'index.html`icon ="logo.svg"# project iconstylesheet ="my_stylesheet.css"# custom stylesheetcode_theme ="atom-one-light"# 'highlight.js' themecode_lang ="ts"# default language for code blocksextension ="rhai"# script extensiongoogle_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

  • version: Version of this TOML file;1.0 is the current version.
  • name: The name of the project, if any. It's the title that shows up on the documentation pages.
  • color: RGB values of the theme color for the generated docs, if any.
  • root: The root URL generated as part of the documentation, if any.
  • index: The mainMarkDown file, if any, that will becomeindex.html.
  • icon: The location of a custom icon file, if any.
  • stylesheet: The location of a custom stylesheet, if any.
  • code_theme: Thehighlight.js theme for syntax highlighting in code blocks (defaultdefault).
  • code_lang: Default language for code blocks (defaultts).
  • extension: The extension of the script filesrhai-doc will look for (default.rhai).
  • google_analytics: Google Analytics ID, if any.
  • [[links]]: External links, if any, to other sites of relevance.
    • name: Title of external link.
    • link: URL of external link.

Doc-Comments

Rhai supportsdoc-comments inMarkDown format on script-definedfunctions.

/// This function calculates a **secret number**!////// Formula provided from this [link](https://secret_formula.com/calc_secret_number).////// # Scale Factor/// Uses a scale factor obtained by calling [`get_contribution_factor`].////// # Parameters/// `seed` - random seed to start the calculation////// # Returns/// The secret number!////// # Exceptions/// Throws when the seed is not positive.////// # Example/// ```/// let secret = calc_secret_number(42);/// ```fncalc_secret_number(seed){if seed <=0{        throw"the seed must be positive!";}let factor =get_contribution_factor(seed);// Some very complex code skipped ...// ...}/// This function is private and will not be included/// unless the `-a` flag is used.privatefnget_multiply_factor(){42}/// This function calculates a scale factor for use/// in the [`calc_secret_number`] function.fnget_contribution_factor(x){    x*get_multiply_factor()}

Syntax Highlighting

highlight.js is used for syntax highlighting in code blocks.

The default language for code blocks ists (i.e. TypeScript). This default is chosen because Rhaisyntax mostly resembles JavaScript/TypeScript, and highlighting works properly for strings interpolation.

Inter-Script Links

Functions documentation can cross-link to each other within the same script file.

A link in the format[`my_func`] is automatically expanded to link to the documentation ofthe target function (in this casemy_func).

MarkDown Pages

By default,rhai-doc will generate documentation pages fromMarkDown documents within apages sub-directory under the scripts directory.

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

Features

  • Generate documentation fromMarkDowndoc-comments inRhai script files.
  • Create general-purpose documentation pages.
  • Text search.
  • Linter for undocumented functions, parameters, etc.

License

Licensed under either of the following, at your choice:

Unless explicitly stated otherwise, any contribution intentionally submittedfor inclusion in this crate, as defined in the Apache-2.0 license,shall be dual-licensed as above, without any additional terms or conditions.

About

Tool to auto-generate documentation for Rhai source code.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.txt
MIT
LICENSE-MIT.txt

Stars

Watchers

Forks

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp