diff --git a/docs/html/reference/pip_install.rst b/docs/html/reference/pip_install.rst
index c81e43ba49e..d5f1e0149ac 100644
--- a/docs/html/reference/pip_install.rst
+++ b/docs/html/reference/pip_install.rst
@@ -156,18 +156,7 @@ To interpret the requirements file in UTF-8 format add a comment
The following options are supported:
- * :ref:`-i, --index-url `
- * :ref:`--extra-index-url `
- * :ref:`--no-index `
- * :ref:`-c, --constraint `
- * :ref:`-r, --requirement `
- * :ref:`-e, --editable `
- * :ref:`-f, --find-links `
- * :ref:`--no-binary `
- * :ref:`--only-binary `
- * :ref:`--require-hashes `
- * :ref:`--pre `
- * :ref:`--trusted-host <--trusted-host>`
+.. pip-reqfile-options-ref::
For example, to specify :ref:`--no-index ` and two
:ref:`--find-links ` locations:
diff --git a/docs/pip_sphinxext.py b/docs/pip_sphinxext.py
index 29ca34c7289..b8797edeb23 100644
--- a/docs/pip_sphinxext.py
+++ b/docs/pip_sphinxext.py
@@ -10,6 +10,7 @@
from pip._internal.cli import cmdoptions
from pip._internal.commands import create_command
+from pip._internal.req.req_file import SUPPORTED_OPTIONS
class PipCommandUsage(rst.Directive):
@@ -108,9 +109,40 @@ def process_options(self):
)
+class PipReqFileOptionsReference(PipOptions):
+
+ def process_options(self):
+ for option in SUPPORTED_OPTIONS:
+ if getattr(option, 'deprecated', False):
+ continue
+
+ opt = option()
+ opt_name = opt._long_opts[0]
+ if opt._short_opts:
+ short_opt_name = '{}, '.format(opt._short_opts[0])
+ else:
+ short_opt_name = ''
+
+ from_install = (
+ 'install_'
+ if option not in cmdoptions.general_group['options'] else
+ ''
+ )
+ self.view_list.append(
+ ' * :ref:`{short}{long}<{prefix}{opt_name}>`'.format(
+ short=short_opt_name,
+ long=opt_name,
+ prefix=from_install,
+ opt_name=opt_name
+ ),
+ "\n"
+ )
+
+
def setup(app):
app.add_directive('pip-command-usage', PipCommandUsage)
app.add_directive('pip-command-description', PipCommandDescription)
app.add_directive('pip-command-options', PipCommandOptions)
app.add_directive('pip-general-options', PipGeneralOptions)
app.add_directive('pip-index-options', PipIndexOptions)
+ app.add_directive('pip-reqfile-options-ref', PipReqFileOptionsReference)
diff --git a/news/7908.doc b/news/7908.doc
new file mode 100644
index 00000000000..8a5d182196e
--- /dev/null
+++ b/news/7908.doc
@@ -0,0 +1,2 @@
+Requirements file options are now extracted from the code instead
+of being maintained manually.