[py] Auto-generate Python API docs from code by cgoldberg ยท Pull Request #15822 ยท SeleniumHQ/selenium

User description

๐Ÿ”— Related Issues

Fixes #14178

๐Ÿ’ฅ What does this PR do?

This PR updates the Python documentation build process so API documentation is auto-generated from code. Previously, we had to manually keep ./py/docs/source/api.rst updated when new modules were added so they were included in the API docs (which was often forgotten).

Now, we have a 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.

The docs can be built using tox -c py/tox.ini -e docs or ./go py:docs.

Other changes:

  • update .readthedocs.yaml config file to use the new script
  • remove unused Makefile

๐Ÿ”„ Types of changes

  • build infrastructure
  • documentation

PR Type

Enhancement, Documentation


Description

  • Automate generation of Python API docs from codebase

    • Add script to generate api.rst from modules
    • Remove manual maintenance of API module list
  • Update documentation build process and configs

    • Modify tox and ReadTheDocs to use new script
    • Remove obsolete Makefile and update README
  • Regenerate and restructure api.rst for autodoc


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
generate_api_module_listing.py
Add script to auto-generate API module listing                     

py/generate_api_module_listing.py

  • Add script to scan selenium package for modules
  • Script generates docs/source/api.rst for Sphinx autodoc
  • Automates API documentation module listing
  • +83/-0   
    Configuration changes
    .readthedocs.yaml
    Update ReadTheDocs config for auto-generated API docs       

    py/docs/.readthedocs.yaml

  • Update Python version to 3.12
  • Add step to run API module generation script before Sphinx
  • Ensure docs build uses auto-generated api.rst
  • +2/-1     
    tox.ini
    Update tox docs environment for auto-generated API docs   

    py/tox.ini

  • Add step to run API module generation script in docs build
  • Ensure Sphinx uses up-to-date module listing
  • +2/-0     
    Cleanup
    Makefile
    Remove obsolete Sphinx Makefile                                                   

    py/docs/Makefile

  • Remove obsolete Sphinx Makefile
  • Clean up legacy manual build commands
  • +0/-131 
    Documentation
    README.rst
    Update docs for automated API doc generation                         

    py/docs/README.rst

  • Update documentation to reflect new API doc generation
  • Remove references to manual api.rst maintenance and Makefile
  • +3/-11   
    api.rst
    Regenerate and restructure API reference file                       

    py/docs/source/api.rst

  • Regenerate API reference file with new module structure
  • Add auto-generation notice and reorganize sections
  • Reflects current modules found by the new script
  • +109/-58

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.