diff --git a/crates/lad_backends/mdbook_lad_preprocessor/Cargo.toml b/crates/lad_backends/mdbook_lad_preprocessor/Cargo.toml index 28b9904d1a..88c0d2f88c 100644 --- a/crates/lad_backends/mdbook_lad_preprocessor/Cargo.toml +++ b/crates/lad_backends/mdbook_lad_preprocessor/Cargo.toml @@ -19,6 +19,7 @@ ladfile = { path = "../../ladfile", version = "0.3.1" } env_logger = "0.11" log = "0.4" serde_json = "1.0" +regex = "1.11" [dev-dependencies] assert_cmd = "2.0" diff --git a/crates/lad_backends/mdbook_lad_preprocessor/src/argument_visitor.rs b/crates/lad_backends/mdbook_lad_preprocessor/src/argument_visitor.rs index c86cfd2b5c..575ac7cd10 100644 --- a/crates/lad_backends/mdbook_lad_preprocessor/src/argument_visitor.rs +++ b/crates/lad_backends/mdbook_lad_preprocessor/src/argument_visitor.rs @@ -74,6 +74,16 @@ impl ArgumentVisitor for MarkdownArgumentVisitor<'_> { self.buffer.text(")"); } + fn walk_union(&mut self, inner: &[ladfile::LadArgumentKind]) { + // Write `T1 | T2` + for (idx, arg) in inner.iter().enumerate() { + self.visit(arg); + if idx < inner.len() - 1 { + self.buffer.text(" | "); + } + } + } + fn walk_array(&mut self, inner: &ladfile::LadArgumentKind, size: usize) { // Write [inner; size] self.buffer.text("["); diff --git a/crates/lad_backends/mdbook_lad_preprocessor/src/markdown.rs b/crates/lad_backends/mdbook_lad_preprocessor/src/markdown.rs index 51c099cb5f..4f0847af42 100644 --- a/crates/lad_backends/mdbook_lad_preprocessor/src/markdown.rs +++ b/crates/lad_backends/mdbook_lad_preprocessor/src/markdown.rs @@ -155,7 +155,7 @@ impl IntoMarkdown for Markdown { let clamped_level = level.clamp(&1, &6); let hashes = "#".repeat(*clamped_level as usize); // Escape the text for Markdown - builder.append(&format!("{} {}", hashes, text)); + builder.append(&format!("{hashes} {text}")); } Markdown::Paragraph { text, diff --git a/crates/lad_backends/mdbook_lad_preprocessor/src/sections.rs b/crates/lad_backends/mdbook_lad_preprocessor/src/sections.rs index 3843518c2d..f2484c9b34 100644 --- a/crates/lad_backends/mdbook_lad_preprocessor/src/sections.rs +++ b/crates/lad_backends/mdbook_lad_preprocessor/src/sections.rs @@ -116,9 +116,9 @@ impl<'a> Section<'a> { match self { Section::Summary { ladfile, .. } => { vec![ - Section::TypeSummary { ladfile }, - Section::FunctionSummary { ladfile }, Section::InstancesSummary { ladfile }, + Section::FunctionSummary { ladfile }, + Section::TypeSummary { ladfile }, ] } Section::TypeSummary { ladfile } => ladfile diff --git a/crates/ladfile_builder/src/plugin.rs b/crates/ladfile_builder/src/plugin.rs index fa93a64b9c..58e132a414 100644 --- a/crates/ladfile_builder/src/plugin.rs +++ b/crates/ladfile_builder/src/plugin.rs @@ -87,6 +87,11 @@ fn generate_lad_file( } } + // find functions on the global namespace + for (_, function) in function_registry.iter_namespace(Namespace::Global) { + builder.add_function_info(function.info.clone()); + } + let file = builder.build(); let mut path = PathBuf::from("assets"); diff --git a/docs/book.toml b/docs/book.toml index bace71420b..b347b4786a 100644 --- a/docs/book.toml +++ b/docs/book.toml @@ -11,4 +11,8 @@ additional-js = ["multi-code-block.js"] git-repository-url = "https://github.com/makspll/bevy_mod_scripting" edit-url-template = "https://github.com/makspll/bevy_mod_scripting/edit/main/docs/{path}" +[output.html.fold] +enable = true +level = 1 + [preprocessor.lad-preprocessor]