Skip to content

Commit 9584216

Browse files
authored
Streamlined auto api referencing for documentation (#5795)
## Description The current developer documentation feels somewhat cluttered due to inline auto-generated API references for certain classes. To improve readability and maintainability, this PR introduces a more streamlined approach that aligns better with best practices observed in other PyData ecosystem documentation. Specifically, this PR: - Adds a dedicated `api/` folder to the documentation structure. - Moves all auto-generated references (classes, methods, etc.) to this folder. - Enables clean, concise linking to API elements from the narrative documentation—without interrupting human-written content with large autogenerated blocks. This separation makes the documentation easier to navigate and maintain, while still providing full API reference coverage where needed. - [x] Documentation - [x] Changelog
1 parent 5356e6e commit 9584216

File tree

12 files changed

+204
-129
lines changed

12 files changed

+204
-129
lines changed

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_build
2+
generated/

docs/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ SPHINXOPTS =
66
SPHINXBUILD = sphinx-build
77
PAPER =
88
BUILDDIR = _build
9+
SOURCEDIR = .
910

1011
# When both are available, use Sphinx 2.x for autodoc compatibility.
1112
ifeq ($(shell which sphinx-build2 >/dev/null 2>&1 ; echo $$?),0)
@@ -39,7 +40,7 @@ help:
3940
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
4041

4142
clean:
42-
-rm -rf $(BUILDDIR)/*
43+
-rm -rf $(BUILDDIR)/* $(SOURCEDIR)/api/generated/*
4344

4445
html:
4546
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html

docs/_templates/autosummary/base.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{ fullname | escape | underline}}
2+
.. currentmodule:: {{ module }}
3+
.. auto{{ objtype }}:: {{ objname }}

docs/_templates/autosummary/class.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{{ fullname | escape | underline}}
2+
3+
.. currentmodule:: {{ module }}
4+
5+
.. autoclass:: {{ objname }}
6+
:members: <-- add at least this line
7+
:private-members:
8+
:show-inheritance: <-- plus I want to show inheritance...
9+
:inherited-members: <-- ...and inherited members too
10+
11+
{% block methods %}
12+
.. automethod:: __init__
13+
14+
{% if methods %}
15+
.. rubric:: {{ _('Public methods summary') }}
16+
17+
.. autosummary::
18+
{% for item in methods %}
19+
~{{ name }}.{{ item }}
20+
{%- endfor %}
21+
{% for item in _methods %}
22+
~{{ name }}.{{ item }}
23+
{%- endfor %}
24+
{% endif %}
25+
{% endblock %}
26+
27+
.. rubric:: {{ _('Methods definition') }}
28+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{ fullname | escape | underline}}
2+
{% block modules %}
3+
{% if modules %}
4+
.. rubric:: Modules
5+
6+
{% for item in modules %}
7+
{{ item }}
8+
9+
{%- endfor %}
10+
{% endif %}
11+
{% endblock %}

docs/api/database.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Database
2+
--------
3+
4+
.. currentmodule:: beets.library
5+
6+
7+
Library
8+
'''''''
9+
10+
.. autosummary::
11+
:toctree: generated/
12+
13+
Library
14+
15+
16+
Models
17+
''''''
18+
19+
.. autosummary::
20+
:toctree: generated/
21+
22+
LibModel
23+
Album
24+
Item
25+
26+
27+
Transactions
28+
''''''''''''
29+
30+
.. currentmodule:: beets.dbcore.db
31+
32+
.. autosummary::
33+
:toctree: generated/
34+
35+
Transaction
36+
37+
Queries
38+
'''''''
39+
40+
.. currentmodule:: beets.dbcore.query
41+
42+
.. autosummary::
43+
:toctree: generated/
44+
45+
Query
46+
FieldQuery
47+
AndQuery

docs/api/plugins.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Plugins
2+
-------
3+
4+
.. currentmodule:: beets.plugins
5+
6+
7+
8+
.. autosummary::
9+
:toctree: generated/
10+
11+
BeetsPlugin

docs/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,21 @@ For plugin developers:
4343

4444
Other changes:
4545

46+
* Documentation structure for auto generated API references changed slightly.
47+
Autogenerated API references are now located in the `docs/api` subdirectory.
48+
4649
2.3.1 (May 14, 2025)
4750
--------------------
4851

4952
Bug fixes:
53+
5054
* :doc:`/reference/pathformat`: Fixed a regression where path legalization
5155
incorrectly removed parts of user-configured path formats that followed a dot
5256
(**.**).
5357
:bug:`5771`
5458

5559
For packagers:
60+
5661
* Force ``poetry`` version below 2 to avoid it mangling file modification times
5762
in ``sdist`` package.
5863
:bug:`5770`

docs/conf.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
1-
AUTHOR = "Adrian Sampson"
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
25

3-
# General configuration
6+
# -- Project information -----------------------------------------------------
7+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
48

5-
extensions = ["sphinx.ext.autodoc", "sphinx.ext.extlinks"]
6-
7-
exclude_patterns = ["_build"]
8-
source_suffix = {".rst": "restructuredtext"}
9-
master_doc = "index"
109

1110
project = "beets"
11+
AUTHOR = "Adrian Sampson"
1212
copyright = "2016, Adrian Sampson"
1313

14+
master_doc = "index"
15+
language = "en"
1416
version = "2.3"
1517
release = "2.3.1"
1618

19+
# -- General configuration ---------------------------------------------------
20+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
21+
22+
extensions = [
23+
"sphinx.ext.autodoc",
24+
"sphinx.ext.autosummary",
25+
"sphinx.ext.extlinks",
26+
]
27+
autosummary_generate = True
28+
exclude_patterns = ["_build"]
29+
templates_path = ["_templates"]
30+
source_suffix = {".rst": "restructuredtext", ".md": "markdown"}
31+
32+
1733
pygments_style = "sphinx"
1834

1935
# External links to the bug tracker and other sites.
@@ -59,10 +75,24 @@
5975
),
6076
]
6177

62-
# Options for pydata theme
78+
79+
# -- Options for HTML output -------------------------------------------------
80+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
81+
82+
6383
html_theme = "pydata_sphinx_theme"
6484
html_theme_options = {"collapse_navigation": True, "logo": {"text": "beets"}}
6585
html_title = "beets"
6686
html_logo = "_static/beets_logo_nobg.png"
6787
html_static_path = ["_static"]
6888
html_css_files = ["beets.css"]
89+
90+
91+
def skip_member(app, what, name, obj, skip, options):
92+
if name.startswith("_"):
93+
return True
94+
return skip
95+
96+
97+
def setup(app):
98+
app.connect("autodoc-skip-member", skip_member)

docs/dev/index.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,18 @@ and write metadata tags in media files.
1010
.. _MediaFile: https://mediafile.readthedocs.io/en/latest/
1111

1212
.. toctree::
13+
:maxdepth: 1
1314

1415
plugins
1516
library
1617
importer
1718
cli
19+
20+
21+
.. toctree::
22+
:maxdepth: 1
23+
:caption: API Reference
24+
25+
../api/plugins
26+
../api/database
27+

0 commit comments

Comments
 (0)