Skip to content
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

Add hotfix to deal with duplicate fields in teal #52

Merged
merged 1 commit into from
May 8, 2023
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
2 changes: 1 addition & 1 deletion languages/bevy_mod_scripting_lua/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ path="src/lib.rs"
[dependencies]
bevy= { version = "0.10.1", default-features = false}
bevy_mod_scripting_core = {path="../../bevy_mod_scripting_core", version = "0.2.2" }
tealr = { version = "=0.9.0-alpha4", git = "https://github.com/awestlake87/tealr", rev = "120ab2da424fbfaaf1a96f77c60072707399a4ba", features=["mlua_vendored","mlua_send"]}
tealr = { version = "=0.9.0-alpha4", features=["mlua_vendored","mlua_send"]}
parking_lot = "0.12.1"
serde_json = "1.0.81"
serde = { version = "1", features = ["derive"] }
Expand Down
11 changes: 9 additions & 2 deletions languages/bevy_mod_scripting_lua/src/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
};

use bevy::asset::FileAssetIo;
use tealr::TypeWalker;
use tealr::{TypeGenerator, TypeWalker};

use bevy_mod_scripting_core::prelude::*;

Expand Down Expand Up @@ -86,11 +86,18 @@ impl DocFragment for LuaDocFragment {
let docs_name = self.name().to_owned();

// build the type walker
let tw = self
let mut tw = self
.walker
.into_iter()
.fold(TypeWalker::new(), |a, v| (v.builder)(a));

// fixes bug in tealr which causes syntax errors in teal due to duplicate fields (from having both getters and setters)
tw.given_types.iter_mut().for_each(|tg| {
if let TypeGenerator::Record(rg) = tg {
rg.fields.dedup_by(|a, b| a.name == b.name);
}
});

// generate json file
let json = serde_json::to_string_pretty(&tw)
.map_err(|e| ScriptError::DocGenError(e.to_string()))?;
Expand Down