Update preserves-schema-rs docs

This commit is contained in:
Tony Garnock-Jones 2023-10-27 14:11:38 +02:00
parent af5de5b836
commit e31f834d72
2 changed files with 10 additions and 8 deletions

View File

@ -14,7 +14,7 @@ inputs.
You will usually not need to use the `preserves-schema-rs`
command-line program. Instead, access the preserves-schema compiler
API from your `build.rs`. The following example is taken from
[`build.rs` for the `preserves-path` crate](https://gitlab.com/preserves/preserves/-/blob/18ac9168996026073ee16164fce108054b2a0ed7/implementations/rust/preserves-path/build.rs):
[`build.rs` for the `preserves-path` crate](https://gitlab.com/preserves/preserves/-/blob/af5de5b836ffc51999db93797d1995ff677cf6f8/implementations/rust/preserves-path/build.rs):
use preserves_schema::compiler::*;
@ -30,14 +30,14 @@ API from your `build.rs`. The following example is taken from
let mut c = CompilerConfig::new(gen_dir, "crate::schemas".to_owned());
let inputs = expand_inputs(&vec!["path.bin".to_owned()])?;
c.load_schemas_and_bundles(&inputs)?;
c.load_schemas_and_bundles(&inputs, &vec![])?;
compile(&c)
}
This approach also requires an `include!` from your main, hand-written
source tree. The following is a snippet from
[`preserves-path/src/lib.rs`](https://gitlab.com/preserves/preserves/-/blob/18ac9168996026073ee16164fce108054b2a0ed7/implementations/rust/preserves-path/src/lib.rs):
[`preserves-path/src/lib.rs`](https://gitlab.com/preserves/preserves/-/blob/af5de5b836ffc51999db93797d1995ff677cf6f8/implementations/rust/preserves-path/src/lib.rs):
pub mod schemas {
include!(concat!(env!("OUT_DIR"), "/src/schemas/mod.rs"));
@ -52,20 +52,22 @@ Then, `cargo install preserves-schema`.
## Usage
preserves-schema 1.0.0
preserves-schema 3.990.2
USAGE:
preserves-schema-rs [OPTIONS] --output-dir <output-dir> --prefix <prefix> [--] [input-glob]...
preserves-schema-rs [FLAGS] [OPTIONS] --output-dir <output-dir> --prefix <prefix> [--] [input-glob]...
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
-h, --help Prints help information
--rustfmt-skip
-V, --version Prints version information
OPTIONS:
--module <module>...
-o, --output-dir <output-dir>
-p, --prefix <prefix>
--support-crate <support-crate>
--xref <xref>...
ARGS:
<input-glob>...

View File

@ -19,7 +19,7 @@
//! let mut c = CompilerConfig::new(gen_dir, "crate::schemas".to_owned());
//!
//! let inputs = expand_inputs(&vec![PATH_TO_PRB_FILE.to_owned()])?;
//! c.load_schemas_and_bundles(&inputs)?;
//! c.load_schemas_and_bundles(&inputs, &vec![])?;
//! compile(&c)
//! }
//! ```