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

Demo Gen Backend Customization #618

Merged
merged 23 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2b486dd
Correcting lowering errors with ICU4X
ambiguousname Aug 1, 2024
4c0c7ed
Starting on demo generation configuration options
ambiguousname Aug 1, 2024
d85e894
Starting to set up config options
ambiguousname Aug 1, 2024
c9463ec
Updating thoughts
ambiguousname Aug 1, 2024
a860131
Set JS relative import config
ambiguousname Aug 2, 2024
51d279a
Adding explicit generation option
ambiguousname Aug 2, 2024
6a79f59
Adding hide default renderer option
ambiguousname Aug 2, 2024
bd287ba
Fix kebab case bug
ambiguousname Aug 2, 2024
a0dd0dc
Separate out config.mjs to only generate if JS is elsewhere
ambiguousname Aug 2, 2024
31856c5
Adding module import statement
ambiguousname Aug 2, 2024
ee5b883
Updating generation
ambiguousname Aug 2, 2024
3e10052
Disable generation for some config options
ambiguousname Aug 2, 2024
2dbf38f
Fixing bug with lib changing locations
ambiguousname Aug 2, 2024
568c5c6
Moving rendering files around for better structure
ambiguousname Aug 5, 2024
cc774ee
Rewriting html output to be single file
ambiguousname Aug 5, 2024
e1114df
Simplifying customization options
ambiguousname Aug 5, 2024
1d80683
Add error detection
ambiguousname Aug 5, 2024
4063f30
Console.error instead of throwing
ambiguousname Aug 5, 2024
cbc0cb3
Formatting
ambiguousname Aug 5, 2024
c1b07b3
Updated generation
ambiguousname Aug 5, 2024
9d9edc5
Clippy fixes
ambiguousname Aug 5, 2024
0d211a2
Renaming "enabled" to "generate" in snapshots
ambiguousname Aug 5, 2024
5b763d6
Clippy fix
ambiguousname Aug 5, 2024
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
12 changes: 4 additions & 8 deletions core/src/hir/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ pub struct DemoInputCFG {
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
pub struct DemoInfo {
/// `#[diplomat::demo(enable)]`. If automatic generation is disabled by default (TODO: Right now there is no such option), then the below render terminus will be allowed to generate.
/// `#[diplomat::demo(disable)]`. If automatic generations is enabled by default, the below render terminus will not be allowed to generate.
/// TODO: If demo generation is its own separate backend, this serves no real purpose, since [`Attrs::disable`] already handles this for us.
pub enabled: bool,
/// `#[diplomat::demo(generate)]`. If automatic generation is disabled by default (see [`diplomat_tool::demo_gen::DemoConfig`]), then the below render terminus will be allowed to generate.
pub generate: bool,

/// `#[diplomat::demo(default_constructor)]`
/// We search for any methods specially tagged with `Constructor`, but if there's are no default Constructors and there's NamedConstructor that you want to be default instead, use this.
Expand Down Expand Up @@ -359,10 +357,8 @@ impl Attrs {
this.demo_attrs.external = true;
} else if path_ident == "default_constructor" {
this.demo_attrs.default_constructor = true;
} else if path_ident == "enable" {
this.demo_attrs.enabled = true;
} else if path_ident == "disable" {
this.demo_attrs.enabled = false;
} else if path_ident == "generate" {
this.demo_attrs.generate = true;
} else if path_ident == "input" {
// TODO: Move this to AST.
let meta_list = attr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Method {
},
special_method: None,
demo_attrs: DemoInfo {
enabled: false,
generate: false,
default_constructor: false,
external: false,
input_cfg: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ TypeContext {
},
special_method: None,
demo_attrs: DemoInfo {
enabled: false,
generate: false,
default_constructor: false,
external: false,
input_cfg: {},
Expand All @@ -127,7 +127,7 @@ TypeContext {
},
special_method: None,
demo_attrs: DemoInfo {
enabled: false,
generate: false,
default_constructor: false,
external: false,
input_cfg: {},
Expand Down Expand Up @@ -260,7 +260,7 @@ TypeContext {
},
special_method: None,
demo_attrs: DemoInfo {
enabled: false,
generate: false,
default_constructor: false,
external: false,
input_cfg: {},
Expand All @@ -279,7 +279,7 @@ TypeContext {
},
special_method: None,
demo_attrs: DemoInfo {
enabled: false,
generate: false,
default_constructor: false,
external: false,
input_cfg: {},
Expand Down Expand Up @@ -321,7 +321,7 @@ TypeContext {
},
special_method: None,
demo_attrs: DemoInfo {
enabled: false,
generate: false,
default_constructor: false,
external: false,
input_cfg: {},
Expand Down
2 changes: 1 addition & 1 deletion example/demo_gen/demo/FixedDecimal.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/demo_gen/demo/FixedDecimal.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions example/demo_gen/demo/FixedDecimalFormatter.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions example/demo_gen/demo/FixedDecimalFormatter.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions example/demo_gen/demo/index.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

12 changes: 0 additions & 12 deletions example/demo_gen/demo/rendering/FixedDecimal_toString.html

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions example/demo_gen/demo/rendering/runtime.mjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions example/demo_gen/demo/runtime.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion example/demo_gen/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { RenderInfo } from "./demo/index.mjs";

Object.values(RenderInfo.termini).forEach((t) => {
let a = document.createElement("li");
a.innerHTML = `<a href="demo/${t.html}">${t.funcName}</a>`;
a.innerHTML = `<a href="demo/rendering/template.html?func=${t.funcName}">${t.funcName}</a>`;
document.getElementById("links").appendChild(a);
});
Loading
Loading