From ed34e2bf60e61eec7dac11e065be9d71df49c491 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Mon, 24 Jun 2024 04:46:50 +0200 Subject: [PATCH] Switch pub to super only --- Cargo.toml | 2 -- src/makepdf.rs | 38 ++++++++++++-------- src/makepdf_functions.rs | 20 +++++------ src/makepdf_misc.rs | 8 ++--- src/makepdf_structs.rs | 75 +++++++++++++++++++--------------------- src/stat_algo.rs | 6 ++-- src/stat_io.rs | 68 ++++++++++++++++++------------------ src/stat_structs.rs | 10 +++--- src/stats.rs | 8 ++--- src/table_structs.rs | 38 ++++++++++---------- src/table_types.rs | 14 ++++---- src/tablegen.rs | 2 +- 12 files changed, 146 insertions(+), 143 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 02c329b..d5be1d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,6 @@ console = "0.15.8" csv = "1.3.0" debug_print = "1.0.0" dynfmt = { version = "0.1.5", features = ["curly"] } -enum_dispatch = "0.3.13" -futures = "0.3.30" glob = "0.3.1" indexmap = "2.2.6" indicatif = "0.17.8" diff --git a/src/makepdf.rs b/src/makepdf.rs index f911966..97c96f1 100644 --- a/src/makepdf.rs +++ b/src/makepdf.rs @@ -30,41 +30,41 @@ use crate::Config; #[derive(Args, Debug, Clone)] // #[command(after_)] /// The configuration struct for the PdfMaker -pub(crate) struct MakeConfig { +pub(super) struct MakeConfig { /// The filename to compile - pub(crate) filename: String, + pub(super) filename: String, /// Special target #[arg(short, long, help = format!("Build with a special target. {}", HELP_BUILD_TARGET_LIST.as_str()))] - pub(crate) target: Option, + pub(super) target: Option, /// The verbosity level #[arg(short, long, default_value = "warning", help = format!("The verbosity level. {}",HELP_VERBOSITY_LEVEL.as_str()))] - pub(crate) verbosity: VerboseLevel, + pub(super) verbosity: VerboseLevel, /// The progress bar style #[arg(short, long, default_value = "class", help = format!("The progress bar style. {}",HELP_BLOCK_SELECTION.as_str()))] - pub(crate) pbar: String, + pub(super) pbar: String, /// switch to non interactive mode #[arg(short = 'N', long, default_value_t = false)] - pub(crate) non_interactive: bool, + pub(super) non_interactive: bool, /// Select only these targets #[arg(short, long, value_name = "FILE", group = "select")] - pub(crate) only: Vec, + pub(super) only: Vec, /// Deselect these targets #[arg(short, long, value_name = "FILE", group = "select")] - pub(crate) no: Vec, + pub(super) no: Vec, /// Wether to add the initial and final context #[arg(short = 'C', long, action = clap::ArgAction::SetFalse)] - pub(crate) no_context: bool, + pub(super) no_context: bool, } /// Make a pdf spawning a subprocess -pub(crate) fn make_pdf(args: &MakeConfig, _config: &Config) -> Result<()> { +pub(super) fn make_pdf(args: &MakeConfig, _config: &Config) -> Result<()> { let Ok(Some(_)) = BLOCK_PROGRESSION.get_key(&args.pbar) else { panic!( "Progressbar {} doesn't exists. Use one of the following {:?}", @@ -105,6 +105,7 @@ async fn launch_subprocess( let mut status = Status::zero(); let started = Instant::now(); + let mut last_total_duration = Duration::from_secs(0); let mut current_run = BuildInfo::new(args); let last_run = BuildInfo::load(args); @@ -179,8 +180,16 @@ async fn launch_subprocess( continue; } }; - checkline(args, s, &mut status, &mut current_run, &started, &pb) - .expect("Error while checking line"); + checkline( + args, + s, + &mut status, + &mut current_run, + &started, + &pb, + &mut last_total_duration, + ) + .expect("Error while checking line"); } else { break; } @@ -201,6 +210,7 @@ fn checkline( run: &mut BuildInfo, started: &Instant, pb: &ProgressBar, + last_total_duration: &mut Duration, ) -> Result<()> { // Match the line to guess what is happening let mut lex = LineType::lexer(orginal_line); @@ -217,8 +227,8 @@ fn checkline( // LineType::StartingSequence => todo!(), // LineType::EndSequence => todo!(), // LineType::MPSConverter => todo!(), - ref a @ LineType::Chapter(ref chap) => { - run.add_lap(started, chap); + ref a @ LineType::Chapter(_) => { + run.add_lap(started, last_total_duration); a } LineType::MissingReferencePrs => &LineType::MissingReference(orginal_line.to_string()), diff --git a/src/makepdf_functions.rs b/src/makepdf_functions.rs index a5843c0..3b0b7a7 100644 --- a/src/makepdf_functions.rs +++ b/src/makepdf_functions.rs @@ -25,7 +25,7 @@ static CHAPT_REGEX: LazyLock = LazyLock::new(|| Regex::new(r#" *\\chapter\*?\{"?([^\}]+)\}"?"#).unwrap()); /// The info returned by a make_file -pub(crate) struct BuilderParseResult { +pub(super) struct BuilderParseResult { /// The new name pub(super) new_name: String, @@ -34,7 +34,7 @@ pub(crate) struct BuilderParseResult { } /// Make the (new/purged) target file and return (name,chapter_list) -pub(crate) fn make_file(args: &MakeConfig) -> BuilderParseResult { +pub(super) fn make_file(args: &MakeConfig) -> BuilderParseResult { let path = target_name(&args.filename); let m = make_ignore_targets(args); let mut f = File::open(&args.filename).expect("The file doesn't exist"); @@ -127,7 +127,7 @@ fn add_checker(check: &str, dict_entries: &IndexMap, args: &Make false } /// List all chapters targetable by ignore and only -pub(crate) fn make_list(args: &MakeConfig) { +pub(super) fn make_list(args: &MakeConfig) { let m = make_ignore_targets(args); println!("The ignore targets are the following:"); println!("{:#?}", m); @@ -150,7 +150,7 @@ fn make_ignore_targets(args: &MakeConfig) -> IndexMap { } /// Create a target name, by appending _build to it -pub(crate) fn target_name(target: &str) -> PathBuf { +pub(super) fn target_name(target: &str) -> PathBuf { let target = Path::new(target); let mut target_oss = target.file_stem().unwrap().to_owned(); target_oss.push("_build.tex"); @@ -158,7 +158,7 @@ pub(crate) fn target_name(target: &str) -> PathBuf { } /// Create a target suffix and by append _build -pub(crate) fn target_pref(target: &str) -> String { +pub(super) fn target_pref(target: &str) -> String { let target = Path::new(target); let target_oss = target.file_stem().unwrap().to_owned(); let v = format!("{:?}", target_oss); @@ -166,7 +166,7 @@ pub(crate) fn target_pref(target: &str) -> String { } /// Try to add a simplified entry to a list -pub(crate) fn simplify_add( +pub(super) fn simplify_add( entry: String, dict_entries: &mut IndexMap, ) -> Result<()> { @@ -211,7 +211,7 @@ pub(crate) fn simplify_add( } /// Make the glossaries -pub(crate) fn make_glossaries(args: &MakeConfig) { +pub(super) fn make_glossaries(args: &MakeConfig) { use std::str; // let name = format!("{:?}", target_name(&args.filename)); // let name = &name[1..name.len() - 1]; @@ -240,17 +240,17 @@ pub(crate) fn make_glossaries(args: &MakeConfig) { } /// Make the working directory clean, by eliminating all temporary files -pub(crate) fn make_clean(args: &MakeConfig) { +pub(super) fn make_clean(args: &MakeConfig) { let _ = args; // let target = format!("{:?}", Path::new(&args.filename).file_stem().unwrap()); let target = target_pref(&args.filename); let list_suff = [ - ".aux", ".glg", ".glo", ".gls", ".ist", ".log", ".out", ".toc", ".pdf", + ".aux", ".glg", ".glo", ".gls", ".ist", ".log", ".out", ".toc", ".pdf", ".dvi", ".fls", ]; let mut cmd = Command::new("rm"); for s in list_suff { // The most ghetto *** I've done so far - cmd.arg(format!("{}{}", &target, s)); + // cmd.arg(format!("{}{}", &target, s)); cmd.arg(format!("{}_build{}", &target, s)); } cmd.arg(format!("{}_build{}", &target, ".tex")); diff --git a/src/makepdf_misc.rs b/src/makepdf_misc.rs index bdc27aa..3f42e03 100644 --- a/src/makepdf_misc.rs +++ b/src/makepdf_misc.rs @@ -24,21 +24,21 @@ static STR_TO_BUILD_TARGET: phf::Map<&'static str, MakeTargets> = phf_map! { }; /// List all blocktype -pub(crate) static HELP_BLOCK_SELECTION: LazyLock = LazyLock::new(|| { +pub(super) static HELP_BLOCK_SELECTION: LazyLock = LazyLock::new(|| { let mut targets = BLOCK_PROGRESSION.keys().collect::>(); targets.sort(); format!("{:?}", targets) }); /// List all targets -pub(crate) static HELP_VERBOSITY_LEVEL: LazyLock = LazyLock::new(|| { +pub(super) static HELP_VERBOSITY_LEVEL: LazyLock = LazyLock::new(|| { let mut targets = STR_TO_VERBOSITY.values().collect::>(); targets.sort(); format!("{:?}", targets) }); /// List all targets -pub(crate) static HELP_BUILD_TARGET_LIST: LazyLock = LazyLock::new(|| { +pub(super) static HELP_BUILD_TARGET_LIST: LazyLock = LazyLock::new(|| { let targets = STR_TO_BUILD_TARGET.values().collect::>(); format!("{:?}", targets) }); @@ -70,7 +70,7 @@ impl From<&str> for MakeTargets { } /// All progress bar styles -pub(crate) static BLOCK_PROGRESSION: LazyLock> = LazyLock::new(|| { +pub(super) static BLOCK_PROGRESSION: LazyLock> = LazyLock::new(|| { let mut m = HashMap::new(); m.insert("class".to_string(), "#>-".to_string()); m.insert("cargo".to_string(), "#> ".to_string()); diff --git a/src/makepdf_structs.rs b/src/makepdf_structs.rs index 3df751d..2ef7383 100644 --- a/src/makepdf_structs.rs +++ b/src/makepdf_structs.rs @@ -13,49 +13,49 @@ use console::Style; use crate::{makepdf::MakeConfig, makepdf_functions::BuilderParseResult}; /// Color Scheme for the NORMAL level -pub(crate) static COL_NORMAL: LazyLock