mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-22 05:12:27 +00:00
01d571fc9e
* remove contributing guidelines duplicate `docs/contributing.md` is now auto generated * Commit Contributing Guidelines * core `xtask` functionality * almost there * write panic * almost almost there * there. * remove empty descriptions * better contributing.md comment * Commit Contributing Guidelines * remove entries without descriptions --------- Co-authored-by: adamperkowski <adamperkowski@users.noreply.github.com>
61 lines
1.9 KiB
Rust
61 lines
1.9 KiB
Rust
use std::fs;
|
|
|
|
use linutil_core::Command;
|
|
|
|
use crate::path;
|
|
use crate::DynError;
|
|
|
|
pub const USER_GUIDE: &str = "userguide.md";
|
|
|
|
pub fn userguide() -> Result<String, DynError> {
|
|
let mut md = String::new();
|
|
md.push_str("<!-- THIS FILE IS GENERATED BY cargo xtask docgen -->\n# Walkthrough\n");
|
|
|
|
let tabs = linutil_core::get_tabs(false).1;
|
|
|
|
for tab in tabs {
|
|
#[cfg(debug_assertions)]
|
|
println!("Tab: {}", tab.name);
|
|
|
|
md.push_str(&format!("\n## {}\n\n", tab.name));
|
|
|
|
for entry in tab.tree {
|
|
if entry.command == Command::None {
|
|
#[cfg(debug_assertions)]
|
|
println!(" Directory: {}", entry.name);
|
|
|
|
if entry.name != "root".to_string() {
|
|
md.push_str(&format!("\n### {}\n\n", entry.name));
|
|
}
|
|
|
|
/* let current_dir = &entry.name;
|
|
|
|
if *current_dir != "root".to_string() {
|
|
md.push_str(&format!(
|
|
"\n<details><summary>{}</summary>\n\n",
|
|
current_dir
|
|
));
|
|
} */ // Commenting this for now, might be a good idea later
|
|
} else {
|
|
if !entry.description.is_empty() {
|
|
#[cfg(debug_assertions)]
|
|
println!(" Entry: {}", entry.name);
|
|
#[cfg(debug_assertions)]
|
|
println!(" Description: {}", entry.description);
|
|
|
|
md.push_str(&format!("- **{}**: {}\n", entry.name, entry.description));
|
|
} /* else {
|
|
md.push_str(&format!("- **{}**\n", entry.name));
|
|
} */ // https://github.com/ChrisTitusTech/linutil/pull/753
|
|
}
|
|
}
|
|
}
|
|
|
|
Ok(md)
|
|
}
|
|
|
|
pub fn write(file: &str, data: &str) {
|
|
let path = path::docs().join(file);
|
|
fs::write(path, data).unwrap_or_else(|_| panic!("Could not write to {}", file));
|
|
}
|