diff --git a/CHANGELOG.md b/CHANGELOG.md index 92546b7..63af92c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,26 +1,37 @@ + +## [v0.4.0](https://github.com/rust-sailfish/sailfish/compare/v0.3.4...v0.4.0) (2022-03-10) + +## Fix + +* Fix some issues pointing to the wrong documentation links + +##Breaking Change + +* Changed format to .TOML instead of .yaml to better match what Rust uses. + -## [v0.3.4](https://github.com/Kogia-sima/sailfish/compare/v0.3.3...v0.3.4) (2021-02-13) +## [v0.3.4](https://github.com/rust-sailfish/sailfish/compare/v0.3.3...v0.3.4) (2021-02-13) ## Fix * Update some dependencies -## [v0.3.3](https://github.com/Kogia-sima/sailfish/compare/v0.3.2...v0.3.3) (2021-04-06) +## [v0.3.3](https://github.com/rust-sailfish/sailfish/compare/v0.3.2...v0.3.3) (2021-04-06) ## Fix * Improve error message for missing semicolon in code blocks -## [v0.3.2](https://github.com/Kogia-sima/sailfish/compare/v0.3.1...v0.3.2) (2021-03-29) +## [v0.3.2](https://github.com/rust-sailfish/sailfish/compare/v0.3.1...v0.3.2) (2021-03-29) ## Fix * Avoid sable/nightly mismatch error caused by proc-macro2 crate -## [v0.3.1](https://github.com/Kogia-sima/sailfish/compare/v0.3.0...v0.3.1) (2021-01-23) +## [v0.3.1](https://github.com/rust-sailfish/sailfish/compare/v0.3.0...v0.3.1) (2021-01-23) ## New Features @@ -31,7 +42,7 @@ * Workaround for incorrect cargo fingerprints -## [v0.3.0](https://github.com/Kogia-sima/sailfish/compare/v0.2.2...v0.3.0) (2020-12-20) +## [v0.3.0](https://github.com/rust-sailfish/sailfish/compare/v0.2.2...v0.3.0) (2020-12-20) ## Breaking changes @@ -54,21 +65,21 @@ * Properly handle slices with size greater than `isize::MAX` -## [v0.2.3](https://github.com/Kogia-sima/sailfish/compare/v0.2.2...v0.2.3) (2020-11-29) +## [v0.2.3](https://github.com/rust-sailfish/sailfish/compare/v0.2.2...v0.2.3) (2020-11-29) ## Fix * Use `std::result::Result` in derive macro to allow custom Result types (#34) -## [v0.2.2](https://github.com/Kogia-sima/sailfish/compare/v0.2.1...v0.2.2) (2020-11-11) +## [v0.2.2](https://github.com/rust-sailfish/sailfish/compare/v0.2.1...v0.2.2) (2020-11-11) ## Fix * Update proc-macro2 version (#32) -## [v0.2.1](https://github.com/Kogia-sima/sailfish/compare/v0.2.0...v0.2.1) (2020-08-04) +## [v0.2.1](https://github.com/rust-sailfish/sailfish/compare/v0.2.0...v0.2.1) (2020-08-04) ### Features @@ -83,7 +94,7 @@ * Search rustfmt command along all toolchains -## [v0.2.0](https://github.com/Kogia-sima/sailfish/compare/v0.1.3...v0.2.0) (2020-07-17) +## [v0.2.0](https://github.com/rust-sailfish/sailfish/compare/v0.1.3...v0.2.0) (2020-07-17) ### Breaking Changes diff --git a/Cargo.lock b/Cargo.lock index 29988b5..476ddd2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "cfg-if" @@ -25,9 +25,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "ctor" -version = "0.1.14" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf6b25ee9ac1995c54d7adb2eff8cfffb7260bc774fb63c601ec65467f43cd9d" +checksum = "ccc0a48a9b826acdf4028595adc9db92caea352f7af011a3034acd172a52a0aa" dependencies = [ "quote", "syn", @@ -41,9 +41,9 @@ checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" [[package]] name = "filetime" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8" +checksum = "975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98" dependencies = [ "cfg-if", "libc", @@ -68,7 +68,7 @@ dependencies = [ [[package]] name = "integration-tests" -version = "0.3.4" +version = "0.4.0" dependencies = [ "pretty_assertions", "sailfish", @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.5" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "itoap" @@ -90,35 +90,29 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9028f49264629065d057f340a86acb84867925865f73bbf8d47b4d149a7e88b8" -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" -version = "0.2.82" +version = "0.2.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929" - -[[package]] -name = "linked-hash-map" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dd5a6d5999d9907cda8ed67bbd137d3af8085216c2ac62de5be860bd41f304a" +checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" [[package]] name = "memchr" -version = "2.3.3" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "once_cell" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" [[package]] name = "output_vt100" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" +checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66" dependencies = [ "winapi", ] @@ -137,40 +131,40 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.26" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.6" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea" +checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.2.4" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" +checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" dependencies = [ "bitflags", ] [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" [[package]] name = "sailfish" -version = "0.3.4" +version = "0.4.0" dependencies = [ "itoap", "ryu", @@ -182,7 +176,7 @@ dependencies = [ [[package]] name = "sailfish-compiler" -version = "0.3.4" +version = "0.4.0" dependencies = [ "filetime", "home", @@ -190,13 +184,14 @@ dependencies = [ "pretty_assertions", "proc-macro2", "quote", + "serde", "syn", - "yaml-rust", + "toml", ] [[package]] name = "sailfish-macros" -version = "0.3.4" +version = "0.4.0" dependencies = [ "proc-macro2", "sailfish-compiler", @@ -204,18 +199,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.111" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9124df5b40cbd380080b2cc6ab894c040a3070d995f5c9dc77e18c34a8ae37d" +checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.111" +version = "1.0.136" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f2c3ac8e6ca1e9c80b8be1023940162bf81ae3cffbb1809474152f2ce1eb250" +checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" dependencies = [ "proc-macro2", "quote", @@ -224,9 +219,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.53" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "993948e75b189211a9b31a7528f950c6adc21f9720b6438ff80a7fa2f864cea2" +checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ "itoa", "ryu", @@ -235,9 +230,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.68" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87" +checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" dependencies = [ "proc-macro2", "quote", @@ -246,30 +241,30 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] [[package]] name = "toml" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] [[package]] name = "trybuild" -version = "1.0.28" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3183158b2c8170db33b8b3a90ddc7b5f380d15b50794d22c1fa9c61b47249" +checksum = "2d60539445867cdd9680b2bfe2d0428f1814b7d5c9652f09d8d3eae9d19308db" dependencies = [ "glob", - "lazy_static", + "once_cell", "serde", "serde_json", "termcolor", @@ -278,21 +273,21 @@ dependencies = [ [[package]] name = "unicode-xid" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "winapi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", @@ -318,12 +313,3 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "yaml-rust" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39f0c922f1a334134dc2f7a8b67dc5d25f0735263feec974345ff706bcf20b0d" -dependencies = [ - "linked-hash-map", -] diff --git a/README.md b/README.md index 7a943c1..a5cf5a1 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,13 @@ Simple, small, and extremely fast template engine for Rust -[![Tests](https://github.com/Kogia-sima/sailfish/workflows/Tests/badge.svg)](https://github.com/Kogia-sima/sailfish/actions?query=workflow%3ATests) +[![Tests](https://github.com/rust-sailfish/sailfish/workflows/Tests/badge.svg)](https://github.com/rust-sailfish/sailfish/actions?query=workflow%3ATests) [![Version](https://img.shields.io/crates/v/sailfish)](https://crates.io/crates/sailfish) -[![dependency status](https://deps.rs/repo/github/Kogia-sima/sailfish/status.svg)](https://deps.rs/repo/github/Kogia-sima/sailfish) +[![dependency status](https://deps.rs/repo/github/rust-sailfish/sailfish/status.svg)](https://deps.rs/repo/github/rust-sailfish/sailfish) [![Rust 1.42](https://img.shields.io/badge/rust-1.42+-lightgray.svg)](https://blog.rust-lang.org/2020/03/12/Rust-1.42.html) -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Kogia-sima/sailfish/blob/master/LICENSE) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/rust-sailfish/sailfish/blob/master/LICENSE) -[User Guide](https://sailfish.netlify.app/en/) | [API Docs](https://docs.rs/sailfish) | [Examples](./examples) +[User Guide](https://rust-sailfish.netlify.app/en/) | [API Docs](https://docs.rs/sailfish) | [Examples](./examples) @@ -31,7 +31,7 @@ Dependencies: ```toml [dependencies] -sailfish = "0.3.4" +sailfish = "0.4.0" ``` Template file (templates/hello.stpl): @@ -69,7 +69,7 @@ You can find more examples in [examples](./examples) directory. ## 🐾 Roadmap -- `Template` trait ([RFC](https://github.com/Kogia-sima/sailfish/issues/3)) +- `Template` trait ([RFC](https://github.com/rust-sailfish/sailfish/issues/3)) - Template inheritance (block, partials, etc.) ## 👤 Author @@ -82,9 +82,9 @@ You can find more examples in [examples](./examples) directory. Contributions, issues and feature requests are welcome! -Since sailfish is an immature library, there are many [planned features](https://github.com/Kogia-sima/sailfish/labels/Type%3A%20RFC) that is on a stage of RFC. Please leave a comment if you have an idea about its design! +Since sailfish is an immature library, there are many [planned features](https://github.com/rust-sailfish/sailfish/labels/Type%3A%20RFC) that is on a stage of RFC. Please leave a comment if you have an idea about its design! -Also I welcome any pull requests to improve sailfish! Find issue with [Status: PR Welcome](https://github.com/Kogia-sima/sailfish/issues?q=is%3Aissue+is%3Aopen+label%3A%22Status%3A+PR+Welcome%22) label, and [let's create a new pull request](https://github.com/Kogia-sima/sailfish/pulls)! +Also I welcome any pull requests to improve sailfish! Find issue with [Status: PR Welcome](https://github.com/rust-sailfish/sailfish/issues?q=is%3Aissue+is%3Aopen+label%3A%22Status%3A+PR+Welcome%22) label, and [let's create a new pull request](https://github.com/rust-sailfish/sailfish/pulls)! ## Show your support @@ -94,7 +94,7 @@ Give a ⭐️ if this project helped you! Copyright © 2020 [Ryohei Machida](https://github.com/Kogia-sima). -This project is [MIT](https://github.com/Kogia-sima/sailfish/blob/master/LICENSE) licensed. +This project is [MIT](https://github.com/rust-sailfish/sailfish/blob/master/LICENSE) licensed. *** _This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_ diff --git a/docs/en/docs/assets/css/custom.css b/docs/en/docs/assets/css/custom.css index f74aeeb..37e63aa 100644 --- a/docs/en/docs/assets/css/custom.css +++ b/docs/en/docs/assets/css/custom.css @@ -1,5 +1,5 @@ .md-typeset__table table { - font-size: .75rem !important; + font-size: 0.75rem !important; } .md-typeset__table table tr td:first-child { @@ -8,16 +8,16 @@ .md-typeset code { background-color: rgb(240, 240, 240); - font-size: .95em; + font-size: 0.95em; } .md-typeset pre > code { background-color: rgb(245, 245, 245); - font-size: .90em; + font-size: 0.9em; } .md-typeset .admonition { - font-size: .70rem; + font-size: 0.7rem; } body { @@ -29,7 +29,7 @@ body { border-bottom-color: rgb(234, 236, 239); border-bottom-style: solid; border-bottom-width: 1px; - padding-bottom: .3rem; + padding-bottom: 0.3rem; } .md-content a:hover { @@ -39,3 +39,22 @@ body { .highlight code .cp { color: #a83; } + +a code { + color: #472a63 !important; +} + +[data-md-color-scheme="dark"] { + --md-primary-fg-color: #321860; + --md-default-bg-color: #170a1c; + --md-default-fg-color: #dabaff; + --md-typeset-color: #ffffff; + --md-default-fg-color--light: #b0a8b9; + --md-typeset-a-color: #b596d2; + --md-code-bg-color: #f5f5f5; + --md-code-fg-color: #170a1c; + --md-admonition-fg-color: #ffffff; + --md-default-fg-color--lighter: #acb7c0; + --md-default-fg-color--lightest: #d2d5db; + --md-code-hl-variable-color: #815abb; +} diff --git a/docs/en/docs/getting-started.md b/docs/en/docs/getting-started.md index 1337b22..d6bc09e 100644 --- a/docs/en/docs/getting-started.md +++ b/docs/en/docs/getting-started.md @@ -58,4 +58,4 @@ fn main() { That's it! -You can find more examples in the [example](https://github.com/Kogia-sima/sailfish/tree/master/examples) directory in the sailfish repository. +You can find more examples in the [example](https://github.com/rust-sailfish/sailfish/tree/master/examples) directory in the sailfish repository. diff --git a/docs/en/docs/index.md b/docs/en/docs/index.md index 3935a05..0f24a58 100644 --- a/docs/en/docs/index.md +++ b/docs/en/docs/index.md @@ -13,11 +13,11 @@ There are many libraries for template rendering in Rust. Among those libraries, - Minimal dependencies (<15 crates in total) - Extremely fast (See [benchmarks](https://github.com/djc/template-benchmarks-rs)) - Template rendering is always type-safe because templates are statically compiled. -- Syntax highlighting ([vscode](http://github.com/Kogia-sima/sailfish/blob/master/syntax/vscode), [vim](http://github.com/Kogia-sima/sailfish/blob/master/syntax/vim)) +- Syntax highlighting ([vscode](http://github.com/rust-sailfish/sailfish/blob/master/syntax/vscode), [vim](http://github.com/rust-sailfish/sailfish/blob/master/syntax/vim)) ## Upcoming features -Since sailfish is on early stage of development, there are many upcoming features that is not supported yet. You can find many [RFC](https://github.com/Kogia-sima/sailfish/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+RFC%22)s in my repository. These RFC include: +Since sailfish is on early stage of development, there are many upcoming features that is not supported yet. You can find many [RFC](https://github.com/rust-sailfish/sailfish/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+RFC%22)s in my repository. These RFC include: - `Template` trait (which does not consume itself) - Template inheritance (block, partials, etc.) @@ -28,4 +28,4 @@ If you have any idea about them or want to implement that feature, please send a Copyright © 2020 Ryohei Machida -This project is [MIT](https://github.com/Kogia-sima/sailfish/blob/master/LICENSE) licensed +This project is [MIT](https://github.com/rust-sailfish/sailfish/blob/master/LICENSE) licensed diff --git a/docs/en/docs/installation.md b/docs/en/docs/installation.md index 9ae387b..844c33b 100644 --- a/docs/en/docs/installation.md +++ b/docs/en/docs/installation.md @@ -4,7 +4,7 @@ In order to use sailfish templates, you have add two dependencies in your `Cargo ``` toml [dependencies] -sailfish = "0.3.4" +sailfish = "0.4.0" ``` ## Feature Flags diff --git a/docs/en/docs/options.md b/docs/en/docs/options.md index ad8b3c6..02b0e9a 100644 --- a/docs/en/docs/options.md +++ b/docs/en/docs/options.md @@ -33,13 +33,13 @@ struct TemplateStruct { ## Configuration file -Sailfish allows global and local configuration in a file named `sailfish.yml`. Sailfish looks for this file in same directory as `Cargo.toml` and all parent directories. +Sailfish allows global and local configuration in a file named `sailfish.toml`. Sailfish looks for this file in same directory as `Cargo.toml` and all parent directories. If, for example, `Cargo.toml` exists in `/foo/bar/baz` directory, then the following configuration files would be scanned in this order. -- `/foo/bar/baz/sailfish.yml` -- `/foo/bar/sailfish.yml` -- `/foo/sailfish.yml` -- `/sailfish.yml` +- `/foo/bar/baz/sailfish.toml` +- `/foo/bar/sailfish.toml` +- `/foo/sailfish.toml` +- `/sailfish.toml` If a key is specified in multiple configuration files, the value in the deeper directory takes precedence over ancestor directories. @@ -47,15 +47,21 @@ If a key is specified in both configuration file and derive options, then the va ### Configuration file format -Configuration files are written in the YAML 1.2 format. Here is the default configuration. +Configuration files are written in the TOML 0.5 format. Here is the default configuration: -``` yaml -template_dir: "templates" -escape: true -delimiter: "%" +``` toml +template_dirs = ["templates"] +escape = true +delimiter = "%" -optimization: - rm_whitespace: false +[optimizations] +rm_whitespace = false ``` -You can specify another template directory in `template_dir` option. Other options are same as derive options. +You can specify another template directory in `template_dirs` option. Other options are same as derive options. + +You can also embed environment variables in `template_dirs` paths by wrapping the variable name with `${` and `}` like `${MY_ENV_VAR}`: + +```toml +template_dirs = ["${CI}/path/to/project/${MYVAR}/templates"] +``` diff --git a/docs/en/mkdocs.yml b/docs/en/mkdocs.yml index e9c527f..845be1c 100644 --- a/docs/en/mkdocs.yml +++ b/docs/en/mkdocs.yml @@ -1,59 +1,70 @@ # Project information -site_name: 'Sailfish Documentation' +site_name: "Sailfish Documentation" # site_description: 'Sailfish Documentation' -site_author: 'Ryohei Machida' +site_author: "Ryohei Machida" # site_url: 'https://***.com' # Copyright -copyright: '© 2020 Ryohei Machida' +copyright: "© 2020 Ryohei Machida" # Repository -repo_name: 'Kogia-sima/sailfish' -repo_url: 'https://github.com/Kogia-sima/sailfish' +repo_name: "rust-sailfish/sailfish" +repo_url: "https://github.com/rust-sailfish/sailfish" -# Configuration theme: - name: 'material' - language: 'en' - logo: 'images/logo.svg' + name: "material" + language: "en" + logo: "images/logo.svg" palette: - scheme: 'default' - primary: 'deep purple' - accent: 'deep purple' - favicon: 'images/favicon.ico' + - media: "(prefers-color-scheme: dark)" + scheme: "dark" + primary: "deep purple" + accent: "deep purple" + toggle: + icon: "material/lightbulb-outline" + name: "Light Mode" + - media: "(prefers-color-scheme: light)" + scheme: "default" + primary: "deep purple" + accent: "deep purple" + toggle: + icon: "material/lightbulb" + name: "Dark Mode" + favicon: "images/favicon.ico" font: - text: 'Ubuntu' - code: 'Ubuntu Mono' + text: "Ubuntu" + code: "Ubuntu Mono" features: - - 'navigation.expand' + - "navigation.expand" # Extensions markdown_extensions: - - 'admonition' - - 'footnotes' - - 'pymdownx.highlight' - - 'pymdownx.tabbed' - - 'pymdownx.superfences': + - "admonition" + - "footnotes" + - "pymdownx.highlight" + - "pymdownx.tabbed": + alternate_style: true + - "pymdownx.superfences": custom_fences: - name: mermaid class: mermaid extra_css: - - 'assets/css/custom.css' + - "assets/css/custom.css" extra: social: - - icon: 'fontawesome/brands/github-alt' - link: 'https://github.com/Kogia-sima' + - icon: "fontawesome/brands/github-alt" + link: "https://github.com/rust-sailfish" # Page tree nav: - - 'Welcome': 'index.md' - - 'Installation': 'installation.md' - - 'Getting Started': 'getting-started.md' - - 'Configuration': 'options.md' - - 'Syntax': - - 'Overview': 'syntax/overview.md' - - 'Tags': 'syntax/tags.md' - - 'Includes': 'syntax/includes.md' - - 'Filters': 'syntax/filters.md' + - "Welcome": "index.md" + - "Installation": "installation.md" + - "Getting Started": "getting-started.md" + - "Configuration": "options.md" + - "Syntax": + - "Overview": "syntax/overview.md" + - "Tags": "syntax/tags.md" + - "Includes": "syntax/includes.md" + - "Filters": "syntax/filters.md" diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 7321d35..9519f58 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sailfish-examples" -version = "0.3.4" +version = "0.4.0" authors = ["Ryohei Machida "] edition = "2018" publish = false diff --git a/requirements.txt b/requirements.txt index 3ef9d7d..5215838 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -mkdocs-material==5.2.3 -mkdocs==1.1.2 +mkdocs-material==8.2.3 +mkdocs==1.2.3 diff --git a/sailfish-compiler/Cargo.toml b/sailfish-compiler/Cargo.toml index 2e6d08b..89289f0 100644 --- a/sailfish-compiler/Cargo.toml +++ b/sailfish-compiler/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "sailfish-compiler" -version = "0.3.4" +version = "0.4.0" authors = ["Ryohei Machida "] description = "Simple, small, and extremely fast template engine for Rust" -homepage = "https://github.com/Kogia-sima/sailfish" -repository = "https://github.com/Kogia-sima/sailfish" +homepage = "https://github.com/rust-sailfish/sailfish" +repository = "https://github.com/rust-sailfish/sailfish" readme = "../README.md" keywords = ["markup", "template", "html"] categories = ["template-engine"] @@ -19,12 +19,13 @@ doctest = false [features] default = ["config"] procmacro = [] -config = ["yaml-rust"] +config = ["serde", "toml"] [dependencies] memchr = "2.3.3" quote = { version = "1.0.6", default-features = false } -yaml-rust = { version = "0.4.4", optional = true } +serde = { version = "1.0", features = ["derive"], optional = true } +toml = { version = "0.5", optional = true } home = "0.5.3" filetime = "0.2.14" diff --git a/sailfish-compiler/src/config.rs b/sailfish-compiler/src/config.rs index b47e9ce..0a26a58 100644 --- a/sailfish-compiler/src/config.rs +++ b/sailfish-compiler/src/config.rs @@ -27,8 +27,8 @@ impl Default for Config { #[cfg(feature = "config")] mod imp { + use serde::Deserialize; use std::fs; - use yaml_rust::yaml::{Yaml, YamlLoader}; use super::*; use crate::error::*; @@ -41,7 +41,7 @@ mod imp { for component in base.iter() { path.push(component); - path.push("sailfish.yml"); + path.push("sailfish.toml"); if path.is_file() { let config_file = @@ -52,6 +52,14 @@ mod imp { if let Some(template_dirs) = config_file.template_dirs { for template_dir in template_dirs.into_iter().rev() { + let expanded = + expand_env_vars(template_dir).map_err(|mut e| { + e.source_file = Some(path.to_owned()); + e + })?; + + let template_dir = PathBuf::from(expanded); + if template_dir.is_absolute() { config.template_dirs.push(template_dir); } else { @@ -70,8 +78,10 @@ mod imp { config.escape = escape; } - if let Some(rm_whitespace) = config_file.rm_whitespace { - config.rm_whitespace = rm_whitespace; + if let Some(optimizations) = config_file.optimizations { + if let Some(rm_whitespace) = optimizations.rm_whitespace { + config.rm_whitespace = rm_whitespace; + } } } @@ -82,154 +92,138 @@ mod imp { } } - #[derive(Default)] + #[derive(Deserialize, Debug)] + #[serde(deny_unknown_fields)] + struct Optimizations { + rm_whitespace: Option, + } + + #[derive(Deserialize, Debug)] + #[serde(deny_unknown_fields)] struct ConfigFile { - template_dirs: Option>, + template_dirs: Option>, delimiter: Option, escape: Option, - rm_whitespace: Option, + optimizations: Option, } impl ConfigFile { fn read_from_file(path: &Path) -> Result { - let mut config = Self::default(); let content = fs::read_to_string(path) .chain_err(|| format!("Failed to read configuration file {:?}", path))?; - - let entries = YamlLoader::load_from_str(&*content) - .map_err(|e| ErrorKind::ConfigError(e.to_string()))?; - drop(content); - - for entry in entries { - config.visit_global(entry)? - } - - Ok(config) + Self::from_string(&content) } - fn visit_global(&mut self, entry: Yaml) -> Result<(), Error> { - let hash = entry.into_hash().ok_or_else(|| { - ErrorKind::ConfigError("Invalid configuration format".to_owned()) - })?; - - for (k, v) in hash { - match k { - Yaml::String(ref s) => match &**s { - "template_dir" => self.visit_template_dir(v)?, - "delimiter" => self.visit_delimiter(v)?, - "escape" => self.visit_escape(v)?, - "optimization" => self.visit_optimization(v)?, - _ => return Err(Self::error(format!("Unknown key ({})", s))), - }, - _ => { - return Err(Self::error("Invalid configuration format")); - } - } - } - - Ok(()) + fn from_string(content: &str) -> Result { + toml::from_str::(content).map_err(|e| error(e.to_string())) } + } - fn visit_template_dir(&mut self, value: Yaml) -> Result<(), Error> { - if self.template_dirs.is_some() { - return Err(Self::error("Duplicate key (template_dir)")); - } + fn expand_env_vars>(input: S) -> Result { + use std::env; - match value { - Yaml::String(s) => self.template_dirs = Some(vec![PathBuf::from(s)]), - Yaml::Array(v) => { - let mut template_dirs = Vec::new(); - for e in v { - if let Yaml::String(s) = e { - template_dirs.push(PathBuf::from(s)); + let input = input.as_ref(); + let len = input.len(); + let mut iter = input.chars().enumerate(); + let mut result = String::new(); + + let mut found = false; + let mut env_var = String::new(); + + while let Some((i, c)) = iter.next() { + match c { + '$' if found == false => { + if let Some((_, cc)) = iter.next() { + if cc == '{' { + found = true; } else { - return Err(Self::error( - "Arguments of `template_dir` must be string", - )); + // We didn't find a trailing { after the $ + // so we push the chars read onto the result + result.push(c); + result.push(cc); } } - self.template_dirs = Some(template_dirs); + } + '}' if found => { + let val = env::var(&env_var).map_err(|e| match e { + env::VarError::NotPresent => { + error(format!("Environment variable ({}) not set", env_var)) + } + env::VarError::NotUnicode(_) => error(format!( + "Environment variable ({}) contents not valid unicode", + env_var + )), + })?; + result.push_str(&val); + + env_var.clear(); + found = false; } _ => { - return Err(Self::error( - "Arguments of `template_dir` must be string", - )); - } - } + if found { + env_var.push(c); - Ok(()) - } - - fn visit_delimiter(&mut self, value: Yaml) -> Result<(), Error> { - if self.delimiter.is_some() { - return Err(Self::error("Duplicate key (delimiter)")); - } - - if let Yaml::String(s) = value { - if s.chars().count() == 1 { - self.delimiter = Some(s.chars().next().unwrap()); - Ok(()) - } else { - Err(Self::error("`escape` must be single character")) - } - } else { - Err(Self::error("`escape` must be single character")) - } - } - - fn visit_escape(&mut self, value: Yaml) -> Result<(), Error> { - if self.escape.is_some() { - return Err(Self::error("Duplicate key (escape)")); - } - - if let Yaml::Boolean(b) = value { - self.escape = Some(b); - Ok(()) - } else { - Err(Self::error("`escape` must be boolean")) - } - } - - fn visit_optimization(&mut self, entry: Yaml) -> Result<(), Error> { - let hash = entry.into_hash().ok_or_else(|| { - ErrorKind::ConfigError("Invalid configuration format".to_owned()) - })?; - - for (k, v) in hash { - match k { - Yaml::String(ref s) => match &**s { - "rm_whitespace" => self.visit_rm_whitespace(v)?, - _ => { - return Err(Self::error(format!( - "Unknown key (optimization.{})", - s - ))); + // Check if we're at the end with an unclosed environment variable: + // ${MYVAR instead of ${MYVAR} + // If so, push it back onto the string as some systems allows the $ { characters in paths. + if i == len - 1 { + result.push_str("${"); + result.push_str(&env_var); } - }, - _ => { - return Err(Self::error("Invalid configuration format")); + } else { + result.push(c); } } } - - Ok(()) } - fn visit_rm_whitespace(&mut self, value: Yaml) -> Result<(), Error> { - if self.rm_whitespace.is_some() { - return Err(Self::error("Duplicate key (rm_whitespace)")); - } + Ok(result) + } - if let Yaml::Boolean(b) = value { - self.rm_whitespace = Some(b); - Ok(()) - } else { - Err(Self::error("`rm_whitespace` must be boolean")) - } + fn error>(msg: T) -> Error { + make_error!(ErrorKind::ConfigError(msg.into())) + } + + #[cfg(test)] + mod tests { + use crate::config::imp::expand_env_vars; + use std::env; + + #[test] + fn expands_env_vars() { + env::set_var("TESTVAR", "/a/path"); + let input = "/path/to/${TESTVAR}Templates"; + let output = expand_env_vars(input).unwrap(); + assert_eq!(output, "/path/to//a/pathTemplates"); } - fn error>(msg: T) -> Error { - make_error!(ErrorKind::ConfigError(msg.into())) + #[test] + fn retains_case_sensitivity() { + env::set_var("tEstVar", "/a/path"); + let input = "/path/${tEstVar}"; + let output = expand_env_vars(input).unwrap(); + assert_eq!(output, "/path//a/path"); + } + + #[test] + fn retains_unclosed_env_var() { + let input = "/path/to/${UNCLOSED"; + let output = expand_env_vars(input).unwrap(); + assert_eq!(output, input); + } + + #[test] + fn ingores_markers() { + let input = "path/{$/$}/${/to/{"; + let output = expand_env_vars(input).unwrap(); + assert_eq!(output, input); + } + + #[test] + fn errors_on_unset_env_var() { + let input = "/path/to/${UNSET}"; + let output = expand_env_vars(input); + assert!(output.is_err()); } } } diff --git a/sailfish-macros/Cargo.toml b/sailfish-macros/Cargo.toml index b014682..1779ac6 100644 --- a/sailfish-macros/Cargo.toml +++ b/sailfish-macros/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "sailfish-macros" -version = "0.3.4" +version = "0.4.0" authors = ["Ryohei Machida "] description = "Simple, small, and extremely fast template engine for Rust" -homepage = "https://github.com/Kogia-sima/sailfish" -repository = "https://github.com/Kogia-sima/sailfish" +homepage = "https://github.com/rust-sailfish/sailfish" +repository = "https://github.com/rust-sailfish/sailfish" readme = "../README.md" keywords = ["markup", "template", "html"] categories = ["template-engine"] @@ -30,6 +30,6 @@ proc-macro2 = "1.0.11" [dependencies.sailfish-compiler] path = "../sailfish-compiler" -version = "0.3.4" +version = "0.4.0" default-features = false features = ["procmacro"] diff --git a/sailfish-tests/fuzzing-tests/Cargo.toml b/sailfish-tests/fuzzing-tests/Cargo.toml index ec9b875..6dbe25c 100644 --- a/sailfish-tests/fuzzing-tests/Cargo.toml +++ b/sailfish-tests/fuzzing-tests/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fuzzing-tests" -version = "0.3.4" +version = "0.4.0" authors = ["Ryohei Machida "] edition = "2018" publish = false @@ -8,6 +8,6 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -afl = "0.8.0" +afl = "0.12.2" sailfish = { path = "../../sailfish", default-features = false } sailfish-compiler = { path = "../../sailfish-compiler", default-features = false } diff --git a/sailfish-tests/integration-tests/Cargo.toml b/sailfish-tests/integration-tests/Cargo.toml index fc68163..93dad63 100644 --- a/sailfish-tests/integration-tests/Cargo.toml +++ b/sailfish-tests/integration-tests/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "integration-tests" -version = "0.3.4" -authors = ["Kogia-sima "] +version = "0.4.0" +authors = ["Ryohei Machida "] edition = "2018" publish = false diff --git a/sailfish-tests/integration-tests/config/sailfish.toml b/sailfish-tests/integration-tests/config/sailfish.toml new file mode 100644 index 0000000..07d78e0 --- /dev/null +++ b/sailfish-tests/integration-tests/config/sailfish.toml @@ -0,0 +1,6 @@ +template_dirs = ["../templates"] +escape = true +delimiter = "%" + +[optimizations] +rm_whitespace = false \ No newline at end of file diff --git a/sailfish-tests/integration-tests/config/sailfish.yml b/sailfish-tests/integration-tests/config/sailfish.yml deleted file mode 100644 index c12237c..0000000 --- a/sailfish-tests/integration-tests/config/sailfish.yml +++ /dev/null @@ -1,6 +0,0 @@ -template_dir: "../templates" -escape: true -delimiter: "%" - -optimization: - rm_whitespace: false diff --git a/sailfish/Cargo.toml b/sailfish/Cargo.toml index 8bc4f4d..301cca6 100644 --- a/sailfish/Cargo.toml +++ b/sailfish/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "sailfish" -version = "0.3.4" +version = "0.4.0" authors = ["Ryohei Machida "] description = "Simple, small, and extremely fast template engine for Rust" -homepage = "https://github.com/Kogia-sima/sailfish" -repository = "https://github.com/Kogia-sima/sailfish" +homepage = "https://github.com/rust-sailfish/sailfish" +repository = "https://github.com/rust-sailfish/sailfish" readme = "../README.md" keywords = ["markup", "template", "html"] categories = ["template-engine"] @@ -29,7 +29,7 @@ serde_json = { version = "1.0.53", optional = true } [dependencies.sailfish-macros] path = "../sailfish-macros" -version = "0.3.4" +version = "0.4.0" optional = true [build-dependencies] diff --git a/sailfish/src/lib.rs b/sailfish/src/lib.rs index e305d32..f29a663 100644 --- a/sailfish/src/lib.rs +++ b/sailfish/src/lib.rs @@ -1,6 +1,6 @@ //! Sailfish is a simple, small, and extremely fast template engine for Rust. //! Before reading this reference, -//! I recommend reading [User guide](https://sailfish.netlify.app/en/). +//! I recommend reading [User guide](https://rust-sailfish.netlify.app/en/). //! //! This crate contains utilities for rendering sailfish template. //! If you want to use sailfish templates, import `sailfish-macros` crate and use @@ -29,7 +29,7 @@ //! ``` #![doc( - html_logo_url = "https://raw.githubusercontent.com/Kogia-sima/sailfish/master/resources/icon.png" + html_logo_url = "https://raw.githubusercontent.com/rust-sailfish/sailfish/master/resources/icon.png" )] #![cfg_attr(sailfish_nightly, feature(core_intrinsics))] #![cfg_attr(docsrs, feature(doc_cfg))] diff --git a/scripts/build-docs.py b/scripts/build-docs.py index aed34c2..d10fa90 100644 --- a/scripts/build-docs.py +++ b/scripts/build-docs.py @@ -7,17 +7,25 @@ import subprocess def build_docs(input_dir: str, output_dir: str): - subprocess.call('mkdocs build', shell=True, cwd=input_dir) + subprocess.call('python3 -m pip install --upgrade pip', shell=True, cwd=input_dir) + subprocess.call('python3 -m pip install mkdocs', shell=True, cwd=input_dir) + subprocess.call('python3 -m mkdocs build', shell=True, cwd=input_dir) site_dir = os.path.join(input_dir, 'site') shutil.copytree(site_dir, output_dir) def main() -> None: - if os.path.exists('site'): - os.removedirs('site') + if os.path.exists('site'): + if os.path.isfile('site') or os.path.islink('site'): + os.unlink('site') + else: + shutil.rmtree('site') os.mkdir('site') - build_docs('./docs/en', output_dir='site/en') + # get the path of the current directory + docs_path = os.path.join(os.getcwd(), "docs/en") + print(docs_path) + build_docs(docs_path, output_dir='site/en') if __name__ == '__main__': diff --git a/scripts/travis.sh b/scripts/travis.sh index b3ac039..5a7fd0d 100644 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -10,7 +10,7 @@ if [ "$TRAVIS_RUST_VERSION" = "nightly" ] && [ -z "$TRAVIS_TAG" ]; then wget https://github.com/mozilla/grcov/releases/download/v0.5.5/grcov-linux-x86_64.tar.bz2 tar xvf grcov-linux-x86_64.tar.bz2 - wget https://github.com/Kogia-sima/rust-covfix/releases/download/v0.2.1/rust-covfix-linux-x86_64.tar.xz + wget https://github.com/rust-sailfish/rust-covfix/releases/download/v0.2.1/rust-covfix-linux-x86_64.tar.xz tar xvf rust-covfix-linux-x86_64.tar.xz mv rust-covfix-linux-x86_64/rust-covfix ./ fi diff --git a/syntax/vim/README.md b/syntax/vim/README.md index c08d8f3..63cbfd8 100644 --- a/syntax/vim/README.md +++ b/syntax/vim/README.md @@ -5,13 +5,13 @@ ### Using dein.vim ``` -call dein#add('Kogia-sima/sailfish', {'rtp': 'syntax/vim'}) +call dein#add('rust-sailfish/sailfish', {'rtp': 'syntax/vim'}) ``` ### Using vim-plug ``` -Plug 'Kogia-sima/sailfish', { 'rtp': 'syntax/vim' } +Plug 'rust-sailfish/sailfish', { 'rtp': 'syntax/vim' } ``` ## Screenshot diff --git a/syntax/vim/ftdetect/sailfish.vim b/syntax/vim/ftdetect/sailfish.vim index 04a0884..61bd0db 100644 --- a/syntax/vim/ftdetect/sailfish.vim +++ b/syntax/vim/ftdetect/sailfish.vim @@ -1,6 +1,6 @@ " Detect sailfish template files and set filetype " Maintainer: Ryohei Machida -" URL: http://github.com/Kogia-sima/sailfish +" URL: http://github.com/rust-sailfish/sailfish " License: MIT autocmd BufNewFile,BufRead *.stpl set filetype=sailfish diff --git a/syntax/vscode/package.json b/syntax/vscode/package.json index 4e817d1..424a86f 100644 --- a/syntax/vscode/package.json +++ b/syntax/vscode/package.json @@ -5,7 +5,7 @@ "version": "0.1.0", "author": "Ryohei Machida ", "publisher": "kogia-sima", - "repository": "Kogia-sima/sailfish", + "repository": "rust-sailfish/sailfish", "license": "MIT", "engines": { "vscode": "^1.45.0"