diff --git a/codewiki/src/config.py b/codewiki/src/config.py index 0bd4c906..dfd58b4e 100644 --- a/codewiki/src/config.py +++ b/codewiki/src/config.py @@ -349,6 +349,24 @@ def from_args(cls, args: argparse.Namespace) -> 'Config': fallback_base_url=LLM_BASE_URL ) + @classmethod + def from_web_job(cls, repo_path: str, docs_dir: str) -> 'Config': + """Create configuration for a web-app documentation job. + + Same environment-driven resolution as :meth:`from_args`, but takes the + job's repository path and output directory directly instead of an + argparse.Namespace. The web app's background worker has no CLI args to + pass, and building a fake Namespace at the call site just to satisfy + from_args() hid this dependency. + + Args: + repo_path: Path to the cloned repository to document. + docs_dir: Job-specific directory for the generated documentation. + """ + config = cls.from_args(argparse.Namespace(repo_path=repo_path)) + config.docs_dir = docs_dir + return config + @classmethod def from_cli( cls, diff --git a/codewiki/src/fe/background_worker.py b/codewiki/src/fe/background_worker.py index a9fe7729..cd68caa7 100644 --- a/codewiki/src/fe/background_worker.py +++ b/codewiki/src/fe/background_worker.py @@ -207,11 +207,8 @@ def _process_job(self, job_id: str): job.progress = "Analyzing repository structure..." # Create config for documentation generation (using env vars) - import argparse - args = argparse.Namespace(repo_path=temp_repo_dir) - config = Config.from_args(args) - # Override docs_dir with job-specific directory using config constants - config.docs_dir = os.path.join(OUTPUT_BASE_DIR, DOCS_DIR, f"{job_id}-docs") + docs_dir = os.path.join(OUTPUT_BASE_DIR, DOCS_DIR, f"{job_id}-docs") + config = Config.from_web_job(repo_path=temp_repo_dir, docs_dir=docs_dir) job.progress = "Generating documentation..."