SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
29.73k stars 8.02k forks source link

Updates the py api doc build #14173

Closed emanlove closed 6 days ago

emanlove commented 1 week ago

User description

Description

These changes regenerate the api stub files - those template files which give the base structure for the api docs - each time instead of using outdated checked in version from previous builds. Essentially we treat these like new builds which need to be regenerated versus updating and storing old build artifacts.

The base API template (py/docs/source/api.rst) has been updated to match current high level python modules which the api doc is built from. Ideally this should be autogenerated itself simply matching the Python codebase. Leaving that for another body of work to do sometime in the future.

Also updated the versions of the documentation tool (sphinx) and template packages (jinja) to more recent version. (Due to using Python 3.8 the latest sphinx version can't be used but this is ok.).

Motivation and Context

The API changes with each release as it matches the code. So essentially each time a new release comes out a new build of the documentation should be generated.

Types of changes

Checklist


PR Type

Bug fix, Enhancement


Description


Changes walkthrough πŸ“

Relevant files
Dependencies
requirements.txt
Update Sphinx version in documentation requirements           

py/docs/requirements.txt - Updated Sphinx version from 1.8.2 to 7.1.2.
+1/-1     
Documentation
api.rst
Update API documentation structure and modules                     

py/docs/source/api.rst
  • Added new modules to the API documentation.
  • Reordered modules alphabetically.
  • +36/-14 
    Configuration changes
    tox.ini
    Update tox configuration for documentation build                 

    py/tox.ini
  • Updated to use docs/requirements.txt for dependencies.
  • Added command to regenerate autodoc stub pages.
  • Set PYTHONPATH environment variable.
  • +9/-4     

    πŸ’‘ PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    codiumai-pr-agent-pro[bot] commented 1 week ago

    PR Reviewer Guide πŸ”

    ⏱️ Estimated effort to review [1-5] 3
    πŸ§ͺ Relevant tests No
    πŸ”’ Security concerns No
    ⚑ Key issues to review Documentation Structure:
    The PR involves significant changes to the documentation structure, including the removal of several .rst files and the addition of new modules in the API documentation. It's crucial to ensure that all new modules are correctly documented and that no essential information is lost in the transition.
    Sphinx Version Compatibility:
    The update to a newer Sphinx version (from 1.8.2 to 7.1.2) may introduce changes in how documents are built or displayed. It's important to verify that the new Sphinx version is fully compatible with the existing documentation setup and that the documentation builds without errors or significant changes in formatting.
    codiumai-pr-agent-pro[bot] commented 1 week ago

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Best practice
    Ensure all new modules are correctly linked and documented ___ **Verify that all new modules added to the api.rst file are correctly linked and documented
    in their respective .rst files to ensure proper documentation generation.** [py/docs/source/api.rst [79-103]](https://github.com/SeleniumHQ/selenium/pull/14173/files#diff-7e8f0a6376548281d6c1a5b57121f0a701a76c5f88129fe7def3d89f39b63c43R79-R103) ```diff +selenium.webdriver.chrome.remote_connection +selenium.webdriver.chromium.service +selenium.webdriver.edge.remote_connection - ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: This suggestion is crucial for ensuring that the documentation is complete and functional, preventing broken links and ensuring that all new modules are accessible and well-documented.
    8
    Maintainability
    Ensure consistent formatting and alignment for new module entries ___ **Ensure that all new modules added to the api.rst file are correctly formatted and aligned
    with the existing entries to maintain consistency and readability.** [py/docs/source/api.rst [27-37]](https://github.com/SeleniumHQ/selenium/pull/14173/files#diff-7e8f0a6376548281d6c1a5b57121f0a701a76c5f88129fe7def3d89f39b63c43R27-R37) ```diff +selenium.webdriver.common.driver_finder +selenium.webdriver.common.options +selenium.webdriver.common.selenium_manager +selenium.webdriver.common.utils +selenium.webdriver.common.virtual_authenticator - ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: The suggestion is relevant as it addresses the maintainability and readability of the documentation by ensuring new entries are well-formatted and aligned. This is important for large documentation files to remain manageable and user-friendly.
    7
    Possible issue
    Add a check to ensure sphinx-autogen runs successfully before sphinx-build ___ **Add a check to ensure that the sphinx-autogen command runs successfully before proceeding
    to the sphinx-build command to prevent build failures.** [py/tox.ini [10-14]](https://github.com/SeleniumHQ/selenium/pull/14173/files#diff-27d219400d7f64afbf3d9bceb197e20b299fdd58fb4e84c9b7c2ee7c4e828177R10-R14) ```diff commands = ; regenerate autodoc stub pages - sphinx-autogen docs/source/api.rst + sphinx-autogen docs/source/api.rst || { echo 'sphinx-autogen failed'; exit 1; } ; build api docs sphinx-build -b html -d ../build/docs/doctrees docs/source ../build/docs/api/py {posargs} ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 6 Why: Adding a check for the successful execution of `sphinx-autogen` before proceeding with `sphinx-build` is a good practice to avoid build failures. This suggestion enhances the robustness of the build process.
    6
    emanlove commented 1 week ago

    If one wants to easily test or reproduce the steps this is doing, the following commands will setup an virtualenv, grab the latest code and run the doc generation through tox; similar to what the official build does.

    virtualenv test-py38-env
    source test-py38-env/bin/activate
    pip install tox
    git clone git@github.com:emanlove/selenium.git se-api-docs-test
    cd se-api-docs-test/
    git switch -c py-api-doc-13910 origin/py-api-doc-13910
    tox -c py/tox.ini
    titusfortner commented 6 days ago

    Oh wow, yeah, this looks great. When looking at the diff I'm seeing several things in the current docs that still reference Selenium 4.17

    titusfortner commented 6 days ago

    @emanlove can you fix the conflict (looks like adding the line from #14171 isn't part of this PR)

    titusfortner commented 6 days ago

    Also can you create another issue for auto-generating the api.rst file so we can track it?

    emanlove commented 6 days ago

    @titusfortner Fixed the conflict. Sorry about that one.

    titusfortner commented 6 days ago

    @iampopovich I know you did the work to update the api.rst file here, do you want me to merge your file and rebase this on top of it, or can I just merge this? Also are you in our chat room? (https://www.selenium.dev/support/#ChatRoom) We can discuss more there if you'd like.

    iampopovich commented 6 days ago

    These changes are better than mine. It's fine to use them, no worries. They also include part of my work, so it's all fair 🀝

    titusfortner commented 6 days ago

    Now I just need to see about retroactively generating docs from the 4.22 tag😁