summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMike Taves <mwtoews@gmail.com>2020-03-05 00:00:16 +1300
committerMike Taves <mwtoews@gmail.com>2020-03-09 13:44:26 +1300
commita7af9cc2578cdc128e662d163552fcb22da3c496 (patch)
treeed501fdc41b17325929f86e050914bbdcd0e885b /doc
parent6894bbc6d396b87464cbc21516d239d5f94f13b7 (diff)
downloadnumpy-a7af9cc2578cdc128e662d163552fcb22da3c496.tar.gz
MAINT: replace optparse with argparse for 'doc' and 'tools' scripts
Diffstat (limited to 'doc')
-rwxr-xr-xdoc/postprocess.py21
-rwxr-xr-xdoc/summarize.py19
2 files changed, 15 insertions, 25 deletions
diff --git a/doc/postprocess.py b/doc/postprocess.py
index c7fbcc6e7..fb4ea1967 100755
--- a/doc/postprocess.py
+++ b/doc/postprocess.py
@@ -1,27 +1,20 @@
#!/usr/bin/env python
"""
-%prog MODE FILES...
-
Post-processes HTML and Latex files output by Sphinx.
-MODE is either 'html' or 'tex'.
-
"""
-import optparse
import io
def main():
- p = optparse.OptionParser(__doc__)
- options, args = p.parse_args()
-
- if len(args) < 1:
- p.error('no mode given')
+ import argparse
- mode = args.pop(0)
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('mode', help='file mode', choices=('html', 'tex'))
+ parser.add_argument('file', nargs='+', help='input file(s)')
+ args = parser.parse_args()
- if mode not in ('html', 'tex'):
- p.error('unknown mode %s' % mode)
+ mode = args.mode
- for fn in args:
+ for fn in args.file:
with io.open(fn, 'r', encoding="utf-8") as f:
if mode == 'html':
lines = process_html(fn, f.readlines())
diff --git a/doc/summarize.py b/doc/summarize.py
index 5a3088267..72897c5cb 100755
--- a/doc/summarize.py
+++ b/doc/summarize.py
@@ -1,14 +1,11 @@
#!/usr/bin/env python
"""
-summarize.py
-
Show a summary about which NumPy functions are documented and which are not.
"""
import collections.abc
import glob
import inspect
-import optparse
import os
import sys
@@ -59,13 +56,13 @@ ctypeslib ctypeslib.test
""".split()
def main():
- p = optparse.OptionParser(__doc__)
- p.add_option("-c", "--columns", action="store", type="int", dest="cols",
- default=3, help="Maximum number of columns")
- options, args = p.parse_args()
+ import argparse
- if len(args) != 0:
- p.error('Wrong number of arguments')
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument(
+ "-c", "--columns", type=int, default=3,
+ help="Maximum number of columns (default: %(default)d)")
+ args = parser.parse_args()
# prepare
fn = os.path.join(CUR_DIR, 'dump.xml')
@@ -90,13 +87,13 @@ def main():
print("--- %s\n" % filename)
last_filename = filename
print(" ** ", section)
- print(format_in_columns(sorted(names), options.cols))
+ print(format_in_columns(sorted(names), args.columns))
print("\n")
print("")
print("Undocumented")
print("============\n")
- print(format_in_columns(sorted(undocumented.keys()), options.cols))
+ print(format_in_columns(sorted(undocumented.keys()), args.columns))
def check_numpy():
documented = get_documented(glob.glob(SOURCE_DIR + '/*.rst'))