diff options
author | Nadrieril Feneanar | 2019-12-22 00:48:35 +0000 |
---|---|---|
committer | GitHub | 2019-12-22 00:48:35 +0000 |
commit | 06e75c919d999c310f8ca1c151c6a5ad6918ca08 (patch) | |
tree | 849a54821e08c78cbff4965e1a268e050466fa6c /dhall | |
parent | ce74f996808ae84b4967040f3441e1bbba31f506 (diff) | |
parent | 139daf4da23c87366d920cea2775afe11cce7be7 (diff) |
Merge pull request #122 from Nadrieril/publish
Publish to crates.io
Diffstat (limited to '')
-rw-r--r-- | dhall/.gitignore | 1 | ||||
-rw-r--r-- | dhall/Cargo.toml | 12 | ||||
-rw-r--r-- | dhall/README.md | 10 | ||||
-rw-r--r-- | dhall/build.rs | 28 | ||||
-rw-r--r-- | dhall/src/lib.rs | 1 | ||||
-rw-r--r-- | dhall/src/syntax/text/parser.rs | 12 | ||||
-rw-r--r-- | dhall_proc_macros/Cargo.toml | 7 | ||||
-rw-r--r-- | dhall_proc_macros/README.md | 7 | ||||
-rw-r--r-- | dhall_proc_macros/src/lib.rs | 1 |
9 files changed, 67 insertions, 12 deletions
diff --git a/dhall/.gitignore b/dhall/.gitignore deleted file mode 100644 index 8a0bac6..0000000 --- a/dhall/.gitignore +++ /dev/null @@ -1 +0,0 @@ -src/dhall.pest diff --git a/dhall/Cargo.toml b/dhall/Cargo.toml index a93153d..34cf444 100644 --- a/dhall/Cargo.toml +++ b/dhall/Cargo.toml @@ -1,8 +1,11 @@ [package] name = "dhall" -version = "0.1.0" +version = "0.1.1" # remember to update html_root_url authors = ["NanoTech <nanotech@nanotechcorp.net>", "Nadrieril <nadrieril@users.noreply.github.com>"] license = "BSD-2-Clause" +description = "Implementation of the Dhall configuration language" +readme = "README.md" +repository = "https://github.com/Nadrieril/dhall-rust" edition = "2018" build = "build.rs" @@ -12,9 +15,8 @@ hex = "0.3.2" lazy_static = "1.4.0" percent-encoding = "2.1.0" pest = "2.1" -# pest_consume = { path = "../../pest_consume/pest_consume" } pest_consume = "1.0" -serde = { version = "1.0" } +serde = "1.0" serde_cbor = "0.9.0" smallvec = "1.0.0" take_mut = "0.2.2" @@ -24,6 +26,8 @@ pretty_assertions = "0.6.1" [build-dependencies] walkdir = "2" -abnf_to_pest = { version = "0.1.1", path = "../abnf_to_pest" } +abnf_to_pest = { version = "0.1.2", path = "../abnf_to_pest" } +pest_generator = "2.1" +quote = "1.0" diff --git a/dhall/README.md b/dhall/README.md new file mode 100644 index 0000000..82b3e6a --- /dev/null +++ b/dhall/README.md @@ -0,0 +1,10 @@ +# `dhall` + +Implementation of the Dhall configuration language. +This is an internal crate used for [`serde_dhall`], you probably want to use +that instead. + +The API is very unstable and does not respect semver; +use at your own risk. + +[`serde_dhall`]: https://docs.rs/serde_dhall diff --git a/dhall/build.rs b/dhall/build.rs index 50f423e..3021f03 100644 --- a/dhall/build.rs +++ b/dhall/build.rs @@ -408,9 +408,10 @@ fn generate_tests() -> std::io::Result<()> { } fn convert_abnf_to_pest() -> std::io::Result<()> { + let out_dir = env::var("OUT_DIR").unwrap(); let abnf_path = "src/dhall.abnf"; let visibility_path = "src/dhall.pest.visibility"; - let pest_path = "src/dhall.pest"; + let grammar_path = Path::new(&out_dir).join("dhall.pest"); println!("cargo:rerun-if-changed={}", abnf_path); println!("cargo:rerun-if-changed={}", visibility_path); @@ -427,7 +428,7 @@ fn convert_abnf_to_pest() -> std::io::Result<()> { } } - let mut file = File::create(pest_path)?; + let mut file = File::create(grammar_path)?; writeln!(&mut file, "// AUTO-GENERATED FILE. See build.rs.")?; // TODO: this is a cheat; properly support RFC3986 URLs instead @@ -493,8 +494,31 @@ fn convert_abnf_to_pest() -> std::io::Result<()> { Ok(()) } +// Generate pest parser manually becaue otherwise we'd need to modify something outside of +// OUT_DIR and that's forbidden by docs.rs. +fn generate_pest_parser() -> std::io::Result<()> { + let out_dir = env::var("OUT_DIR").unwrap(); + let grammar_path = Path::new(&out_dir).join("dhall.pest"); + let grammar_path = grammar_path.to_str(); + let output_path = Path::new(&out_dir).join("dhall_parser.rs"); + + let pest = quote::quote!( + #[grammar = #grammar_path] + struct DhallParser; + ); + let derived = pest_generator::derive_parser(pest, false); + let file_contents = quote::quote!( + struct DhallParser; + #derived + ); + + let mut file = File::create(output_path)?; + writeln!(file, "{}", file_contents) +} + fn main() -> std::io::Result<()> { convert_abnf_to_pest()?; + generate_pest_parser()?; generate_tests()?; Ok(()) } diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs index 12660b4..dfa06e7 100644 --- a/dhall/src/lib.rs +++ b/dhall/src/lib.rs @@ -1,3 +1,4 @@ +#![doc(html_root_url = "https://docs.rs/dhall/0.1.1")] #![feature(trace_macros)] #![feature(slice_patterns)] #![feature(never_type)] diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs index 90cb4b1..832472b 100644 --- a/dhall/src/syntax/text/parser.rs +++ b/dhall/src/syntax/text/parser.rs @@ -156,9 +156,15 @@ lazy_static::lazy_static! { }; } -#[derive(Parser)] -#[grammar = "dhall.pest"] -struct DhallParser; +// Generate pest parser manually becaue otherwise we'd need to modify something outside of OUT_DIR +// and that's forbidden by docs.rs. +// This is equivalent to: +// ``` +// #[derive(Parser) +// #[grammar = "..."] +// struct DhallParser; +// ``` +include!(concat!(env!("OUT_DIR"), "/dhall_parser.rs")); #[pest_consume::parser(parser = DhallParser, rule = Rule)] impl DhallParser { diff --git a/dhall_proc_macros/Cargo.toml b/dhall_proc_macros/Cargo.toml index b641a39..ef8ae6c 100644 --- a/dhall_proc_macros/Cargo.toml +++ b/dhall_proc_macros/Cargo.toml @@ -1,8 +1,11 @@ [package] name = "dhall_proc_macros" -version = "0.1.0" +version = "0.1.0" # remember to update html_root_url authors = ["Nadrieril <nadrieril@users.noreply.github.com>"] license = "BSD-2-Clause" +description = "Macros for dhall" +readme = "README.md" +repository = "https://github.com/Nadrieril/dhall-rust" edition = "2018" [lib] @@ -13,4 +16,4 @@ doctest = false itertools = "0.8.0" quote = "1.0.2" proc-macro2 = "1.0.2" -syn = { version = "1.0.5", features = ["full", "extra-traits"] } +syn = "1.0.5" diff --git a/dhall_proc_macros/README.md b/dhall_proc_macros/README.md new file mode 100644 index 0000000..9f512c6 --- /dev/null +++ b/dhall_proc_macros/README.md @@ -0,0 +1,7 @@ +# `dhall_proc_macros` + +This is an internal crate used for [`serde_dhall`], you probably want to use +that instead. + +[`serde_dhall`]: https://docs.rs/serde_dhall + diff --git a/dhall_proc_macros/src/lib.rs b/dhall_proc_macros/src/lib.rs index 5304429..ce2dcdb 100644 --- a/dhall_proc_macros/src/lib.rs +++ b/dhall_proc_macros/src/lib.rs @@ -1,3 +1,4 @@ +#![doc(html_root_url = "https://docs.rs/dhall_proc_macros/0.1.0")] //! This crate contains the code-generation primitives for the [dhall-rust][dhall-rust] crate. //! This is highly unstable and breaks regularly; use at your own risk. //! |