Skip to content

Commit

Permalink
cargo_auto_lib 1.1.23 tidy HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
luciano_bestia committed Feb 18, 2024
1 parent be855a5 commit 6ec60f3
Show file tree
Hide file tree
Showing 19 changed files with 54 additions and 276 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-auto"
version = "2024.209.504"
version = "2024.218.2136"
authors = ["bestia.dev"]
homepage = "https://bestia.dev"
edition = "2021"
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[//]: # (auto_cargo_toml_to_md start)

**cargo-auto - automation tasks written in Rust language for the build process of Rust projects**
***version: 2024.209.504 date: 2024-02-18 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/bestia-dev/cargo-auto)***
***version: 2024.218.2136 date: 2024-02-18 author: [bestia.dev](https://bestia.dev) repository: [GitHub](https://github.com/bestia-dev/cargo-auto)***

[//]: # (auto_cargo_toml_to_md end)

Expand All @@ -20,11 +20,11 @@
![Hits](https://bestia.dev/webpage_hit_counter/get_svg_image/959103982.svg)

[//]: # (auto_lines_of_code start)
[![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-9172-green.svg)](https://github.com/bestia-dev/cargo-auto/)
[![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-219-blue.svg)](https://github.com/bestia-dev/cargo-auto/)
[![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-427-purple.svg)](https://github.com/bestia-dev/cargo-auto/)
[![Lines in Rust code](https://img.shields.io/badge/Lines_in_Rust-9157-green.svg)](https://github.com/bestia-dev/cargo-auto/)
[![Lines in Doc comments](https://img.shields.io/badge/Lines_in_Doc_comments-216-blue.svg)](https://github.com/bestia-dev/cargo-auto/)
[![Lines in Comments](https://img.shields.io/badge/Lines_in_comments-371-purple.svg)](https://github.com/bestia-dev/cargo-auto/)
[![Lines in examples](https://img.shields.io/badge/Lines_in_examples-0-yellow.svg)](https://github.com/bestia-dev/cargo-auto/)
[![Lines in tests](https://img.shields.io/badge/Lines_in_tests-6334-orange.svg)](https://github.com/bestia-dev/cargo-auto/)
[![Lines in tests](https://img.shields.io/badge/Lines_in_tests-6310-orange.svg)](https://github.com/bestia-dev/cargo-auto/)

[//]: # (auto_lines_of_code end)

Expand Down
4 changes: 2 additions & 2 deletions automation_tasks_rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion automation_tasks_rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "cargo auto - automation tasks written in Rust language"
publish = false

[dependencies]
cargo_auto_lib = "1.1.2"
cargo_auto_lib = "1.1.23"
base64ct = {version = "1.6.0", features = ["alloc"] }
tokio = {version = "1.36.0", features = ["rt","rt-multi-thread","fs"]}
cargo_auto_github_lib = "0.1.24"
28 changes: 2 additions & 26 deletions automation_tasks_rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,32 +230,8 @@ fn task_doc() {
"echo \"<meta http-equiv=\\\"refresh\\\" content=\\\"0; url={}/index.html\\\" />\" > docs/index.html",
cargo_toml.package_name().replace("-", "_")
));

// region: tidy HTML
// The HTML generated by `cargo doc` is ugly and difficult to `git diff`
// tidy HTML is a HTML checker and formatter installed on most Linuxes.
// If it is not installed run: `sudo apt install -y tidy`
// From the bash you can install it inside the podman container like this:
// `podman exec --user root rust_dev_vscode_cnt apt install -y tidy`
//
// First we check if tidy is installed on the system
// Run a dummy command and write the std/err output to tidy_warnings.txt.
// The command `2>` will overwrite the file and not append like `2>>`.
cl::run_shell_command("tidy xxx 2> docs/tidy_warnings.txt");
// Check if it contains `command not found`
let text = std::fs::read_to_string("docs/tidy_warnings.txt").unwrap();
// don't need this file anymore
cl::run_shell_command("rm -f docs/tidy_warnings.txt");
if !text.contains("command not found") {
// Use tidy HTML to format the docs/*.html files to be human readable and usable for git diff.
// Options: -m modify file, -q quiet suppress nonessential output, -w wrap at 160, -i indent 2 spaces
// The warnings and errors are appended to the file docs/tidy_warnings.txt
cl::run_shell_command(
r#"find ./docs -name '*.html' -type f -print -exec tidy -mq -w 160 -i 2 '{}' \; >> docs/tidy_warnings.txt 2>&1 "#
);
}
// endregion: tidy HTML

// pretty html
cl::auto_doc_tidy_html().unwrap();
cl::run_shell_command("cargo fmt");
// message to help user with next move
println!(
Expand Down
35 changes: 7 additions & 28 deletions src/template_new_auto_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ description = "cargo auto - automation tasks written in Rust language"
publish = false
[dependencies]
cargo_auto_lib = "1.1.2"
cargo_auto_lib = "1.1.23"
"###,
});
vec_file.push(crate::FileItem{
Expand All @@ -141,6 +141,9 @@ use cargo_auto_lib::GREEN;
use cargo_auto_lib::RED;
use cargo_auto_lib::RESET;
use cargo_auto_lib::YELLOW;
// use cargo_auto_github_lib as cgl;
// region: library with basic automation tasks
fn main() {
Expand Down Expand Up @@ -312,39 +315,15 @@ fn task_doc() {
"echo \"<meta http-equiv=\\\"refresh\\\" content=\\\"0; url={}/index.html\\\" />\" > docs/index.html",
cargo_toml.package_name().replace("-", "_")
));
// region: tidy HTML
// The HTML generated by `cargo doc` is ugly and difficult to `git diff`
// tidy HTML is a HTML checker and formatter installed on most Linuxes.
// If it is not installed run: `sudo apt install -y tidy`
// From the bash you can install it inside the podman container like this:
// `podman exec --user root rust_dev_vscode_cnt apt install -y tidy`
//
// First we check if tidy is installed on the system
// Run a dummy command and write the std/err output to tidy_warnings.txt.
// The command `2>` will overwrite the file and not append like `2>>`.
cl::run_shell_command("tidy xxx 2> docs/tidy_warnings.txt");
// Check if it contains `command not found`
let text = std::fs::read_to_string("docs/tidy_warnings.txt").unwrap();
// don't need this file anymore
cl::run_shell_command("rm -f docs/tidy_warnings.txt");
if !text.contains("command not found") {
// Use tidy HTML to format the docs/*.html files to be human readable and usable for git diff.
// Options: -m modify file, -q quiet suppress nonessential output, -w wrap at 160, -i indent 2 spaces
// The warnings and errors are appended to the file docs/tidy_warnings.txt
cl::run_shell_command(
r#"find ./docs -name '*.html' -type f -print -exec tidy -mq -w 160 -i 2 '{}' \; >> docs/tidy_warnings.txt 2>&1 "#
);
}
// endregion: tidy HTML
// pretty html
cl::auto_doc_tidy_html().unwrap();
cl::run_shell_command("cargo fmt");
// message to help user with next move
println!(
r#"
{YELLOW}After `cargo auto doc`, check `docs/index.html`. If ok, then test the documentation code examples{RESET}
{GREEN}cargo auto test{RESET}
"#
}"#
);
}
Expand Down
46 changes: 9 additions & 37 deletions src/template_new_cli_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ pub fn get_vec_file() -> Vec<crate::FileItem> {
// region: files copied into strings by automation tasks
vec_file.push(crate::FileItem{
file_name :"README.md",
file_content : r###"
# cargo_auto_template_new_cli
file_content : r###"# cargo_auto_template_new_cli
[//]: # (auto_cargo_toml_to_md start)
Expand All @@ -64,7 +63,6 @@ pub fn get_vec_file() -> Vec<crate::FileItem> {
[//]: # (auto_lines_of_code end)
## Motivation
The first line I typed when I learned the Rust language was `cargo new hello`. It is extraordinary for learning Rust, but it is a rudimentary example, not really useful in practical life.
Expand Down Expand Up @@ -250,7 +248,6 @@ But I need also to drink. If you find my projects and tutorials helpful, please
You know the price of a beer in your local bar ;-) So I can drink a free beer for your health :-)
[Na zdravje!](https://translate.google.com/?hl=en&sl=sl&tl=en&text=Na%20zdravje&op=translate) [Alla salute!](https://dictionary.cambridge.org/dictionary/italian-english/alla-salute) [Prost!](https://dictionary.cambridge.org/dictionary/german-english/prost) [Nazdravlje!](https://matadornetwork.com/nights/how-to-say-cheers-in-50-languages/) 🍻
"###,
});
vec_file.push(crate::FileItem {
Expand Down Expand Up @@ -400,16 +397,14 @@ fn upper_greet_name(greet_name: &str) -> anyhow::Result<()> {
vec_file.push(crate::FileItem {
file_name: "src/lib.rs",
file_content: r###"// cargo_auto_template_new_cli/src/lib.rs
#![doc=include_str!("../README.md")]
// The `main.rs` has all the stdin and stdout.
// The `lib.rs` must be in/out agnostic. That is the responsibility of the `main.rs`
// The `lib.rs` does not have any real code. All the code is in modules in separate files.
// The `lib.rs` has just the list of modules, it publishes module's functions or class for the caller
// and it has some global stuff like the Error enum.
#![doc=include_str!("../README.md")]
// access to modules
mod hello_mod;
Expand Down Expand Up @@ -555,7 +550,7 @@ description = "cargo auto - automation tasks written in Rust language"
publish = false
[dependencies]
cargo_auto_lib = "1.1.2""###,
cargo_auto_lib = "1.1.23""###,
});
vec_file.push(crate::FileItem{
file_name :"automation_tasks_rs/src/main.rs",
Expand All @@ -570,9 +565,10 @@ use cargo_auto_lib::GREEN;
use cargo_auto_lib::RED;
use cargo_auto_lib::RESET;
use cargo_auto_lib::YELLOW;
// region: library with basic automation tasks
// use cargo_auto_github_lib::*;
// use cargo_auto_github_lib as cgl;
// region: library with basic automation tasks
fn main() {
cl::exit_if_not_run_in_rust_project_root_directory();
Expand Down Expand Up @@ -751,32 +747,8 @@ fn task_doc() {
"echo \"<meta http-equiv=\\\"refresh\\\" content=\\\"0; url={}/index.html\\\" />\" > docs/index.html",
cargo_toml.package_name().replace("-", "_")
));
// region: tidy HTML
// The HTML generated by `cargo doc` is ugly and difficult to `git diff`
// tidy HTML is a HTML checker and formatter installed on most Linuxes.
// If it is not installed run: `sudo apt install -y tidy`
// From the bash you can install it inside the podman container like this:
// `podman exec --user root rust_dev_vscode_cnt apt install -y tidy`
//
// First we check if tidy is installed on the system
// Run a dummy command and write the std/err output to tidy_warnings.txt.
// The command `2>` will overwrite the file and not append like `2>>`.
cl::run_shell_command("tidy xxx 2> docs/tidy_warnings.txt");
// Check if it contains `command not found`
let text = std::fs::read_to_string("docs/tidy_warnings.txt").unwrap();
// don't need this file anymore
cl::run_shell_command("rm -f docs/tidy_warnings.txt");
if !text.contains("command not found") {
// Use tidy HTML to format the docs/*.html files to be human readable and usable for git diff.
// Options: -m modify file, -q quiet suppress nonessential output, -w wrap at 160, -i indent 2 spaces
// The warnings and errors are appended to the file docs/tidy_warnings.txt
cl::run_shell_command(
r#"find ./docs -name '*.html' -type f -print -exec tidy -mq -w 160 -i 2 '{}' \; >> docs/tidy_warnings.txt 2>&1 "#
);
}
// endregion: tidy HTML
// pretty html
cl::auto_doc_tidy_html().unwrap();
cl::run_shell_command("cargo fmt");
// message to help user with next move
println!(
Expand Down
37 changes: 5 additions & 32 deletions src/template_new_pwa_wasm_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ pub fn get_vec_file() -> Vec<crate::FileItem> {
// region: files copied into strings by automation tasks
vec_file.push(crate::FileItem{
file_name :"README.md",
file_content : r###"
# rust_project_name
file_content : r###"# rust_project_name

[//]: # (auto_cargo_toml_to_md start)

Expand Down Expand Up @@ -346,7 +345,6 @@ So I can drink a free beer for your health :-)
[//github.com/bestia-dev](https://github.com/bestia-dev)
[//bestiadev.substack.com](https://bestiadev.substack.com)
[//youtube.com/@bestia-dev-tutorials](https://youtube.com/@bestia-dev-tutorials)

"###,
});
vec_file.push(crate::FileItem {
Expand All @@ -360,7 +358,7 @@ So I can drink a free beer for your health :-)
// but the new service worker will not be activated until all
// tabs with this webapp are closed.

const CACHE_NAME = '2024.209.504';
const CACHE_NAME = '2024.218.2135';

self.addEventListener('install', event => {
console.log('event install ', CACHE_NAME);
Expand Down Expand Up @@ -7957,7 +7955,6 @@ fn upper_greet_name(greet_name: &str) -> anyhow::Result<()> {
vec_file.push(crate::FileItem {
file_name: "src/lib.rs",
file_content: r###"// src/lib.rs

// This file has just the wasm_bindgen_start() function
// and calls into main_mod.rs.
// So the structure of the project modules can be similar to a binary CLI executable.
Expand Down Expand Up @@ -8050,7 +8047,7 @@ description = "cargo auto - automation tasks written in Rust language"
publish = false

[dependencies]
cargo_auto_lib = "1.1.2""###,
cargo_auto_lib = "1.1.23""###,
});
vec_file.push(crate::FileItem{
file_name :"automation_tasks_rs/src/main.rs",
Expand Down Expand Up @@ -8239,32 +8236,8 @@ fn task_doc() {
"echo \"<meta http-equiv=\\\"refresh\\\" content=\\\"0; url={}/index.html\\\" />\" > docs/index.html",
cargo_toml.package_name().replace("-", "_")
));

// region: tidy HTML
// The HTML generated by `cargo doc` is ugly and difficult to `git diff`
// tidy HTML is a HTML checker and formatter installed on most Linuxes.
// If it is not installed run: `sudo apt install -y tidy`
// From the bash you can install it inside the podman container like this:
// `podman exec --user root rust_dev_vscode_cnt apt install -y tidy`
//
// First we check if tidy is installed on the system
// Run a dummy command and write the std/err output to tidy_warnings.txt.
// The command `2>` will overwrite the file and not append like `2>>`.
cl::run_shell_command("tidy xxx 2> docs/tidy_warnings.txt");
// Check if it contains `command not found`
let text = std::fs::read_to_string("docs/tidy_warnings.txt").unwrap();
// don't need this file anymore
cl::run_shell_command("rm -f docs/tidy_warnings.txt");
if !text.contains("command not found") {
// Use tidy HTML to format the docs/*.html files to be human readable and usable for git diff.
// Options: -m modify file, -q quiet suppress nonessential output, -w wrap at 160, -i indent 2 spaces
// The warnings and errors are appended to the file docs/tidy_warnings.txt
cl::run_shell_command(
r#"find ./docs -name '*.html' -type f -print -exec tidy -mq -w 160 -i 2 '{}' \; >> docs/tidy_warnings.txt 2>&1 "#
);
}
// endregion: tidy HTML

// pretty html
cl::auto_doc_tidy_html().unwrap();
cl::run_shell_command("cargo fmt");
// message to help user with next move
println!(
Expand Down
Loading

0 comments on commit 6ec60f3

Please sign in to comment.