diff --git a/docs/conf.py b/docs/conf.py index 59df188..73ae5ab 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,6 +1,8 @@ """Configuration file for the Sphinx documentation builder.""" import os from sphinx import addnodes +from pathlib import Path +import shutil external_projects_remote_repository = "" external_projects_current_project = "dcgpu" @@ -20,10 +22,12 @@ copyright = "Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved." # Required settings +html_copy_source = True html_theme = "rocm_docs_theme" html_theme_options = { "flavor": "instinct", "link_main_doc": True, + "use_download_button": True, "nav_secondary_items": { "Community": "https://github.com/ROCm/ROCm/discussions", "Blogs": "https://rocm.blogs.amd.com/", @@ -43,5 +47,56 @@ exclude_patterns = ['.venv'] +EXCLUDED_DIRS = { + "_build", + "_templates", + "_static", + ".git", + ".venv", +} + +def should_skip(path: Path) -> bool: + return any(part in EXCLUDED_DIRS for part in path.parts) + + +def generate_combined_markdown(app, exception): + if exception: + return + + docs_root = Path(app.srcdir) + + output_file = Path(app.outdir) / "llms.txt" + + print(output_file) + + all_files = sorted(docs_root.rglob("*.md")) + + combined = [] + combined.append("# Combined Documentation\n") + + for doc_file in all_files: + + if should_skip(doc_file): + continue + + relative = doc_file.relative_to(docs_root) + + combined.append(f"\n---\n") + combined.append(f"\n# {relative}\n") + + try: + content = doc_file.read_text(encoding="utf-8") + combined.append(content) + combined.append("\n") + + except Exception as e: + combined.append(f"\n[ERROR reading file: {e}]\n") + + output_file.write_text( + "\n".join(combined), + encoding="utf-8", + ) + def setup(app): app.add_css_file("css/index.css") + app.connect("build-finished", generate_combined_markdown)