thclark / pre-commit-sphinx

A pre-commit hook that will fail if documentation (eg for readthedocs.io) can't be built using sphinx
MIT License
3 stars 14 forks source link

Use additional dependencies to allow configuration of sphinx version #1

Open thclark opened 4 years ago

thclark commented 4 years ago

We have install_requires like:

install_requires =
    Sphinx>=2.0.0
    sphinx-rtd-theme>=0.4.2
    sphinx-tabs>=1.1.10
    breathe>=4.11.1
    exhale>=0.2.1

But the versions people use might vary wildly.

Proposed solution

Take a leaf out of flake8's book, and use additional installs in the pre-commit config:

  - repo: https://gitlab.com/pycqa/flake8
    rev: 3.8.1
    hooks:
      - id: flake8
        additional_dependencies: [flake8-isort]
        language_version: python3

So people's config files would look like:

  - repo: https://github.com/thclark/pre-commit-sphinx
    rev: 0X.Y.Z
    hooks:
      - id: build-docs
         additional_dependencies: [
            Sphinx>=2.0.0
            sphinx-rtd-theme>=0.4.2
            sphinx-tabs>=1.1.10
            breathe>=4.11.1
            exhale>=0.2.1
        ]
        language_version: python3

This has the extra benefit of avoiding the need to set up sphinx dependencies in the developer environment. After a first run of pre-commit, developers will have local docs built.