Skip to content

Commit a5dd13f

Browse files
authored
[py] Auto-generate Python API docs from code (SeleniumHQ#15822)
* Update the Python documentation build process so API documentation is auto-generated from code * Added new script (./py/generate_api_module_listing.py) that scans the codebase for Python modules and generates a new api.rst file. This file is later used by sphinx-autogen to generate sphinx autodoc stub pages used in the Python API documentation. * Update tox.ini and readthedocs.yaml to call the script when building docs
1 parent b7f31ce commit a5dd13f

File tree

7 files changed

+211
-201
lines changed

7 files changed

+211
-201
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ py/selenium/webdriver/remote/isDisplayed.js
7676
py/docs/build/
7777
py/docs/source/**/*
7878
!py/docs/source/conf.py
79+
!py/docs/source/*.rst
7980
py/build/
8081
py/LICENSE
8182
py/pytestdebug.log

py/docs/.readthedocs.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ version: 2
1010
build:
1111
os: ubuntu-24.04
1212
tools:
13-
python: "3.11"
13+
python: "3.12"
1414
commands:
1515
- pip install -r py/docs/requirements.txt
1616
- pip install -r py/requirements.txt
17+
- PYTHONPATH=py python3 py/generate_api_module_listing.py
1718
- PYTHONPATH=py sphinx-autogen -o $READTHEDOCS_OUTPUT/html py/docs/source/api.rst
1819
- PYTHONPATH=py sphinx-build -b html -d build/docs/doctrees py/docs/source $READTHEDOCS_OUTPUT/html
1920

py/docs/Makefile

Lines changed: 0 additions & 131 deletions
This file was deleted.

py/docs/README.rst

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,14 @@ and develop the Python docs.
4949
To clean up the build assets and tox cache
5050
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5151

52-
Although there is a Sphinx Makefile option, to clean up using the tox environment above, one can
53-
manually clean the build assets by deleting the ``build`` directory on the root (``selenium/build``
54-
using the default directory on git clone). Note that tox caches parts of the build and recognizes
55-
changes to speed up the build. To start fresh, delete the aformentioned directory to clean the
56-
Sphinx build assets and delete the ``selenium/py/.tox`` directory to clean the tox environment.
52+
After using the tox environment above, you can clean up the build assets by deleting the ``build``
53+
directory in the root of the repo. Note that tox caches parts of the build and recognizes changes
54+
to speed up the build. To start fresh, delete the ``py/.tox`` directory to clean the tox environment.
5755

5856

5957
Known documentation issues
6058
==========================
6159

62-
The API Reference primarily builds from the source code. But currently the initial template stating
63-
which modules to document is hard coded within ``py/docs/source/api.rst``. So if modules are added or
64-
removed, then the generated docs will be inaccurate. It would be preferred that the API docs generate
65-
soley from the code if possible. This is being tracked in
66-
`#14178 <https://github.com/SeleniumHQ/selenium/issues/14178>`_
67-
6860
We are working through the Sphinx build warnings and errors, trying to clean up both the syntax and
6961
the build.
7062

0 commit comments

Comments
 (0)