Skip to main content

Display a warning at the top of module documentation that it has additional requirements.

Project description

Display a warning at the top of module documentation that it has additional requirements.

Docs

Documentation Build Status Docs Check Status

Tests

Linux Test Status Windows Test Status macOS Test Status Coverage

PyPI

PyPI - Package Version PyPI - Supported Python Versions PyPI - Supported Implementations PyPI - Wheel

Anaconda

Conda - Package Version Conda - Platform

Activity

GitHub last commit GitHub commits since tagged version Maintenance PyPI - Downloads

QA

CodeFactor Grade Flake8 Status mypy status

Other

License GitHub top language Requirements Status

Overview

This extension assumes you have a repository laid out like this:

.
├── chemistry_tools
│   ├── __init__.py
│   ├── formulae
│   │   ├── __init__.py
│   │   ├── compound.py
│   │   ├── formula.py
│   │   ├── parser.py
│   │   └── requirements.txt
│   ├── constants.py
│   └── utils.py
├── doc-source
│   ├── api
│   │   ├── chemistry_tools.rst
│   │   ├── elements.rst
│   │   ├── formulae.rst
│   │   └── pubchem.rst
│   ├── conf.py
│   ├── index.rst
│   └── requirements.txt
├── LICENSE
├── README.rst
├── requirements.txt
├── setup.py
└── tox.ini

The file ./chemistry_tools/formulae/requirements.txt contains the additional requirements to run the formulae subpackage. These would be defined in setup.py like this:

setup(
                extras_require={
                                "formulae": [
                                                "mathematical>=0.1.7",
                                                "pandas>=1.0.1",
                                                "pyparsing>=2.2.0",
                                                "tabulate>=0.8.3",
                                                "cawdrey>=0.1.2",
                                                "quantities>=0.12.4",
                                                ],
                                }
                )

A message can be displayed in the documentation to indicate that the subpackage has these additional requirements that must be installed.

For instance, this:

.. extras-require:: formulae
        :file: formulae/requirements.txt

will produce this:

doc-source/example.png

The path given in :file: is relative to the package_root variable given in conf.py, which in turn is relative to the parent directory of the sphinx documentation.

I.e, this line:

package_root = "chemistry_tools"

points to ./chemistry_tools, and therefore :file: formulae/requirements.txt points to ./chemistry_tools/formulae/requirements.txt.

Requirements can also be specified in pyproject.toml (using the option :pyproject:), setup.cfg (using the option :setup.cfg::), or by typing in the requirements manually, one per line.

The :scope: option can be used to specify a different scope for additional requirements, such as package, module, class or function. Any string value can be supplied here.

Installation

extras_require can be installed from PyPI or Anaconda.

To install with pip:

$ python -m pip install extras_require

To install with conda:

  • First add the required channels

$ conda config --add channels https://conda.anaconda.org/conda-forge
$ conda config --add channels https://conda.anaconda.org/domdfcoding
  • Then install

$ conda install extras_require

Enable extras_require by adding “sphinxcontrib.extras_require” to the extensions variable in conf.py:

extensions = [
        ...
        "sphinxcontrib.extras_require",
        ]

For more information see https://www.sphinx-doc.org/en/master/usage/extensions/index.html#third-party-extensions .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

extras_require-0.4.1.post1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

extras_require-0.4.1.post1-py3-none-any.whl (35.6 kB view details)

Uploaded Python 3

File details

Details for the file extras_require-0.4.1.post1.tar.gz.

File metadata

  • Download URL: extras_require-0.4.1.post1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for extras_require-0.4.1.post1.tar.gz
Algorithm Hash digest
SHA256 68bb97e82b0e27d8d0e4cd3ef8bccf34c6e21db01dd7e6733f29ec59d1907729
MD5 627ead9e81edb7298c45436accf569b9
BLAKE2b-256 17d90996f595c4aa851c9544ba3133e941ce1870a05a13f6b1274de1a86fe8dd

See more details on using hashes here.

File details

Details for the file extras_require-0.4.1.post1-py3-none-any.whl.

File metadata

  • Download URL: extras_require-0.4.1.post1-py3-none-any.whl
  • Upload date:
  • Size: 35.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for extras_require-0.4.1.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 1078ebffe8a60d1f4fb852fa319a6a39a174fe40acf3ef6d1cdeee8e7e7888db
MD5 6d3e57fef728ead678ec335b36f8ef93
BLAKE2b-256 3afc111c1c200591afab502b15a3f859abfebe5a19173af8e1a12357bacf596c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page