Generate documentation for all packages.
(output_dir: Path, repo_root: Path)
| 115 | |
| 116 | |
| 117 | def generate_docs(output_dir: Path, repo_root: Path): |
| 118 | """Generate documentation for all packages.""" |
| 119 | print(f"Generating Python documentation for all workspace packages...") |
| 120 | print(f"Output directory: {output_dir}") |
| 121 | |
| 122 | # Clean and create output directory |
| 123 | if output_dir.exists(): |
| 124 | import shutil |
| 125 | shutil.rmtree(output_dir) |
| 126 | output_dir.mkdir(parents=True) |
| 127 | |
| 128 | # Change to repo root for imports to work correctly |
| 129 | os.chdir(repo_root) |
| 130 | |
| 131 | # Generate documentation for each package |
| 132 | for package, source_dir in PACKAGES.items(): |
| 133 | print(f"Generating docs for {package} (from {source_dir})...") |
| 134 | |
| 135 | try: |
| 136 | # Use pdoc3 to generate HTML documentation |
| 137 | subprocess.run( |
| 138 | [ |
| 139 | "uv", "run", "pdoc3", |
| 140 | "--html", |
| 141 | "--output-dir", str(output_dir), |
| 142 | "--force", |
| 143 | package |
| 144 | ], |
| 145 | check=True, |
| 146 | cwd=repo_root, |
| 147 | ) |
| 148 | except subprocess.CalledProcessError as e: |
| 149 | print(f"Warning: Failed to generate docs for {package}, skipping...") |
| 150 | print(f"Error: {e}") |
| 151 | continue |
| 152 | |
| 153 | # Create index.html |
| 154 | index_path = output_dir / "index.html" |
| 155 | timestamp = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC") |
| 156 | index_path.write_text(INDEX_HTML_TEMPLATE.format(timestamp=timestamp)) |
| 157 | |
| 158 | print("\nDocumentation generated successfully!") |
| 159 | print(f"Open {output_dir}/index.html in your browser to view the documentation.") |
| 160 | |
| 161 | |
| 162 | def main(): |