Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 162f89b

Browse files
committed
use argparse to parse input in make.py
1 parent 86ec1b6 commit 162f89b

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

doc/make.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import shutil
77
import sys
88
import re
9-
9+
import argparse
1010

1111
def 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()
187194
else:
188-
small_docs = False
189195
all()
190196
os.chdir(current_dir)

0 commit comments

Comments
 (0)