From b7d5b0fec4e3b4c0b1caf00176724701faa96d26 Mon Sep 17 00:00:00 2001 From: Vladimir Motylenko Date: Sun, 28 Jul 2024 14:20:19 +0300 Subject: [PATCH] Refactor workspace move rstml to separate folder. Use workspace version of dependencies whenever is possible. --- .github/workflows/bench.yml | 13 +++-- CHANGELOG.md | 60 +++++++++++++++++++- Cargo.toml | 45 +++++---------- examples/html-to-string-macro/Cargo.toml | 33 ++++++----- rstml-control-flow/Cargo.toml | 22 ++++--- rstml/Cargo.toml | 43 ++++++++++++++ {benches => rstml/benches}/bench.rs | 0 build.rs => rstml/build.rs | 0 {src => rstml/src}/config.rs | 0 {src => rstml/src}/error.rs | 0 {src => rstml/src}/lib.rs | 0 {src => rstml/src}/node/atoms.rs | 0 {src => rstml/src}/node/attribute.rs | 0 {src => rstml/src}/node/mod.rs | 0 {src => rstml/src}/node/node_name.rs | 0 {src => rstml/src}/node/node_value.rs | 0 {src => rstml/src}/node/parse.rs | 0 {src => rstml/src}/node/parser_ext.rs | 0 {src => rstml/src}/node/raw_text.rs | 0 {src => rstml/src}/parser/mod.rs | 0 {src => rstml/src}/parser/recoverable.rs | 0 {src => rstml/src}/rawtext_stable_hack.rs | 0 {src => rstml/src}/visitor.rs | 0 {tests => rstml/tests}/custom_node.rs | 0 {tests => rstml/tests}/recoverable_parser.rs | 0 {tests => rstml/tests}/test.rs | 0 26 files changed, 154 insertions(+), 62 deletions(-) create mode 100644 rstml/Cargo.toml rename {benches => rstml/benches}/bench.rs (100%) rename build.rs => rstml/build.rs (100%) rename {src => rstml/src}/config.rs (100%) rename {src => rstml/src}/error.rs (100%) rename {src => rstml/src}/lib.rs (100%) rename {src => rstml/src}/node/atoms.rs (100%) rename {src => rstml/src}/node/attribute.rs (100%) rename {src => rstml/src}/node/mod.rs (100%) rename {src => rstml/src}/node/node_name.rs (100%) rename {src => rstml/src}/node/node_value.rs (100%) rename {src => rstml/src}/node/parse.rs (100%) rename {src => rstml/src}/node/parser_ext.rs (100%) rename {src => rstml/src}/node/raw_text.rs (100%) rename {src => rstml/src}/parser/mod.rs (100%) rename {src => rstml/src}/parser/recoverable.rs (100%) rename {src => rstml/src}/rawtext_stable_hack.rs (100%) rename {src => rstml/src}/visitor.rs (100%) rename {tests => rstml/tests}/custom_node.rs (100%) rename {tests => rstml/tests}/recoverable_parser.rs (100%) rename {tests => rstml/tests}/test.rs (100%) diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index be9095a..9440000 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -9,10 +9,13 @@ jobs: steps: - uses: actions/checkout@v1 - - name: critcmp + - name: Download and install critcmp + run: cargo install critcmp + - name: Run bench on current branch + run: cargo bench -p rstml --bench bench changes + - name: Run bench on main branch run: | - cargo install critcmp - cargo bench -- --save-baseline changes git checkout main - cargo bench -- --save-baseline main - critcmp main changes + cargo bench -p rstml --bench bench main + - name: Compare the results + run: critcmp main changes diff --git a/CHANGELOG.md b/CHANGELOG.md index e581880..12f5aaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,63 @@ All notable changes to this project will be documented in this file. -## [0.11.2] - 2023-08-14 +## [0.12.0] - 2024-07-28 + +### Chore + +- Fix ci +- Fix clippy +- Add example of custom node to html-to-string-macro. +- Add eq and partial eq implementation. +- Move custom node implementation to separate crate. +- Refactor CustomNode trait +- Add readme to rstml-controll-flow +- Refine visitor api (remove clone/debug bounds) +- Add custom node visitor implementation +- Apply fmt/tests +- Refactor custom node visitor. +- Refactor code coverage script. + +### Features + +- Support for custom node +- Parsing utilities for custom nodes +- Add macro matcher +- Add visitor api. +- Implement extendable custom node + +### Fix + +- Fix imports in example +- Empty input parsing +- Make Recoverable field public. +- Fix spelling mistake "witespace" to "whitespace" +- Add unquoted text custom node integration +- Use config and diagnostc from invalid_block in attribute place. + +### Other + +- Use example from inline docs in readme +- Address review + +- Allow multiple puncts in a row in NodeName +- Added test for consecutive punctuation in NodeName + +Signed-off-by: max + +- Update README.md +- Default impl for Parser ([#51](https://github.com/rs-tml/rstml/issues/51)) + +- Initial implementation of block attributes + +- Implement braced key value attribute. See also: [#54](https://github.com/rs-tml/rstml/issues/54#issuecomment-2247924159) + +- Remove scratch + +- Rename KVAttributeValue::Braced -> KVAttributeValue::InvalidBraced + + +## [0.11.1] - 2023-08-14 ### Chore @@ -502,4 +558,4 @@ Use RecoverableContext instead. - Pub not needed - Parse blocks as NodeType::Block - \ No newline at end of file + diff --git a/Cargo.toml b/Cargo.toml index 0dd25c3..add6146 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,20 +1,24 @@ -[package] -name = "rstml" +[workspace.package] description = "Rust templating for XML-based formats (HTML, SVG, MathML) implemented on top of proc-macro::TokenStreams" -version = "0.11.2" authors = ["vldm ", "stoically "] keywords = ["syn", "jsx", "rsx", "html", "macro"] -edition = "2018" +edition = "2021" repository = "https://github.com/rs-tml/rstml" -readme = "README.md" license = "MIT" -resolver = "2" +license-file = "LICENSE" + include = ["/src", "LICENSE"] +readme = "README.md" -[lib] -bench = false +[workspace] +resolver = "2" +members = ["examples/html-to-string-macro", "rstml-control-flow"] -[dependencies] +[workspace.dependencies] +# Our packages +rstml = { version = "0.12.0", path = "rstml" } +rstml-control-flow = { version = "0.1.0", path = "rstml-control-flow" } +# external dependencies proc-macro2 = { version = "1.0.47", features = ["span-locations"] } quote = "1.0.21" syn = { version = "2.0.15", features = [ @@ -27,26 +31,7 @@ thiserror = "1.0.37" syn_derive = "0.1.6" proc-macro2-diagnostics = { version = "0.10", default-features = false } derive-where = "1.2.5" - -[dev-dependencies] -proc-macro2 = { version = "1.0.47", features = ["span-locations"] } +# dev-dependencies criterion = "0.5.1" eyre = "0.6.8" - -[[bench]] -name = "bench" -harness = false -path = "benches/bench.rs" - -[workspace] -members = ["examples/html-to-string-macro", "rstml-control-flow"] - -[features] -default = ["colors"] -# Hack that parse input two times, using `proc-macro2::fallback` to recover spaces, and persist original spans. -# It has no penalty in nightly, but in stable it parses input two times. -# In order to use this feature, one should also set `ParserConfig::macro_call_pattern`. -rawtext-stable-hack = ["rawtext-stable-hack-module"] -# Export inters of rawtext_stable_hack. It is usefull if you need support of `UnquotedText` on stable but your macro is called from other one. -rawtext-stable-hack-module = [] -colors = ["proc-macro2-diagnostics/colors"] +trybuild = "1.0" diff --git a/examples/html-to-string-macro/Cargo.toml b/examples/html-to-string-macro/Cargo.toml index 7904171..a944dd4 100644 --- a/examples/html-to-string-macro/Cargo.toml +++ b/examples/html-to-string-macro/Cargo.toml @@ -2,27 +2,26 @@ name = "rstml-to-string-macro" description = "simple html to string macro powered by rstml" version = "0.1.0" -authors = ["vldm ", "stoically "] -keywords = ["html-to-string", "html", "macro"] -edition = "2021" -repository = "https://github.com/rs-tml/rstml/tree/main/examples/html-to-string-macro" -readme = "README.md" -license = "MIT" +authors.workspace = true +keywords.workspace = true +edition.workspace = true +repository.workspace = true +readme.workspace = true +license.workspace = true +include.workspace = true [lib] proc-macro = true [dependencies] -proc-macro2 = "1.0.47" -quote = "1.0.21" -syn = "2.0.15" -syn_derive = "0.1" -rstml = { version = "0.11.0", path = "../../", features = [ - "rawtext-stable-hack", -] } -proc-macro2-diagnostics = "0.10" -derive-where = "1.2.5" -rstml-control-flow = { version = "0.1.0", path = "../../rstml-control-flow" } +proc-macro2.workspace = true +quote.workspace = true +syn.workspace = true +syn_derive.workspace = true +rstml = { workspace = true, features = ["rawtext-stable-hack"] } +proc-macro2-diagnostics.workspace = true +derive-where.workspace = true +rstml-control-flow.workspace = true [dev-dependencies] -trybuild = "1.0" +trybuild.workspace = true diff --git a/rstml-control-flow/Cargo.toml b/rstml-control-flow/Cargo.toml index f1d7bad..0ccd4e7 100644 --- a/rstml-control-flow/Cargo.toml +++ b/rstml-control-flow/Cargo.toml @@ -1,18 +1,24 @@ [package] name = "rstml-control-flow" version = "0.1.0" -edition = "2021" +edition.workspace = true +authors.workspace = true +keywords.workspace = true +repository.workspace = true +readme.workspace = true +license.workspace = true +include.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -proc-macro2 = "1.0.47" -quote = "1.0.21" -syn = "2.0.15" -syn_derive = "0.1" -rstml = { version = "0.11.0", path = "../", features = ["rawtext-stable-hack"] } -proc-macro2-diagnostics = "0.10" -derive-where = "1.2.5" +proc-macro2.workspace = true +quote.workspace = true +syn.workspace = true +syn_derive.workspace = true +proc-macro2-diagnostics.workspace = true +derive-where.workspace = true +rstml = { workspace = true, features = ["rawtext-stable-hack"] } [features] default = [] diff --git a/rstml/Cargo.toml b/rstml/Cargo.toml new file mode 100644 index 0000000..414823b --- /dev/null +++ b/rstml/Cargo.toml @@ -0,0 +1,43 @@ +[package] +name = "rstml" +description.workspace = true +version = "0.12.0" +authors.workspace = true +keywords.workspace = true +edition.workspace = true +repository.workspace = true +readme.workspace = true +license.workspace = true +include.workspace = true +[lib] +bench = false + +[dependencies] +proc-macro2.workspace = true +quote.workspace = true +syn.workspace = true +thiserror.workspace = true +syn_derive.workspace = true +proc-macro2-diagnostics.workspace = true +derive-where.workspace = true + +[dev-dependencies] +proc-macro2 = { workspace = true, features = ["span-locations"] } +criterion.workspace = true +eyre.workspace = true + +[[bench]] +name = "bench" +harness = false +path = "benches/bench.rs" + + +[features] +default = ["colors"] +# Hack that parse input two times, using `proc-macro2::fallback` to recover spaces, and persist original spans. +# It has no penalty in nightly, but in stable it parses input two times. +# In order to use this feature, one should also set `ParserConfig::macro_call_pattern`. +rawtext-stable-hack = ["rawtext-stable-hack-module"] +# Export inters of rawtext_stable_hack. It is usefull if you need support of `UnquotedText` on stable but your macro is called from other one. +rawtext-stable-hack-module = [] +colors = ["proc-macro2-diagnostics/colors"] diff --git a/benches/bench.rs b/rstml/benches/bench.rs similarity index 100% rename from benches/bench.rs rename to rstml/benches/bench.rs diff --git a/build.rs b/rstml/build.rs similarity index 100% rename from build.rs rename to rstml/build.rs diff --git a/src/config.rs b/rstml/src/config.rs similarity index 100% rename from src/config.rs rename to rstml/src/config.rs diff --git a/src/error.rs b/rstml/src/error.rs similarity index 100% rename from src/error.rs rename to rstml/src/error.rs diff --git a/src/lib.rs b/rstml/src/lib.rs similarity index 100% rename from src/lib.rs rename to rstml/src/lib.rs diff --git a/src/node/atoms.rs b/rstml/src/node/atoms.rs similarity index 100% rename from src/node/atoms.rs rename to rstml/src/node/atoms.rs diff --git a/src/node/attribute.rs b/rstml/src/node/attribute.rs similarity index 100% rename from src/node/attribute.rs rename to rstml/src/node/attribute.rs diff --git a/src/node/mod.rs b/rstml/src/node/mod.rs similarity index 100% rename from src/node/mod.rs rename to rstml/src/node/mod.rs diff --git a/src/node/node_name.rs b/rstml/src/node/node_name.rs similarity index 100% rename from src/node/node_name.rs rename to rstml/src/node/node_name.rs diff --git a/src/node/node_value.rs b/rstml/src/node/node_value.rs similarity index 100% rename from src/node/node_value.rs rename to rstml/src/node/node_value.rs diff --git a/src/node/parse.rs b/rstml/src/node/parse.rs similarity index 100% rename from src/node/parse.rs rename to rstml/src/node/parse.rs diff --git a/src/node/parser_ext.rs b/rstml/src/node/parser_ext.rs similarity index 100% rename from src/node/parser_ext.rs rename to rstml/src/node/parser_ext.rs diff --git a/src/node/raw_text.rs b/rstml/src/node/raw_text.rs similarity index 100% rename from src/node/raw_text.rs rename to rstml/src/node/raw_text.rs diff --git a/src/parser/mod.rs b/rstml/src/parser/mod.rs similarity index 100% rename from src/parser/mod.rs rename to rstml/src/parser/mod.rs diff --git a/src/parser/recoverable.rs b/rstml/src/parser/recoverable.rs similarity index 100% rename from src/parser/recoverable.rs rename to rstml/src/parser/recoverable.rs diff --git a/src/rawtext_stable_hack.rs b/rstml/src/rawtext_stable_hack.rs similarity index 100% rename from src/rawtext_stable_hack.rs rename to rstml/src/rawtext_stable_hack.rs diff --git a/src/visitor.rs b/rstml/src/visitor.rs similarity index 100% rename from src/visitor.rs rename to rstml/src/visitor.rs diff --git a/tests/custom_node.rs b/rstml/tests/custom_node.rs similarity index 100% rename from tests/custom_node.rs rename to rstml/tests/custom_node.rs diff --git a/tests/recoverable_parser.rs b/rstml/tests/recoverable_parser.rs similarity index 100% rename from tests/recoverable_parser.rs rename to rstml/tests/recoverable_parser.rs diff --git a/tests/test.rs b/rstml/tests/test.rs similarity index 100% rename from tests/test.rs rename to rstml/tests/test.rs