File tree 1 file changed +15
-7
lines changed
1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change 9
9
from docutils .statemachine import ViewList
10
10
11
11
from pip ._internal .cli import cmdoptions
12
- from pip ._internal .commands import create_command
12
+ from pip ._internal .commands import commands_dict , create_command
13
13
from pip ._internal .req .req_file import SUPPORTED_OPTIONS
14
14
15
15
@@ -111,6 +111,14 @@ def process_options(self):
111
111
112
112
class PipReqFileOptionsReference (PipOptions ):
113
113
114
+ def determine_opt_prefix (self , opt_name ):
115
+ for command in commands_dict :
116
+ cmd = create_command (command )
117
+ if cmd .cmd_opts .has_option (opt_name ):
118
+ return command
119
+
120
+ raise KeyError ('Could not identify prefix of opt {}' .format (opt_name ))
121
+
114
122
def process_options (self ):
115
123
for option in SUPPORTED_OPTIONS :
116
124
if getattr (option , 'deprecated' , False ):
@@ -123,16 +131,16 @@ def process_options(self):
123
131
else :
124
132
short_opt_name = ''
125
133
126
- from_install = (
127
- 'install_ '
128
- if option not in cmdoptions . general_group [ 'options' ] else
129
- ''
130
- )
134
+ if option in cmdoptions . general_group [ 'options' ]:
135
+ prefix = ' '
136
+ else :
137
+ prefix = '{}_' . format ( self . determine_opt_prefix ( opt_name ))
138
+
131
139
self .view_list .append (
132
140
' * :ref:`{short}{long}<{prefix}{opt_name}>`' .format (
133
141
short = short_opt_name ,
134
142
long = opt_name ,
135
- prefix = from_install ,
143
+ prefix = prefix ,
136
144
opt_name = opt_name
137
145
),
138
146
"\n "
You can’t perform that action at this time.
0 commit comments