File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66import shutil
77import sys
88import re
9-
9+ import argparse
1010
1111def copy_if_out_of_date (original , derived ):
1212 if (not os .path .exists (derived ) or
@@ -174,17 +174,23 @@ def all():
174174 'as spurious changes in your \' git status\' :\n \t {}'
175175 .format ('\n \t ' .join (symlink_warnings )))
176176
177- if len (sys .argv )> 1 :
178- if '--small' in sys .argv [1 :]:
179- small_docs = True
180- sys .argv .remove ('--small' )
181- for arg in sys .argv [1 :]:
182- func = funcd .get (arg )
177+ parser = argparse .ArgumentParser (description = 'Build matplotlib docs' )
178+ parser .add_argument ("cmd" , help = ("Command to execute. Can be multiple. "
179+ "Valid options are: %s" % (funcd .keys ())), nargs = '*' )
180+ parser .add_argument ("--small" ,
181+ help = "Smaller docs with only low res png figures" ,
182+ action = "store_true" )
183+ args = parser .parse_args ()
184+ if args .small :
185+ small_docs = True
186+
187+ if args .cmd :
188+ for command in args .cmd :
189+ func = funcd .get (command )
183190 if func is None :
184- raise SystemExit ('Do not know how to handle %s; valid args are %s' % (
185- arg , funcd .keys ()))
191+ raise SystemExit (( 'Do not know how to handle %s; valid commands'
192+ ' are %s' % ( command , funcd .keys () )))
186193 func ()
187194else :
188- small_docs = False
189195 all ()
190196os .chdir (current_dir )
You can’t perform that action at this time.
0 commit comments