- renderer: render_architecture_md accepts Config, uses project name and current date - renderer: generate real Python usage examples from analyzed symbols - writer: skip writing files when content unchanged (optimization) - cli: add --dry-run flag to generate command (lists files without writing) - cli: add verbose logging for file/module/symbol generation progress
87 lines
2.6 KiB
Rust
87 lines
2.6 KiB
Rust
mod commands;
|
|
mod output;
|
|
|
|
use clap::{Parser, Subcommand};
|
|
use anyhow::Result;
|
|
|
|
#[derive(Parser)]
|
|
#[command(name = "archdoc")]
|
|
#[command(about = "Generate architecture documentation for Python projects")]
|
|
#[command(version = "0.1.0")]
|
|
pub struct Cli {
|
|
#[command(subcommand)]
|
|
command: Commands,
|
|
|
|
/// Verbose output
|
|
#[arg(short, long, global = true)]
|
|
verbose: bool,
|
|
}
|
|
|
|
#[derive(Subcommand)]
|
|
enum Commands {
|
|
/// Initialize archdoc in the project
|
|
Init {
|
|
#[arg(short, long, default_value = ".")]
|
|
root: String,
|
|
#[arg(short, long, default_value = "docs/architecture")]
|
|
out: String,
|
|
},
|
|
/// Generate or update documentation
|
|
Generate {
|
|
#[arg(short, long, default_value = ".")]
|
|
root: String,
|
|
#[arg(short, long, default_value = "docs/architecture")]
|
|
out: String,
|
|
#[arg(short, long, default_value = "archdoc.toml")]
|
|
config: String,
|
|
/// Show what would be generated without writing files
|
|
#[arg(long)]
|
|
dry_run: bool,
|
|
},
|
|
/// Check if documentation is up to date
|
|
Check {
|
|
#[arg(short, long, default_value = ".")]
|
|
root: String,
|
|
#[arg(short, long, default_value = "archdoc.toml")]
|
|
config: String,
|
|
},
|
|
/// Show project statistics
|
|
Stats {
|
|
#[arg(short, long, default_value = ".")]
|
|
root: String,
|
|
#[arg(short, long, default_value = "archdoc.toml")]
|
|
config: String,
|
|
},
|
|
}
|
|
|
|
fn main() -> Result<()> {
|
|
let cli = Cli::parse();
|
|
|
|
match &cli.command {
|
|
Commands::Init { root, out } => {
|
|
commands::init::init_project(root, out)?;
|
|
}
|
|
Commands::Generate { root, out, config, dry_run } => {
|
|
let config = commands::generate::load_config(config)?;
|
|
let model = commands::generate::analyze_project(root, &config)?;
|
|
if *dry_run {
|
|
commands::generate::dry_run_docs(&model, out, &config)?;
|
|
} else {
|
|
commands::generate::generate_docs(&model, out, cli.verbose, &config)?;
|
|
}
|
|
output::print_generate_summary(&model);
|
|
}
|
|
Commands::Check { root, config } => {
|
|
let config = commands::generate::load_config(config)?;
|
|
commands::check::check_docs_consistency(root, &config)?;
|
|
}
|
|
Commands::Stats { root, config } => {
|
|
let config = commands::generate::load_config(config)?;
|
|
let model = commands::generate::analyze_project(root, &config)?;
|
|
commands::stats::print_stats(&model);
|
|
}
|
|
}
|
|
|
|
Ok(())
|
|
}
|