Repository navigation
v.0.19.8
This version makes it easier to generate documentation for a Rhai code base.
Each function defined in an AST can optionally attach doc-comments (which, as in Rust,
are comments prefixed by either /// or /**). Doc-comments allow third-party tools to
automatically generate documentation for functions defined in a Rhai script.
A new API, Engine::gen_fn_metadata_to_json and Engine::gen_fn_metadata_with_ast_to_json,
paired with the new metadata feature, exports the full list of functions metadata
(including those in an AST) as a JSON document.
There are also a sizable number of bug fixes.
Version 0.19.8 released to crates.io.
Bug fixes
- Unary prefix operators
-,+and!now bind correctly when applied to an expression. Previously,-x.lenis parsed as(-x).lenwhich is obviously counter-intuitive. - Indexing of namespace-qualified variables now work properly, such as
path::to::var[x]. - Constants are no longer propagated by the optimizer if shadowed by a non-constant variable.
- A constant passed as the
thisparameter to Rhai functions now throws an error if assigned to. - Generic type parameter of
Engine::register_iteratorisIntoIteratorinstead ofIterator. - Fixes parsing of block comments ending with
**/or inner blocks starting with//*.
Breaking changes
Engine::on_progressnow takesu64instead of&u64.- The closure for
Engine::on_debugnow takes two additional parameters:source: Option<&str>andpos: Position. AST::iter_functionsnow returnsScriptFnMetadata.- The parser function passed to
Engine::register_custom_syntax_rawnow takes an additional parameter containing the look-ahead symbol.
New features
AST::iter_functionsnow returnsScriptFnMetadatawhich includes, among others, doc-comments for functions prefixed by///or/**.- Doc-comments can be enabled/disabled with the new
Engine::set_doc_commentsmethod. - A new feature
metadatais added that pulls inserde_jsonand enablesEngine::gen_fn_metadata_to_jsonandEngine::gen_fn_metadata_with_ast_to_jsonwhich exports the full list of functions metadata (including those inside anAST) in JSON format. Engine::on_debugprovides two additional parameters:source: Option<&str>andpos: Position, containing the current source (if any) and position of thedebugstatement.NativeCallContextandEvalContextboth exposesource()which returns the current source, if any.
Enhancements
- A functions lookup cache is added to make function call resolution faster.
- Capturing a constant variable in a closure is now supported, with no cloning.
- A look-ahead symbol is provided to custom syntax parsers, which can be used to parse variable-length symbol streams.