diff options
| author | Fuwn <[email protected]> | 2023-04-17 06:57:19 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-04-17 06:57:19 +0000 |
| commit | 3854c711b097b39e858d8ceabb4099a659f875a1 (patch) | |
| tree | eaeb6edb104306f17d2bbba3895ee9b93ec39036 | |
| parent | chore(README): Update examples directory path (diff) | |
| download | germ-3854c711b097b39e858d8ceabb4099a659f875a1.tar.xz germ-3854c711b097b39e858d8ceabb4099a659f875a1.zip | |
refactor: remove seldom used procedural macros
| -rw-r--r-- | Cargo.toml | 39 | ||||
| -rw-r--r-- | Makefile.toml | 13 | ||||
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | crates/germ-macros-impl/Cargo.toml | 21 | ||||
| -rw-r--r-- | crates/germ-macros-impl/src/lib.rs | 58 | ||||
| -rw-r--r-- | crates/germ/Cargo.toml | 35 | ||||
| -rw-r--r-- | examples/ast.rs (renamed from crates/germ/examples/ast.rs) | 0 | ||||
| -rw-r--r-- | examples/ast_to_gemtext.rs (renamed from crates/germ/examples/ast_to_gemtext.rs) | 0 | ||||
| -rw-r--r-- | examples/async_request.rs (renamed from crates/germ/examples/async_request.rs) | 0 | ||||
| -rw-r--r-- | examples/convert.html (renamed from crates/germ/examples/convert.html) | 0 | ||||
| -rw-r--r-- | examples/convert.md (renamed from crates/germ/examples/convert.md) | 0 | ||||
| -rw-r--r-- | examples/html.rs (renamed from crates/germ/examples/html.rs) | 2 | ||||
| -rw-r--r-- | examples/markdown.rs (renamed from crates/germ/examples/markdown.rs) | 2 | ||||
| -rw-r--r-- | examples/meta.rs (renamed from crates/germ/examples/meta.rs) | 0 | ||||
| -rw-r--r-- | examples/request.rs (renamed from crates/germ/examples/request.rs) | 0 | ||||
| -rw-r--r-- | examples/request_to_gemtext_from_ast.rs (renamed from crates/germ/examples/request_to_gemtext_from_ast.rs) | 0 | ||||
| -rw-r--r-- | src/ast.rs (renamed from crates/germ/src/ast.rs) | 0 | ||||
| -rw-r--r-- | src/ast/container.rs (renamed from crates/germ/src/ast/container.rs) | 0 | ||||
| -rw-r--r-- | src/ast/macros.rs (renamed from crates/germ/src/ast/macros.rs) | 14 | ||||
| -rw-r--r-- | src/ast/node.rs (renamed from crates/germ/src/ast/node.rs) | 0 | ||||
| -rw-r--r-- | src/convert.rs (renamed from crates/germ/src/convert.rs) | 0 | ||||
| -rw-r--r-- | src/convert/html.rs (renamed from crates/germ/src/convert/html.rs) | 0 | ||||
| -rw-r--r-- | src/convert/macros.rs (renamed from crates/germ/src/convert/macros.rs) | 11 | ||||
| -rw-r--r-- | src/convert/markdown.rs (renamed from crates/germ/src/convert/markdown.rs) | 0 | ||||
| -rw-r--r-- | src/lib.rs (renamed from crates/germ/src/lib.rs) | 0 | ||||
| -rw-r--r-- | src/meta.rs (renamed from crates/germ/src/meta.rs) | 0 | ||||
| -rw-r--r-- | src/quick.rs (renamed from crates/germ/src/quick.rs) | 0 | ||||
| -rw-r--r-- | src/request.rs (renamed from crates/germ/src/request.rs) | 0 | ||||
| -rw-r--r-- | src/request/response.rs (renamed from crates/germ/src/request/response.rs) | 0 | ||||
| -rw-r--r-- | src/request/status.rs (renamed from crates/germ/src/request/status.rs) | 0 | ||||
| -rw-r--r-- | src/request/sync.rs (renamed from crates/germ/src/request/sync.rs) | 0 | ||||
| -rw-r--r-- | src/request/verifier.rs (renamed from crates/germ/src/request/verifier.rs) | 0 | ||||
| -rw-r--r-- | tests/ast.rs (renamed from crates/germ/tests/ast.rs) | 12 | ||||
| -rw-r--r-- | tests/convert.rs (renamed from crates/germ/tests/convert.rs) | 13 | ||||
| -rw-r--r-- | tests/meta.rs (renamed from crates/germ/tests/meta.rs) | 0 | ||||
| -rw-r--r-- | tests/quick.rs (renamed from crates/germ/tests/quick.rs) | 0 | ||||
| -rw-r--r-- | tests/status.rs (renamed from crates/germ/tests/status.rs) | 0 |
37 files changed, 41 insertions, 182 deletions
@@ -1,4 +1,39 @@ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[workspace] -members = ["crates/germ", "crates/germ-macros-impl"] +[package] +name = "germ" +version = "0.3.8" +authors = ["Fuwn <[email protected]>"] +edition = "2021" +description = "The Ultimate Gemini Toolkit." +documentation = "https://docs.rs/germ" +readme = "README.md" +homepage = "https://github.com/gemrest/germ" +repository = "https://github.com/gemrest/germ" +license = "GPL-3.0-only" +keywords = ["gemini", "parser", "lexer", "markdown", "converter"] +categories = ["encoding"] + +[features] +ast = [] +convert = ["ast"] +default = ["ast", "convert", "meta", "request"] +macros = ["ast", "convert"] +meta = [] +request = ["rustls", "url", "anyhow"] +quick = [] +sync = ["tokio", "tokio-rustls"] + +[dependencies] +anyhow = { version = "1.0.70", optional = true } # `Result` +rustls = { version = "0.21.0", features = [ + "dangerous_configuration" +], optional = true } # TLS +tokio-rustls = { version = "0.24.0", optional = true } # Non-blocking TLS +tokio = { version = "1.27.0", optional = true, default-features = false, features = [ + "net", + "io-util", + "rt-multi-thread", + "macros" +] } # Non-blocking I/O +url = { version = "2.3.1", optional = true } # URL Validation diff --git a/Makefile.toml b/Makefile.toml index 8d72151..d152803 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -1,39 +1,26 @@ -# ------------ -# | Wrappers | -# ------------ [tasks.fmt] args = ["fmt"] command = "cargo" toolchain = "nightly" -workspace = false [tasks.check] args = ["check", "--all-features"] command = "cargo" -workspace = false [tasks.clippy] args = ["clippy", "--all-features"] command = "cargo" -workspace = false [tasks.test] args = ["test", "--all-features"] command = "cargo" -workspace = false -# ------------- -# | Executors | -# ------------- [tasks.checkf] dependencies = ["fmt", "check"] -workspace = false [tasks.checkfc] dependencies = ["fmt", "check", "clippy"] -workspace = false [tasks.example] args = ["run", "--example", "${@}", "--all-features"] command = "cargo" -workspace = false @@ -51,7 +51,8 @@ features = ["ast"] # Enable the features you would like to use! ### Examples -Examples can be found within the [`examples/`](./examples) directory. +Examples can be found within the +[`examples/`](https://github.com/gemrest/germ/tree/main/examples) directory. ## License diff --git a/crates/germ-macros-impl/Cargo.toml b/crates/germ-macros-impl/Cargo.toml deleted file mode 100644 index c321b27..0000000 --- a/crates/germ-macros-impl/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[package] -name = "germ-macros-impl" -version = "0.1.2" -authors = ["Fuwn <[email protected]>"] -edition = "2021" -description = "Germ Macro Implementations" -documentation = "https://docs.rs/germ" -readme = "../../README.md" -homepage = "https://github.com/gemrest/germ" -repository = "https://github.com/gemrest/germ" -license = "GPL-3.0-only" -keywords = ["gemini", "parser", "lexer", "markdown", "converter"] -categories = ["encoding"] - -[lib] -proc-macro = true - -[dependencies] -quote = "1.0.18" # Quasi-quoting diff --git a/crates/germ-macros-impl/src/lib.rs b/crates/germ-macros-impl/src/lib.rs deleted file mode 100644 index 30fdd81..0000000 --- a/crates/germ-macros-impl/src/lib.rs +++ /dev/null @@ -1,58 +0,0 @@ -// This file is part of Germ <https://github.com/gemrest/germ>. -// Copyright (C) 2022-2022 Fuwn <[email protected]> -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 3. -// -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// -// Copyright (C) 2022-2022 Fuwn <[email protected]> -// SPDX-License-Identifier: GPL-3.0-only - -#![deny( - warnings, - nonstandard_style, - unused, - future_incompatible, - rust_2018_idioms, - unsafe_code, - clippy::all, - clippy::nursery, - clippy::pedantic -)] -#![feature(proc_macro_hygiene, proc_macro_span)] -#![recursion_limit = "128"] - -use proc_macro::TokenStream; - -/// Convert Gemtext into a token tree -/// -/// # Panics -/// -/// May panic if the Gemini could not be properly handled, for any reason. -#[proc_macro] -pub fn gemini_to_tt(input: TokenStream) -> TokenStream { - let mut tokens = input.into_iter(); - let mut span = tokens.next().unwrap().span(); - - for token in tokens { - span = span.join(token.span()).unwrap(); - } - - let gemini = span - .source_text() - .unwrap() - .lines() - .map(|l| l.trim_start().to_string()) - .collect::<Vec<String>>() - .join("\n"); - - quote::quote!(#gemini).into() -} diff --git a/crates/germ/Cargo.toml b/crates/germ/Cargo.toml deleted file mode 100644 index 6e70f52..0000000 --- a/crates/germ/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[package] -name = "germ" -version = "0.3.8" -authors = ["Fuwn <[email protected]>"] -edition = "2021" -description = "The Ultimate Gemini Toolkit." -documentation = "https://docs.rs/germ" -readme = "../../README.md" -homepage = "https://github.com/gemrest/germ" -repository = "https://github.com/gemrest/germ" -license = "GPL-3.0-only" -keywords = ["gemini", "parser", "lexer", "markdown", "converter"] -categories = ["encoding"] - -[features] -ast = [] -convert = ["ast"] -default = ["ast", "convert", "meta", "request"] -macros = ["ast", "convert", "germ-macros-impl"] -meta = [] -request = ["rustls", "url", "anyhow"] -quick = [] -sync = ["tokio", "tokio-rustls"] - -[dependencies] -anyhow = { version = "1.0.70", optional = true } # `Result` -germ-macros-impl = { path = "../germ-macros-impl", version = "0.1.0", optional = true } # Germ's Macro Implementations -rustls = { version = "0.21.0", features = [ - "dangerous_configuration" -], optional = true } # TLS -tokio-rustls = { version = "0.24.0", optional = true } # Non-blocking TLS -tokio = { version = "1.27.0", optional = true, default-features = false, features = ["net", "io-util", "rt-multi-thread", "macros"] } # Non-blocking I/O -url = { version = "2.3.1", optional = true } # URL Validation diff --git a/crates/germ/examples/ast.rs b/examples/ast.rs index 884bd91..884bd91 100644 --- a/crates/germ/examples/ast.rs +++ b/examples/ast.rs diff --git a/crates/germ/examples/ast_to_gemtext.rs b/examples/ast_to_gemtext.rs index 5ceef21..5ceef21 100644 --- a/crates/germ/examples/ast_to_gemtext.rs +++ b/examples/ast_to_gemtext.rs diff --git a/crates/germ/examples/async_request.rs b/examples/async_request.rs index 604d6d4..604d6d4 100644 --- a/crates/germ/examples/async_request.rs +++ b/examples/async_request.rs diff --git a/crates/germ/examples/convert.html b/examples/convert.html index cdfde66..cdfde66 100644 --- a/crates/germ/examples/convert.html +++ b/examples/convert.html diff --git a/crates/germ/examples/convert.md b/examples/convert.md index ea553ee..ea553ee 100644 --- a/crates/germ/examples/convert.md +++ b/examples/convert.md diff --git a/crates/germ/examples/html.rs b/examples/html.rs index 8dfe034..541c01e 100644 --- a/crates/germ/examples/html.rs +++ b/examples/html.rs @@ -47,7 +47,7 @@ That was a link without text."#; fn main() { std::fs::write( - "crates/germ/examples/convert.html", + "examples/convert.html", germ::convert::from_string(EXAMPLE_GEMTEXT, &germ::convert::Target::HTML), ) .expect("could not write to file"); diff --git a/crates/germ/examples/markdown.rs b/examples/markdown.rs index bb3610b..c14cdc5 100644 --- a/crates/germ/examples/markdown.rs +++ b/examples/markdown.rs @@ -47,7 +47,7 @@ That was a link without text."#; fn main() { std::fs::write( - "crates/germ/examples/convert.md", + "examples/convert.md", germ::convert::from_string( EXAMPLE_GEMTEXT, &germ::convert::Target::Markdown, diff --git a/crates/germ/examples/meta.rs b/examples/meta.rs index a9f4077..a9f4077 100644 --- a/crates/germ/examples/meta.rs +++ b/examples/meta.rs diff --git a/crates/germ/examples/request.rs b/examples/request.rs index e33710f..e33710f 100644 --- a/crates/germ/examples/request.rs +++ b/examples/request.rs diff --git a/crates/germ/examples/request_to_gemtext_from_ast.rs b/examples/request_to_gemtext_from_ast.rs index 174abcf..174abcf 100644 --- a/crates/germ/examples/request_to_gemtext_from_ast.rs +++ b/examples/request_to_gemtext_from_ast.rs diff --git a/crates/germ/src/ast.rs b/src/ast.rs index 8c00b52..8c00b52 100644 --- a/crates/germ/src/ast.rs +++ b/src/ast.rs diff --git a/crates/germ/src/ast/container.rs b/src/ast/container.rs index acb8894..acb8894 100644 --- a/crates/germ/src/ast/container.rs +++ b/src/ast/container.rs diff --git a/crates/germ/src/ast/macros.rs b/src/ast/macros.rs index c2e5a85..037766b 100644 --- a/crates/germ/src/ast/macros.rs +++ b/src/ast/macros.rs @@ -28,23 +28,9 @@ /// // account for that. /// format!("{}\n", "=> / A link!"), /// ); -/// -/// /// Using raw Gemtext -/// assert_eq!( -/// germ::gemini_to_ast! { -/// => / A link! -/// => / Another link! -/// } -/// .to_gemtext(), -/// format!("{}\n", "=> / A link!\n=> / Another link!"), -/// ); -/// ``` #[macro_export] macro_rules! gemini_to_ast { ($gemini:expr) => { germ::ast::Ast::from_string($gemini) }; - ($($gemini:tt)*) => { - germ::ast::Ast::from_string(germ_macros_impl::gemini_to_tt!($($gemini)*)); - }; } diff --git a/crates/germ/src/ast/node.rs b/src/ast/node.rs index e80ef84..e80ef84 100644 --- a/crates/germ/src/ast/node.rs +++ b/src/ast/node.rs diff --git a/crates/germ/src/convert.rs b/src/convert.rs index 22329d0..22329d0 100644 --- a/crates/germ/src/convert.rs +++ b/src/convert.rs diff --git a/crates/germ/src/convert/html.rs b/src/convert/html.rs index 581cbab..581cbab 100644 --- a/crates/germ/src/convert/html.rs +++ b/src/convert/html.rs diff --git a/crates/germ/src/convert/macros.rs b/src/convert/macros.rs index ca29050..696c341 100644 --- a/crates/germ/src/convert/macros.rs +++ b/src/convert/macros.rs @@ -26,13 +26,6 @@ /// germ::gemini_to_html!("=> /to hello !"), /// "<a href=\"/to\">hello !</a><br>", /// ); -/// -/// // Using raw Gemtext -/// assert_eq!( -/// germ::gemini_to_html! { => /to hello ! }, -/// "<a href=\"/to\">hello !</a><br>", -/// ); -/// ``` #[macro_export] macro_rules! gemini_to_html { ($gemini:expr) => { @@ -59,10 +52,6 @@ macro_rules! gemini_to_html { /// germ::gemini_to_md!("=> /to hello !"), /// "[hello !](/to)\n", /// ); -/// -/// // Using raw Gemtext -/// assert_eq!(germ::gemini_to_md! { => /to hello ! }, "[hello !](/to)\n",); -/// ``` #[macro_export] macro_rules! gemini_to_md { ($gemini:expr) => { diff --git a/crates/germ/src/convert/markdown.rs b/src/convert/markdown.rs index 3401940..3401940 100644 --- a/crates/germ/src/convert/markdown.rs +++ b/src/convert/markdown.rs diff --git a/crates/germ/src/lib.rs b/src/lib.rs index 6bdebcc..6bdebcc 100644 --- a/crates/germ/src/lib.rs +++ b/src/lib.rs diff --git a/crates/germ/src/meta.rs b/src/meta.rs index 2a210a0..2a210a0 100644 --- a/crates/germ/src/meta.rs +++ b/src/meta.rs diff --git a/crates/germ/src/quick.rs b/src/quick.rs index 6bc5913..6bc5913 100644 --- a/crates/germ/src/quick.rs +++ b/src/quick.rs diff --git a/crates/germ/src/request.rs b/src/request.rs index 2c7c273..2c7c273 100644 --- a/crates/germ/src/request.rs +++ b/src/request.rs diff --git a/crates/germ/src/request/response.rs b/src/request/response.rs index 4c822e1..4c822e1 100644 --- a/crates/germ/src/request/response.rs +++ b/src/request/response.rs diff --git a/crates/germ/src/request/status.rs b/src/request/status.rs index c18f171..c18f171 100644 --- a/crates/germ/src/request/status.rs +++ b/src/request/status.rs diff --git a/crates/germ/src/request/sync.rs b/src/request/sync.rs index 68c8a0f..68c8a0f 100644 --- a/crates/germ/src/request/sync.rs +++ b/src/request/sync.rs diff --git a/crates/germ/src/request/verifier.rs b/src/request/verifier.rs index b0120bd..b0120bd 100644 --- a/crates/germ/src/request/verifier.rs +++ b/src/request/verifier.rs diff --git a/crates/germ/tests/ast.rs b/tests/ast.rs index c91d4b7..7c6dc36 100644 --- a/crates/germ/tests/ast.rs +++ b/tests/ast.rs @@ -116,16 +116,4 @@ That was a link without text."#; format!("{}\n", EXAMPLE_GEMTEXT), ); } - - #[test] - fn gemtext_to_ast_then_ast_to_gemtext_macro_block() { - assert_eq!( - germ::gemini_to_ast! { - => / A link! - => / Another link! - } - .to_gemtext(), - format!("{}\n", "=> / A link!\n=> / Another link!"), - ); - } } diff --git a/crates/germ/tests/convert.rs b/tests/convert.rs index de1baf2..aad7ac4 100644 --- a/crates/germ/tests/convert.rs +++ b/tests/convert.rs @@ -46,14 +46,6 @@ mod test { } #[test] - fn convert_from_string_to_html_single_link_macro_block() { - assert_eq!( - gemini_to_html! { => /to hello ! }, - "<a href=\"/to\">hello !</a><br>", - ); - } - - #[test] fn convert_from_string_to_markdown_single_line() { assert_eq!(from_string("hi", &Target::Markdown), "hi\n",); } @@ -75,9 +67,4 @@ mod test { fn convert_from_string_to_markdown_single_macro_expression() { assert_eq!(gemini_to_md!("=> /to hello !"), "[hello !](/to)\n",); } - - #[test] - fn convert_from_string_to_markdown_single_macro_block() { - assert_eq!(gemini_to_md! { => /to hello ! }, "[hello !](/to)\n",); - } } diff --git a/crates/germ/tests/meta.rs b/tests/meta.rs index 70c8adc..70c8adc 100644 --- a/crates/germ/tests/meta.rs +++ b/tests/meta.rs diff --git a/crates/germ/tests/quick.rs b/tests/quick.rs index 255acd9..255acd9 100644 --- a/crates/germ/tests/quick.rs +++ b/tests/quick.rs diff --git a/crates/germ/tests/status.rs b/tests/status.rs index 51f3f66..51f3f66 100644 --- a/crates/germ/tests/status.rs +++ b/tests/status.rs |