|
13 | 13 | from sphinx.application import Sphinx
|
14 | 14 |
|
15 | 15 | from pip._internal.cli import cmdoptions
|
| 16 | +from pip._internal.configuration import _normalize_name |
16 | 17 | from pip._internal.commands import commands_dict, create_command
|
17 | 18 | from pip._internal.req.req_file import SUPPORTED_OPTIONS
|
18 | 19 |
|
| 20 | +def convert_cli_option_to_envvar(opt_name): |
| 21 | + undashed_opt_name = _normalize_name(opt_name) |
| 22 | + normalized_opt_name = undashed_opt_name.upper().replace("-", "_") |
| 23 | + return f"PIP_{normalized_opt_name}" |
| 24 | + |
| 25 | +def convert_cli_opt_names_to_envvars(original_cli_opt_names): |
| 26 | + return [ |
| 27 | + convert_cli_option_to_envvar(opt_name) |
| 28 | + for opt_name in original_cli_opt_names |
| 29 | + ] |
19 | 30 |
|
20 | 31 | class PipNewsInclude(rst.Directive):
|
21 | 32 | required_arguments = 1
|
@@ -130,7 +141,9 @@ def _format_option(
|
130 | 141 | opt_help = option.help.replace("%default", str(option.default))
|
131 | 142 | # fix paths with sys.prefix
|
132 | 143 | opt_help = opt_help.replace(sys.prefix, "<sys.prefix>")
|
133 |
| - return [bookmark_line, "", line, "", " " + opt_help, ""] |
| 144 | + env_var_names = convert_cli_opt_names_to_envvars(option._long_opts) |
| 145 | + env_var_names_src = ", ".join(f"``{env_var}``" for env_var in env_var_names) |
| 146 | + return [bookmark_line, "", line, "", " " + opt_help, "", f" (environment variable: {env_var_names_src})", ""] |
134 | 147 |
|
135 | 148 | def _format_options(
|
136 | 149 | self, options: Iterable[optparse.Option], cmd_name: Optional[str] = None
|
|
0 commit comments