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 |
|
---|---|
Tests |
|
PyPI |
|
Anaconda |
|
Activity |
|
Other |
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:
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 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 http://conda.anaconda.org/domdfcoding $ conda config --add channels http://conda.anaconda.org/conda-forge
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 .
Future Enhancements
Support different methods of defining the requirements, e.g. setup.py or pyproject.toml.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file extras_require-0.2.0.tar.gz
.
File metadata
- Download URL: extras_require-0.2.0.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df1fc5c53a75f17516baecdce52c00b529c955b54e711bb4bc3d97885e2e3715 |
|
MD5 | 0ab5c78abe8011e86dfa2b5d987d5e4c |
|
BLAKE2b-256 | 532d649daed4cf17ff4b9d9119860ab10c4c9461ece212f6473ef867dc73bcf3 |
File details
Details for the file extras_require-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: extras_require-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8783e993f45ab6f04cef0743aee2034bdec3f1a88e4f60feb8b1a33928569398 |
|
MD5 | 22fff81dc2109261c853a6b2a073b855 |
|
BLAKE2b-256 | 34d42d60fce9868b403afed30038e845e64a63a9db63f255cce610ca6d726ac0 |