Metadata-Version: 2.1
Name: extras-require
Version: 0.1.0
Summary: Display a warning at the top of module documentation that it has additional requirements.
Home-page: https://github.com/domdfcoding/extras_require
Author: Dominic Davis-Foster
Author-email: dominic@davis-foster.co.uk
License: BSD License
Project-URL: Documentation, https://extras_require.readthedocs.io
Project-URL: Issue Tracker, https://github.com/domdfcoding/extras_require/issues
Project-URL: Source Code, https://github.com/domdfcoding/extras_require
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Framework :: Sphinx :: Extension
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Classifier: Topic :: Documentation
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: License :: OSI Approved :: BSD License
Requires-Python: >=3.6
Requires-Dist: sphinx (>=3.0.0)
Requires-Dist: docutils
Provides-Extra: all

****************
extras-require
****************

.. start shields 

.. list-table::
	:stub-columns: 1
	:widths: 10 90

	* - Docs
	  - |docs|
	* - Tests
	  - |travis| |requires| |codefactor|
	* - PyPI
	  - |pypi-version| |supported-versions| |supported-implementations| |wheel|
	* - Other
	  - |license| |language| |commits-since| |commits-latest| |maintained| 

.. |docs| image:: https://readthedocs.org/projects/extras_require/badge/?version=latest
	:target: https://extras_require.readthedocs.io/en/latest/?badge=latest
	:alt: Documentation Status

.. |travis| image:: https://img.shields.io/travis/com/domdfcoding/extras_require/master?logo=travis
	:target: https://travis-ci.com/domdfcoding/extras_require
	:alt: Travis Build Status

.. |requires| image:: https://requires.io/github/domdfcoding/extras_require/requirements.svg?branch=master
	:target: https://requires.io/github/domdfcoding/extras_require/requirements/?branch=master
	:alt: Requirements Status

.. |codefactor| image:: https://img.shields.io/codefactor/grade/github/domdfcoding/extras_require
	:target: https://www.codefactor.io/repository/github/domdfcoding/extras_require
	:alt: CodeFactor Grade

.. |pypi-version| image:: https://img.shields.io/pypi/v/extras_require.svg
	:target: https://pypi.org/project/extras_require/
	:alt: PyPI - Package Version

.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/extras_require.svg
	:target: https://pypi.org/project/extras_require/
	:alt: PyPI - Supported Python Versions

.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/extras_require
	:target: https://pypi.org/project/extras_require/
	:alt: PyPI - Supported Implementations

.. |wheel| image:: https://img.shields.io/pypi/wheel/extras_require
	:target: https://pypi.org/project/extras_require/
	:alt: PyPI - Wheel

.. |license| image:: https://img.shields.io/github/license/domdfcoding/extras_require
	:alt: License
	:target: https://github.com/domdfcoding/extras_require/blob/master/LICENSE

.. |language| image:: https://img.shields.io/github/languages/top/domdfcoding/extras_require
	:alt: GitHub top language

.. |commits-since| image:: https://img.shields.io/github/commits-since/domdfcoding/extras_require/v0.1.0
	:target: https://github.com/domdfcoding/extras_require/pulse
	:alt: GitHub commits since tagged version

.. |commits-latest| image:: https://img.shields.io/github/last-commit/domdfcoding/extras_require
	:target: https://github.com/domdfcoding/extras_require/commit/master
	:alt: GitHub last commit

.. |maintained| image:: https://img.shields.io/maintenance/yes/2020
	:alt: Maintenance

.. end shields

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:

.. code-block:: python

    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:

.. image:: .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:

.. code-block:: python

    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``:

.. code-block:: bash

    $ python -m pip install extras_require

Enable ``extras_require`` by adding "sphinxcontrib.extras_require" to the ``extensions`` variable in ``conf.py``:

.. code-block:: python

    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
-----

- Source: https://github.com/domdfcoding/extras-require
- Bugs: https://github.com/domdfcoding/extras-require/issues


