refactor: Remove redundant doc comments throughout codebase
Removes module-level doc comments (//! lines) and excessive inline doc comments that were duplicating information already evident from: - Function/struct names (self-documenting code) - Type signatures (the what is clear from types) - Implementation context (the how is clear from code) Affected modules: - cli/* - Removed command descriptions duplicating clap help text - core/* - Removed module headers and obvious function docs - documents/* - Removed extractor/regenerator/truncation docs - embedding/* - Removed pipeline and chunking docs - gitlab/* - Removed client and transformer docs (kept type definitions) - ingestion/* - Removed orchestrator and ingestion docs - search/* - Removed FTS and vector search docs Philosophy: Code should be self-documenting. Comments should explain "why" (business decisions, non-obvious constraints) not "what" (which the code itself shows). This change reduces noise and maintenance burden while keeping the codebase just as understandable. Retains comments for: - Non-obvious business logic - Important safety invariants - Complex algorithm explanations - Public API boundaries where generated docs matter Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
//! Init command - initialize configuration and database.
|
||||
|
||||
use std::fs;
|
||||
|
||||
use crate::core::config::{MinimalConfig, MinimalGitLabConfig, ProjectConfig};
|
||||
@@ -8,21 +6,18 @@ use crate::core::error::{LoreError, Result};
|
||||
use crate::core::paths::{get_config_path, get_data_dir};
|
||||
use crate::gitlab::{GitLabClient, GitLabProject};
|
||||
|
||||
/// Input data for init command.
|
||||
pub struct InitInputs {
|
||||
pub gitlab_url: String,
|
||||
pub token_env_var: String,
|
||||
pub project_paths: Vec<String>,
|
||||
}
|
||||
|
||||
/// Options for init command.
|
||||
pub struct InitOptions {
|
||||
pub config_path: Option<String>,
|
||||
pub force: bool,
|
||||
pub non_interactive: bool,
|
||||
}
|
||||
|
||||
/// Result of successful init.
|
||||
pub struct InitResult {
|
||||
pub config_path: String,
|
||||
pub data_dir: String,
|
||||
@@ -40,12 +35,10 @@ pub struct ProjectInfo {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
/// Run the init command programmatically.
|
||||
pub async fn run_init(inputs: InitInputs, options: InitOptions) -> Result<InitResult> {
|
||||
let config_path = get_config_path(options.config_path.as_deref());
|
||||
let data_dir = get_data_dir();
|
||||
|
||||
// 1. Check if config exists (force takes precedence over non_interactive)
|
||||
if config_path.exists() && !options.force {
|
||||
if options.non_interactive {
|
||||
return Err(LoreError::Other(format!(
|
||||
@@ -59,7 +52,6 @@ pub async fn run_init(inputs: InitInputs, options: InitOptions) -> Result<InitRe
|
||||
));
|
||||
}
|
||||
|
||||
// 2. Validate GitLab URL format
|
||||
if url::Url::parse(&inputs.gitlab_url).is_err() {
|
||||
return Err(LoreError::Other(format!(
|
||||
"Invalid GitLab URL: {}",
|
||||
@@ -67,12 +59,10 @@ pub async fn run_init(inputs: InitInputs, options: InitOptions) -> Result<InitRe
|
||||
)));
|
||||
}
|
||||
|
||||
// 3. Check token is set in environment
|
||||
let token = std::env::var(&inputs.token_env_var).map_err(|_| LoreError::TokenNotSet {
|
||||
env_var: inputs.token_env_var.clone(),
|
||||
})?;
|
||||
|
||||
// 4. Create GitLab client and test authentication
|
||||
let client = GitLabClient::new(&inputs.gitlab_url, &token, None);
|
||||
|
||||
let gitlab_user = client.get_current_user().await.map_err(|e| {
|
||||
@@ -88,7 +78,6 @@ pub async fn run_init(inputs: InitInputs, options: InitOptions) -> Result<InitRe
|
||||
name: gitlab_user.name,
|
||||
};
|
||||
|
||||
// 5. Validate each project path
|
||||
let mut validated_projects: Vec<(ProjectInfo, GitLabProject)> = Vec::new();
|
||||
|
||||
for project_path in &inputs.project_paths {
|
||||
@@ -115,14 +104,10 @@ pub async fn run_init(inputs: InitInputs, options: InitOptions) -> Result<InitRe
|
||||
));
|
||||
}
|
||||
|
||||
// 6. All validations passed - now write config and setup DB
|
||||
|
||||
// Create config directory if needed
|
||||
if let Some(parent) = config_path.parent() {
|
||||
fs::create_dir_all(parent)?;
|
||||
}
|
||||
|
||||
// Write minimal config (rely on serde defaults)
|
||||
let config = MinimalConfig {
|
||||
gitlab: MinimalGitLabConfig {
|
||||
base_url: inputs.gitlab_url,
|
||||
@@ -138,16 +123,13 @@ pub async fn run_init(inputs: InitInputs, options: InitOptions) -> Result<InitRe
|
||||
let config_json = serde_json::to_string_pretty(&config)?;
|
||||
fs::write(&config_path, format!("{config_json}\n"))?;
|
||||
|
||||
// 7. Create data directory and initialize database
|
||||
fs::create_dir_all(&data_dir)?;
|
||||
|
||||
let db_path = data_dir.join("lore.db");
|
||||
let conn = create_connection(&db_path)?;
|
||||
|
||||
// Run embedded migrations
|
||||
run_migrations(&conn)?;
|
||||
|
||||
// 8. Insert validated projects
|
||||
for (_, gitlab_project) in &validated_projects {
|
||||
conn.execute(
|
||||
"INSERT INTO projects (gitlab_project_id, path_with_namespace, default_branch, web_url)
|
||||
|
||||
Reference in New Issue
Block a user