From 79e64869680f012cb282f75eb0f518b94cccebd0 Mon Sep 17 00:00:00 2001 From: Federico Igne Date: Fri, 30 Dec 2022 16:36:38 +0000 Subject: docs: update PDF manual --- README.md | 35 +++++++++++++++++++++++++---------- README.pdf | Bin 277696 -> 290388 bytes src/main.rs | 27 ++++++++++++++++++--------- 3 files changed, 43 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 25b3a44..88d4725 100644 --- a/README.md +++ b/README.md @@ -122,9 +122,11 @@ if !id.is_empty() { let entry = clss.contains(&String::from("entry")); let path = attrs .into_iter() - .find_map(|(k,p)| if k == "path" { Some(p.clone()) } else { None }); + .find_map(|(k,p)| + if k == "path" { Some(p.clone()) } else { None }); if entry || path.is_some() || PATH.is_match(id) { - let path = PathBuf::from(path.unwrap_or_default()).join(id); + let path = + PathBuf::from(path.unwrap_or_default()).join(id); if path.starts_with(&target) { Some(Key::Entry(path)) } else { @@ -189,7 +191,13 @@ An alternative way to compile the project is using Docker. Run the following from the root of the project without the need to install Rust locally. ```sh -docker run --rm --user "$(id -u)":"$(id -g)" -v "$PWD":/usr/src/pangler -w /usr/src/pangler rust:latest cargo build --release +docker run \ + --rm \ + --user "$(id -u)":"$(id -g)" \ + --volume "$PWD":/usr/src/pangler \ + --workdir /usr/src/pangler \ + rust:latest \ + cargo build --release ``` See the [official documentation](https://hub.docker.com/_/rust) for more information. @@ -279,8 +287,8 @@ By default `pangler` will generate all entry points gathered from the input file This behaviour can be overridden with the `-t/--target` flag. ```{#config_target .rust} -/// Limit entry points to those matching the provided prefix -#[clap(short, long, value_name = "PREFIX")] +/// Limit entry points to those matching the given prefix +#[clap(short, long, value_name="PREFIX")] target: Option, ``` @@ -315,7 +323,7 @@ If the output folder does not exists, *it will be created*. ```{#config_output .rust} /// Base output directory [default: './'] -#[clap(short, long, value_name = "PATH")] +#[clap(short, long, value_name="PATH")] output: Option, ``` @@ -326,7 +334,7 @@ By default, `pangler` will stop after 10 substitution iterations, but this param ```{#config_depth .rust} /// Maximum substitution depth -#[clap(short, long, default_value_t = 10, value_name = "N")] +#[clap(short, long, default_value_t=10, value_name="N")] depth: u32, ``` @@ -475,7 +483,9 @@ In case we reach the maximum allowed depth we truncate code block substitution a if current_depth < max_depth { let block = blocks .get(&Key::Macro(caps[2].to_string())) - .unwrap_or_else(|| panic!("Block \"{}\" not present", caps[2].to_string())) + .unwrap_or_else(|| panic!( + "Block \"{}\" not present", + caps[2].to_string())) .clone(); indent(block, caps[1].len()) } else { @@ -498,7 +508,9 @@ fn build( <> blocks .iter() - .filter_map(|(key,code)| { key.get_path().map(|k| (k,code)) }) + .filter_map(|(key,code)| { + key.get_path().map(|k| (k,code)) + }) .for_each(|(path,code)| { <> }) @@ -660,7 +672,10 @@ fn write_to_file( <> <> } else { - eprintln!("Absolute paths not supported: {}", path.display()) + eprintln!( + "Absolute paths not supported: {}", + path.display() + ) } Ok(()) } diff --git a/README.pdf b/README.pdf index c0637da..2cd624f 100644 Binary files a/README.pdf and b/README.pdf differ diff --git a/src/main.rs b/src/main.rs index acb08ad..44dab99 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,13 +21,13 @@ struct Config { #[clap(short, long)] list: bool, /// Maximum substitution depth - #[clap(short, long, default_value_t = 10, value_name = "N")] + #[clap(short, long, default_value_t=10, value_name="N")] depth: u32, /// Base output directory [default: './'] - #[clap(short, long, value_name = "PATH")] + #[clap(short, long, value_name="PATH")] output: Option, - /// Limit entry points to those matching the provided prefix - #[clap(short, long, value_name = "PREFIX")] + /// Limit entry points to those matching the given prefix + #[clap(short, long, value_name="PREFIX")] target: Option, /// Input files input: Vec, @@ -63,7 +63,9 @@ fn build( } blocks .iter() - .filter_map(|(key,code)| { key.get_path().map(|k| (k,code)) }) + .filter_map(|(key,code)| { + key.get_path().map(|k| (k,code)) + }) .for_each(|(path,code)| { let mut current_depth = 0; let mut code = code.clone(); @@ -73,7 +75,9 @@ fn build( if current_depth < max_depth { let block = blocks .get(&Key::Macro(caps[2].to_string())) - .unwrap_or_else(|| panic!("Block \"{}\" not present", caps[2].to_string())) + .unwrap_or_else(|| panic!( + "Block \"{}\" not present", + caps[2].to_string())) .clone(); indent(block, caps[1].len()) } else { @@ -125,7 +129,10 @@ fn write_to_file( fs::create_dir_all(path.parent().unwrap())?; fs::write(path, content)?; } else { - eprintln!("Absolute paths not supported: {}", path.display()) + eprintln!( + "Absolute paths not supported: {}", + path.display() + ) } Ok(()) } @@ -156,9 +163,11 @@ fn main() -> Result<()> { let entry = clss.contains(&String::from("entry")); let path = attrs .into_iter() - .find_map(|(k,p)| if k == "path" { Some(p.clone()) } else { None }); + .find_map(|(k,p)| + if k == "path" { Some(p.clone()) } else { None }); if entry || path.is_some() || PATH.is_match(id) { - let path = PathBuf::from(path.unwrap_or_default()).join(id); + let path = + PathBuf::from(path.unwrap_or_default()).join(id); if path.starts_with(&target) { Some(Key::Entry(path)) } else { -- cgit v1.2.3