gdnative-doc

Crates.iogdnative-doc
lib.rsgdnative-doc
version0.0.6
sourcesrc
created_at2021-01-29 10:41:09.931249
updated_at2022-10-14 16:44:43.020293
descriptionDocumentation tool for gdnative
homepage
repositoryhttps://github.com/arnaudgolfouse/gdnative-doc-rs/
max_upload_size
id347979
size190,059
Arnaud Golfouse (arnaudgolfouse)

documentation

README

gdnative-doc

MIT license Latest Version Docs Status

This is a documentation tool for godot-rust projects.

WARNING: very unstable at the moment.

The goal of this tool is to automate writing documentation in Rust code that will be used in gdscript.

Features

  • Keep the documentation synchronized with your code.
  • Generate readable and easy to change markdown
  • Build table of contents automatically.
  • Automatic linking to the godot documentation.
  • Generate gut tests from gdscript examples.

Example

An example: process function

  • Input: Rust

    /// Process the given [`String`], returning [`FAILED`] on error.
    ///
    /// # Example
    /// ```gdscript
    /// var processor = Myprocessor.new()
    /// assert_eq(processor.process("hello"), OK)
    /// ```
    #[method]
    pub fn process(&mut self, _: &Node, s: GodotString) -> i32 { /* ... */ }
    
  • Output: Markdown

    ### <a id="func-process"></a>func process(s: [String]) -> [int]
    
    Process the given [`String`], returning [`FAILED`] on error.
    
    #### Example
    
    ```gdscript
    var processor = Myprocessor.new()
    assert_eq(processor.process("hello"), OK)
    ```
    
    [string]: https://docs.godotengine.org/en/stable/classes/class_string.html
    [`string`]: https://docs.godotengine.org/en/stable/classes/class_string.html
    [int]: https://docs.godotengine.org/en/stable/classes/class_int.html
    [`failed`]: https://docs.godotengine.org/en/stable/classes/class_@globalscope.html#enum-globalscope-error
    
  • Output: Gut

    func test_process():
        var processor = Myprocessor.new()
        assert_eq(processor.process("hello"), OK)
    

A more complete example can be found in the examples/dijkstra-map-gd directory.

Usage

This is meant to be used as a build script: Set

[build-dependencies]
gdnative-doc = "*"

In your Cargo.toml. Then you can drive the process with the Builder structure:

// in build.rs
use gdnative_doc::{backend::BuiltinBackend, init_logger, Builder, LevelFilter};
use std::path::PathBuf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    init_logger(LevelFilter::Info)?;
    Builder::new()
        .add_backend(BuiltinBackend::Markdown, PathBuf::from("doc/markdown"))
        .build()?;
    Ok(())
}

More informations can be found in the documentation.

The format of the configuration file can be found here.

You can also use the command-line tool.

Godot version

Supported godot versions are 3.2, 3.3, 3.4 and 3.5. By default, 3.5 will be selected. To select another version, use the godot_version field of the configuration file.

Limitations

At the moment, syn is used to parse rust and search for the struct and impls. This is not optimal however and might sometime mess up link resolution. rust-analyzer libraries will probably be used in the future to avoid this.

Commit count: 121

cargo fmt