Open jonathanstrong opened 2 years ago
I have thought of this before and wanted essentially the same thing.
However, rhai-doc
is written to really read script files and recurse into directories to search for script files.
All the mechanisms are already there: You can easily get a JSON file of all the registered functions in one single call.
https://rhai.rs/book/engine/metadata/export_to_json.html
All you need to do is a templating system (e.g. handlebars) that takes this JSON file and generates documentation pages.
In fact, you'd probably want to first use a templating system to generate a MarkDown file containing the functions plus doc-comments (in MarkDown), then convert that MarkDown into HTML.
cool - I will have a look! thanks.
It seems like you can use a static site generator which supports JSON sources to automatically generate documentation pages.
Something like Hugo: https://gohugo.io/templates/data-templates/
Or, it probably won't be difficult to write your own using handlebars
as the templating engine and pulldown-cmark
as the MarkDown renderer, which is what rhai-doc
does.
@schungx This is probably something that should be supported but this currently only parses .rhai
files. Adding this functionality would require parsing Rust code. An immediate solution I can think of would be to attach a macro (or leverage an existing one) to generate an output file that rhai-doc
can parse and add to the docs.
There is already a way to generate similar documentation on native Rust functions into a JSON format.
It would be more in-depth than the current Rhai functions because you have to deal with parameter types, return types and &mut
etc.
Nevertheless, the logic is similar to rhai-doc
. It probably only requires a different template.
I don't think this is possible with rhai-doc as is but wanted to double check. in my case I have a fairly large api of registered rust types/functions that I would love to generate docs for.