From b4bd105c41dc5eacd74f7650ce21ea72f306ad1b Mon Sep 17 00:00:00 2001 From: PONS Date: Thu, 12 Feb 2026 14:22:51 +0100 Subject: [PATCH] Fix for readthedocs --- docs/Makefile | 3 +-- docs/conf.py | 5 +++++ {docs => pyaml/apidoc}/gen_api.py | 27 ++++++++++++++------------- 3 files changed, 20 insertions(+), 15 deletions(-) rename {docs => pyaml/apidoc}/gen_api.py (92%) diff --git a/docs/Makefile b/docs/Makefile index 0ea910a1..13262b8c 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -23,11 +23,10 @@ test: Makefile clean: Makefile rm -f api.rst - rm -rf api/* + rm -rf api/*.rst @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile - python gen_api.py @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/conf.py b/docs/conf.py index 8f47fe2b..37114082 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,6 +17,11 @@ import pyaml +# Generate reference API +from pyaml.apidoc.gen_api import gen_doc + +gen_doc() + # -- Project information ----------------------------------------------------- project = "Python Accelerator Middle Layer" diff --git a/docs/gen_api.py b/pyaml/apidoc/gen_api.py similarity index 92% rename from docs/gen_api.py rename to pyaml/apidoc/gen_api.py index f462259b..94431248 100644 --- a/docs/gen_api.py +++ b/pyaml/apidoc/gen_api.py @@ -153,16 +153,17 @@ def generate_toctree(filename: str, title: str, level: int, module: str): # Generate toctrees -sys.stdout.write("Generating API") -sys.stdout.flush() -paths = generate_toctree("api.rst", "API Reference", 0, "pyaml") -level = 1 -while len(paths) > 0: - npaths = [] - for p in paths: - npaths.extend( - generate_toctree(f"api/{'pyaml.' + p}.rst", f"{p}", level, "pyaml." + p) - ) - paths = npaths - level += 1 -print("done") +def gen_doc(): + sys.stdout.write("Generating API") + sys.stdout.flush() + paths = generate_toctree("api.rst", "API Reference", 0, "pyaml") + level = 1 + while len(paths) > 0: + npaths = [] + for p in paths: + npaths.extend( + generate_toctree(f"api/{'pyaml.' + p}.rst", f"{p}", level, "pyaml." + p) + ) + paths = npaths + level += 1 + print("done")