Skip to content

Commit 3374206

Browse files
authored
feat(lad): export global functions in lad exported plugin & add collapsible sections to pre-processor (#334)
1 parent 852a2d9 commit 3374206

File tree

6 files changed

+23
-3
lines changed

6 files changed

+23
-3
lines changed

crates/lad_backends/mdbook_lad_preprocessor/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ ladfile = { path = "../../ladfile", version = "0.3.1" }
1919
env_logger = "0.11"
2020
log = "0.4"
2121
serde_json = "1.0"
22+
regex = "1.11"
2223

2324
[dev-dependencies]
2425
assert_cmd = "2.0"

crates/lad_backends/mdbook_lad_preprocessor/src/argument_visitor.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ impl ArgumentVisitor for MarkdownArgumentVisitor<'_> {
7474
self.buffer.text(")");
7575
}
7676

77+
fn walk_union(&mut self, inner: &[ladfile::LadArgumentKind]) {
78+
// Write `T1 | T2`
79+
for (idx, arg) in inner.iter().enumerate() {
80+
self.visit(arg);
81+
if idx < inner.len() - 1 {
82+
self.buffer.text(" | ");
83+
}
84+
}
85+
}
86+
7787
fn walk_array(&mut self, inner: &ladfile::LadArgumentKind, size: usize) {
7888
// Write [inner; size]
7989
self.buffer.text("[");

crates/lad_backends/mdbook_lad_preprocessor/src/markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ impl IntoMarkdown for Markdown {
155155
let clamped_level = level.clamp(&1, &6);
156156
let hashes = "#".repeat(*clamped_level as usize);
157157
// Escape the text for Markdown
158-
builder.append(&format!("{} {}", hashes, text));
158+
builder.append(&format!("{hashes} {text}"));
159159
}
160160
Markdown::Paragraph {
161161
text,

crates/lad_backends/mdbook_lad_preprocessor/src/sections.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ impl<'a> Section<'a> {
116116
match self {
117117
Section::Summary { ladfile, .. } => {
118118
vec![
119-
Section::TypeSummary { ladfile },
120-
Section::FunctionSummary { ladfile },
121119
Section::InstancesSummary { ladfile },
120+
Section::FunctionSummary { ladfile },
121+
Section::TypeSummary { ladfile },
122122
]
123123
}
124124
Section::TypeSummary { ladfile } => ladfile

crates/ladfile_builder/src/plugin.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ fn generate_lad_file(
8787
}
8888
}
8989

90+
// find functions on the global namespace
91+
for (_, function) in function_registry.iter_namespace(Namespace::Global) {
92+
builder.add_function_info(function.info.clone());
93+
}
94+
9095
let file = builder.build();
9196

9297
let mut path = PathBuf::from("assets");

docs/book.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ additional-js = ["multi-code-block.js"]
1111
git-repository-url = "https://github.com/makspll/bevy_mod_scripting"
1212
edit-url-template = "https://github.com/makspll/bevy_mod_scripting/edit/main/docs/{path}"
1313

14+
[output.html.fold]
15+
enable = true
16+
level = 1
17+
1418
[preprocessor.lad-preprocessor]

0 commit comments

Comments
 (0)