From 9105be723dbf2d380eebe104eda57d925e0f4598 Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Wed, 24 Jan 2024 13:56:36 +0100 Subject: [PATCH 1/2] DOC: use sphinx-apipages extension --- docs/_templates/autosummary/base.rst | 5 ----- docs/_templates/autosummary/class.rst | 19 ------------------ docs/_templates/autosummary/function.rst | 5 ----- docs/conf.py | 25 +++++++----------------- docs/requirements.txt | 1 + 5 files changed, 8 insertions(+), 47 deletions(-) delete mode 100644 docs/_templates/autosummary/base.rst delete mode 100644 docs/_templates/autosummary/class.rst delete mode 100644 docs/_templates/autosummary/function.rst diff --git a/docs/_templates/autosummary/base.rst b/docs/_templates/autosummary/base.rst deleted file mode 100644 index 01a0408f..00000000 --- a/docs/_templates/autosummary/base.rst +++ /dev/null @@ -1,5 +0,0 @@ -{{ name | escape | underline}} - -.. currentmodule:: {{ module }} - -.. auto{{ objtype }}:: {{ fullname }} diff --git a/docs/_templates/autosummary/class.rst b/docs/_templates/autosummary/class.rst deleted file mode 100644 index 638475d9..00000000 --- a/docs/_templates/autosummary/class.rst +++ /dev/null @@ -1,19 +0,0 @@ -{{ objname | escape | underline}} - -.. currentmodule:: {{ module }} - -.. autoclass:: {{ objname }} - -{% block methods %} -{%- for item in (all_methods + attributes)|sort %} - {%- if not item.startswith('_') or item in ['__call__', '__contains__', '__getitem__', '__len__'] %} - {%- if item in all_methods %} -{{ (item + '()') | escape | underline(line='-') }} -.. automethod:: {{ name }}.{{ item }} - {%- elif item in attributes %} -{{ item | escape | underline(line='-') }} -.. autoattribute:: {{ name }}.{{ item }} - {%- endif %} - {% endif %} -{%- endfor %} -{% endblock %} diff --git a/docs/_templates/autosummary/function.rst b/docs/_templates/autosummary/function.rst deleted file mode 100644 index 528f2227..00000000 --- a/docs/_templates/autosummary/function.rst +++ /dev/null @@ -1,5 +0,0 @@ -{{ (name + '()') | escape | underline}} - -.. currentmodule:: {{ module }} - -.. auto{{ objtype }}:: {{ fullname }} diff --git a/docs/conf.py b/docs/conf.py index 65a7f1d6..6c1b925d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,6 +1,4 @@ from datetime import date -import os -import shutil import toml @@ -34,14 +32,13 @@ pygments_style = None extensions = [ "sphinx.ext.graphviz", - "sphinx.ext.autodoc", "sphinx.ext.napoleon", # support for Google-style docstrings - "sphinx.ext.autosummary", "sphinx_autodoc_typehints", "sphinx.ext.viewcode", "sphinx.ext.intersphinx", "sphinx_copybutton", "jupyter_sphinx", + "sphinx_apipages", ] napoleon_use_ivar = True # List of class attributes @@ -73,9 +70,12 @@ ] graphviz_output_format = "svg" -# Disable auto-generation of TOC entries in the API -# https://github.com/sphinx-doc/sphinx/issues/6316 -toc_object_entries = False +apipages_hidden_methods = [ + "__call__", + "__contains__", + "__getitem__", + "__len__", +] # HTML -------------------------------------------------------------------- html_theme = "sphinx_audeering_theme" @@ -126,14 +126,3 @@ only_metadata=True, verbose=False, ) - - -# Copy API (sub-)module RST files to docs/api/ folder --------------------- -audeer.rmdir("api") -audeer.mkdir("api") -api_src_files = audeer.list_file_names("api-src") -api_dst_files = [ - audeer.path("api", os.path.basename(src_file)) for src_file in api_src_files -] -for src_file, dst_file in zip(api_src_files, api_dst_files): - shutil.copyfile(src_file, dst_file) diff --git a/docs/requirements.txt b/docs/requirements.txt index cc2f7252..208fffaf 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -3,6 +3,7 @@ ipykernel jupyter-sphinx pyarrow sphinx >=3.5.4 +sphinx-apipages >=0.1.2 sphinx-audeering-theme >=1.2.1 sphinx-autodoc-typehints sphinx-copybutton From 390e1962729070d5777dc909c2049231ef5184ed Mon Sep 17 00:00:00 2001 From: Hagen Wierstorf Date: Wed, 24 Jan 2024 14:05:05 +0100 Subject: [PATCH 2/2] Remove templates path --- docs/conf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index 6c1b925d..9e82e108 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,7 +28,6 @@ "Thumbs.db", ".DS_Store", ] -templates_path = ["_templates"] pygments_style = None extensions = [ "sphinx.ext.graphviz",