Skip to main content

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

Project description

Docs

Documentation Status

Tests

Travis Build Status Requirements Status CodeFactor Grade

PyPI

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

Other

License GitHub top language GitHub commits since tagged version GitHub last commit Maintenance

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


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 look like this:

.images/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 __pkginfo__.py (using the option :__pkginfo__:), 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 with pip:

$ python -m pip 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 .

Future Enhancements

  • Support different methods of defining the requirements, e.g. setup.py or pyproject.toml.

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.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

extras_require-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file extras_require-0.1.0.tar.gz.

File metadata

  • Download URL: extras_require-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.7

File hashes

Hashes for extras_require-0.1.0.tar.gz
Algorithm Hash digest
SHA256 03068b895e9350a8c777d0e1c0907d3740f4a8b377c5caf8fcd0509be0f25550
MD5 a64894c8b421ae3d780581055f90c0ba
BLAKE2b-256 b0c15fde6a5d610e9c88f3009ecd6c782668b0206ddcf9e0ae89a341cb15b6e0

See more details on using hashes here.

File details

Details for the file extras_require-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: extras_require-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.7

File hashes

Hashes for extras_require-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 465912badd55021a5d92d4ff7a35a6a2ae6c2d2ba316e50cbd2284891c7e8f04
MD5 258bb67f597bb71da8f4b767c57324ee
BLAKE2b-256 028c8da95ee056db2ae17d8a479d652f44cb7b03e2e62a6862dedeae28ace01d

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