From e0682dfb576e70b3f0a8c0e205f4874bf45882b6 Mon Sep 17 00:00:00 2001 From: Istvan Kiss Date: Tue, 28 Apr 2026 15:27:12 +0200 Subject: [PATCH 1/8] Add markdown download button --- .gitignore | 1 - docs/_templates/page.html | 15 +++++++++++++++ docs/conf.py | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 docs/_templates/page.html diff --git a/.gitignore b/.gitignore index aaecec1c..af984950 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ build _build/ _images/ _static/ -_templates/ _toc.yml docBin/ _doxygen/ diff --git a/docs/_templates/page.html b/docs/_templates/page.html new file mode 100644 index 00000000..412518cc --- /dev/null +++ b/docs/_templates/page.html @@ -0,0 +1,15 @@ +{% extends "!page.html" %} + +{% block content %} + + {% if sourcename is defined %} +
+ + Download Markdown + +
+ {% endif %} + + {{ super() }} + +{% endblock %} \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 59df1884..d913608c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,6 +20,7 @@ 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", @@ -33,6 +34,8 @@ # Add any additional theme options here } extensions = ["rocm_docs"] +templates_path = ["_templates"] + html_static_path = ['_static', 'images'] From d6c6da126c9546eb25e774c8f524941438319a1a Mon Sep 17 00:00:00 2001 From: Istvan Kiss Date: Tue, 28 Apr 2026 15:51:01 +0200 Subject: [PATCH 2/8] Add download all button --- docs/_templates/page.html | 16 +++++++++--- docs/conf.py | 55 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 4 deletions(-) diff --git a/docs/_templates/page.html b/docs/_templates/page.html index 412518cc..2bc739ec 100644 --- a/docs/_templates/page.html +++ b/docs/_templates/page.html @@ -2,13 +2,21 @@ {% block content %} - {% if sourcename is defined %} -
+
+ + {% if sourcename is defined and sourcename %} + Download Markdown -
- {% endif %} + + {% endif %} + + + Download Full Documentation + + +
{{ super() }} diff --git a/docs/conf.py b/docs/conf.py index d913608c..a70d1e21 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" @@ -46,5 +48,58 @@ exclude_patterns = ['.venv'] +def generate_combined_markdown(app, exception): + if exception: + return + + docs_root = Path(app.srcdir) + output_file = Path(app.outdir) / "all-docs.md" + + markdown_files = sorted(docs_root.rglob("*.md")) + + combined = [] + + for md_file in markdown_files: + # Skip build/template dirs + if "_build" in md_file.parts or "_templates" in md_file.parts: + continue + + relative = md_file.relative_to(docs_root) + + combined.append(f"# {relative}\n") + + try: + content = md_file.read_text(encoding="utf-8") + combined.append(content) + combined.append("\n\n") + except Exception as e: + combined.append(f"\nError reading file: {e}\n\n") + + output_file.write_text("\n".join(combined), encoding="utf-8") + +def copy_markdown_for_downloads(app, exception): + if exception: + return + + src_dir = Path(app.srcdir) + out_dir = Path(app.outdir) + + download_dir = out_dir / "downloads" + download_dir.mkdir(parents=True, exist_ok=True) + + for md_file in src_dir.rglob("*.md"): + if "_build" in md_file.parts or "_templates" in md_file.parts: + continue + + relative_path = md_file.relative_to(src_dir) + + target = download_dir / relative_path.with_suffix(".md") + + target.parent.mkdir(parents=True, exist_ok=True) + shutil.copyfile(md_file, target) + + def setup(app): app.add_css_file("css/index.css") + app.connect("build-finished", generate_combined_markdown) + app.connect("build-finished", copy_markdown_for_downloads) From 5c529aca17c3fcd04165277ab57427207cb2400d Mon Sep 17 00:00:00 2001 From: Istvan Kiss Date: Wed, 29 Apr 2026 07:55:44 +0200 Subject: [PATCH 3/8] Enable theme download button --- docs/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/conf.py b/docs/conf.py index a70d1e21..7971931c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -27,6 +27,7 @@ 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/", From eecc8423c3e9d3873fdbd465bea669acc47a3ec5 Mon Sep 17 00:00:00 2001 From: Istvan Kiss Date: Mon, 4 May 2026 12:46:23 +0200 Subject: [PATCH 4/8] Removed the unnecessary buttons --- docs/_templates/page.html | 23 --------------- docs/conf.py | 61 ++++++++++++++++----------------------- 2 files changed, 25 insertions(+), 59 deletions(-) delete mode 100644 docs/_templates/page.html diff --git a/docs/_templates/page.html b/docs/_templates/page.html deleted file mode 100644 index 2bc739ec..00000000 --- a/docs/_templates/page.html +++ /dev/null @@ -1,23 +0,0 @@ -{% extends "!page.html" %} - -{% block content %} - -
- - {% if sourcename is defined and sourcename %} - - - Download Markdown - - - {% endif %} - - - Download Full Documentation - - -
- - {{ super() }} - -{% endblock %} \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 7971931c..ddff4ce1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -37,7 +37,6 @@ # Add any additional theme options here } extensions = ["rocm_docs"] -templates_path = ["_templates"] html_static_path = ['_static', 'images'] @@ -49,58 +48,48 @@ exclude_patterns = ['.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) / "all-docs.md" - markdown_files = sorted(docs_root.rglob("*.md")) + 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: - for md_file in markdown_files: - # Skip build/template dirs - if "_build" in md_file.parts or "_templates" in md_file.parts: + if should_skip(doc_file): continue - relative = md_file.relative_to(docs_root) + relative = doc_file.relative_to(docs_root) - combined.append(f"# {relative}\n") + combined.append(f"\n---\n") + combined.append(f"\n# {relative}\n") try: - content = md_file.read_text(encoding="utf-8") + content = doc_file.read_text(encoding="utf-8") combined.append(content) - combined.append("\n\n") - except Exception as e: - combined.append(f"\nError reading file: {e}\n\n") - - output_file.write_text("\n".join(combined), encoding="utf-8") + combined.append("\n") -def copy_markdown_for_downloads(app, exception): - if exception: - return - - src_dir = Path(app.srcdir) - out_dir = Path(app.outdir) - - download_dir = out_dir / "downloads" - download_dir.mkdir(parents=True, exist_ok=True) - - for md_file in src_dir.rglob("*.md"): - if "_build" in md_file.parts or "_templates" in md_file.parts: - continue - - relative_path = md_file.relative_to(src_dir) - - target = download_dir / relative_path.with_suffix(".md") - - target.parent.mkdir(parents=True, exist_ok=True) - shutil.copyfile(md_file, target) + 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) - app.connect("build-finished", copy_markdown_for_downloads) + app.connect("build-finished", generate_combined_markdown)) From a9e98535f0389593e54ecc1358ff5f8b1511154c Mon Sep 17 00:00:00 2001 From: Istvan Kiss Date: Mon, 4 May 2026 12:50:07 +0200 Subject: [PATCH 5/8] WIP --- docs/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index ddff4ce1..43da4fea 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -92,4 +92,4 @@ def generate_combined_markdown(app, exception): def setup(app): app.add_css_file("css/index.css") - app.connect("build-finished", generate_combined_markdown)) + app.connect("build-finished", generate_combined_markdown) From 1af76eafa1c06827576f8077eae77de19bcb7e79 Mon Sep 17 00:00:00 2001 From: Istvan Kiss Date: Mon, 4 May 2026 12:50:42 +0200 Subject: [PATCH 6/8] WIP --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index af984950..8b9d6e5f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ build _build/ _images/ _static/ +_template _toc.yml docBin/ _doxygen/ From 2f113c2c28e3bda4607fe910b4fc3ad4c14efd12 Mon Sep 17 00:00:00 2001 From: Istvan Kiss Date: Mon, 4 May 2026 12:54:06 +0200 Subject: [PATCH 7/8] WIP --- docs/conf.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 43da4fea..1314a44a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,6 +48,14 @@ 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) From 73a4af118898be82d402b048e6fc2e265b28bd54 Mon Sep 17 00:00:00 2001 From: Istvan Kiss Date: Mon, 4 May 2026 13:03:43 +0200 Subject: [PATCH 8/8] WIP --- .gitignore | 2 +- docs/conf.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8b9d6e5f..aaecec1c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ build _build/ _images/ _static/ -_template +_templates/ _toc.yml docBin/ _doxygen/ diff --git a/docs/conf.py b/docs/conf.py index 1314a44a..73ae5ab6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,7 +38,6 @@ } extensions = ["rocm_docs"] - html_static_path = ['_static', 'images'] html_css_files = ["index.css"]