Skip to content

feat(lad): export global functions in lad exported plugin & add collapsible sections to pre-processor #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/lad_backends/mdbook_lad_preprocessor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("[");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions crates/lad_backends/mdbook_lad_preprocessor/src/sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions crates/ladfile_builder/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 4 additions & 0 deletions docs/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Loading