Metadata-Version: 2.1
Name: extras-require
Version: 0.0.2
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 :: 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

.. 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
.. image:: https://readthedocs.org/projects/extras_require/badge/?version=latest
    :target: https://extras_require.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status
.. image:: https://img.shields.io/pypi/v/extras_require.svg
    :target: https://pypi.org/project/extras_require/
    :alt: PyPI
.. image:: https://img.shields.io/pypi/pyversions/extras_require.svg
    :target: https://pypi.org/project/extras_require/
    :alt: PyPI - Python Version
.. image:: https://img.shields.io/pypi/wheel/extras_require
    :target: https://pypi.org/project/extras_require/
    :alt: PyPI - Wheel
.. image:: https://img.shields.io/pypi/implementation/extras_require
    :target: https://pypi.org/project/extras_require/
    :alt: PyPI - Implementation
.. image:: https://img.shields.io/github/license/domdfcoding/extras_require
    :alt: License
    :target: https://github.com/domdfcoding/extras_require/blob/master/LICENSE
.. image:: https://img.shields.io/github/languages/top/domdfcoding/extras_require
    :alt: GitHub top language
.. image:: https://img.shields.io/github/commits-since/domdfcoding/extras_require/v0.0.2
    :target: https://github.com/domdfcoding/extras_require/pulse
    :alt: GitHub commits since tagged version
.. image:: https://img.shields.io/github/last-commit/domdfcoding/extras_require
    :target: https://github.com/domdfcoding/extras_require/commit/master
    :alt: GitHub last commit
.. image:: https://img.shields.io/maintenance/yes/2020
    :alt: Maintenance
.. image:: https://img.shields.io/codefactor/grade/github/domdfcoding/extras_require
    :target: https://www.codefactor.io/repository/github/domdfcoding/extras_require
    :alt: CodeFactor Grade

.. 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::
        :file: formulae/requirements.txt
        :extra: formulae

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

Installation
--------------

``extras_require`` can be installed with ``pip``:

.. code-block:: bash

    $ python -m pip install extras_require

Enable ``extras_require`` by adding the following line to the ``extensions`` variable in ``conf.py``:

.. code-block:: python

    "sphinxcontrib.extras_require",

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

Future Enhancements
---------------------

* Allow use of different "scopes", e.g. ``package``, ``module``, ``class``, ``function``, depending on what the additional requirements are for.
* Support different methods of defining the requirements, e.g. ``setup.cfg``, ``setup.py``, ``__pkginfo__.py``, ``pyproject.toml``, or typing as entries in the directive itself.


Links
-----

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


