Refactor directory structure creation and enhance documentation generation
- Simplified the creation of output directory structure in `init_project` and `generate_docs` functions. - Added a `sanitize_filename` function to ensure valid filenames for generated documentation files. - Implemented individual documentation file creation for modules and files in the `generate_docs` function. - Updated links in the renderer to use the new `sanitize_for_link` function for safe URL generation. - Adjusted the `extract_docstring` method in `PythonAnalyzer` to accept the body parameter without using it, preparing for future enhancements.
This commit is contained in:
@@ -164,7 +164,7 @@ impl PythonAnalyzer {
|
||||
}
|
||||
}
|
||||
|
||||
fn extract_docstring(&self, body: &[Stmt]) -> Option<String> {
|
||||
fn extract_docstring(&self, _body: &[Stmt]) -> Option<String> {
|
||||
// For now, just return None until we figure out the correct way to extract docstrings
|
||||
// TODO: Implement proper docstring extraction
|
||||
None
|
||||
@@ -213,11 +213,13 @@ impl PythonAnalyzer {
|
||||
flags
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn extract_function_def(&self, _func_def: &StmtFunctionDef, _symbols: &mut Vec<Symbol>, _calls: &mut Vec<Call>, _depth: usize) {
|
||||
// Extract function information
|
||||
// This is a simplified implementation - a full implementation would extract more details
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn extract_class_def(&self, _class_def: &StmtClassDef, _symbols: &mut Vec<Symbol>, _depth: usize) {
|
||||
// Extract class information
|
||||
// This is a simplified implementation - a full implementation would extract more details
|
||||
|
||||
@@ -6,6 +6,16 @@
|
||||
use crate::model::ProjectModel;
|
||||
use handlebars::Handlebars;
|
||||
|
||||
fn sanitize_for_link(filename: &str) -> String {
|
||||
filename
|
||||
.chars()
|
||||
.map(|c| match c {
|
||||
'/' | '\\' | ':' | '*' | '?' | '"' | '<' | '>' | '|' => '_',
|
||||
c => c,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub struct Renderer {
|
||||
templates: Handlebars<'static>,
|
||||
}
|
||||
@@ -243,7 +253,7 @@ impl Renderer {
|
||||
layout_items.push(serde_json::json!({
|
||||
"path": file_doc.path,
|
||||
"purpose": "Source file",
|
||||
"link": format!("docs/architecture/files/{}.md", file_id)
|
||||
"link": format!("docs/architecture/files/{}.md", sanitize_for_link(&file_doc.path))
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -280,7 +290,7 @@ impl Renderer {
|
||||
"symbol_count": module.symbols.len(),
|
||||
"inbound_count": module.inbound_modules.len(),
|
||||
"outbound_count": module.outbound_modules.len(),
|
||||
"link": format!("docs/architecture/modules/{}.md", module_id)
|
||||
"link": format!("docs/architecture/modules/{}.md", sanitize_for_link(module_id))
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user