Skip to content

Commit e8194a5

Browse files
and2345Andreas Kunze
andauthored
fix: generated pybind11-mkdoc console script should work now (#20)
Co-authored-by: Andreas Kunze <andreas.kunze@watttron.com>
1 parent 93214d7 commit e8194a5

File tree

2 files changed

+55
-54
lines changed

2 files changed

+55
-54
lines changed

pybind11_mkdoc/__init__.py

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,56 @@
1212

1313
__version__ = "2.6.1.dev1"
1414

15-
def main(self):
16-
return mkdoc(sys.argv[:1])
15+
def main():
16+
mkdoc_out = None
17+
mkdoc_help = False
18+
mkdoc_args = []
19+
docstring_width = None
20+
21+
i = 1
22+
while i < len(sys.argv):
23+
arg = sys.argv[i]
24+
25+
if arg == '-h':
26+
mkdoc_help = True
27+
elif arg == '-o':
28+
mkdoc_out = sys.argv[i + 1]
29+
i += 1 # Skip next
30+
elif arg.startswith('-o'):
31+
mkdoc_out = arg[2:]
32+
elif arg == '-w':
33+
docstring_width = int(sys.argv[i + 1])
34+
i += 1 # Skip next
35+
elif arg.startswith('-w'):
36+
docstring_width = int(arg[2:])
37+
elif arg == '-I':
38+
# Concatenate include directive and path
39+
mkdoc_args.append(arg + sys.argv[i + 1])
40+
i += 1 # Skip next
41+
else:
42+
mkdoc_args.append(arg)
43+
i += 1
44+
45+
if len(mkdoc_args) == 0 or mkdoc_help:
46+
print("""Syntax: python -m pybind11_mkdoc [options] .. list of headers files ..
47+
48+
This tool processes a sequence of C/C++ headers and extracts comments for use
49+
in pybind11 binding code.
50+
51+
Options:
52+
53+
-h Display this help text
54+
55+
-o <filename> Write to the specified filename (default: use stdout)
56+
57+
-w <width> Specify docstring width before wrapping
58+
59+
-I <path> Specify an include directory
60+
61+
-Dkey=value Specify a compiler definition
62+
63+
(Other compiler flags that Clang understands can also be supplied)""")
64+
else:
65+
mkdoc(mkdoc_args, docstring_width, mkdoc_out)
66+
67+
return 0

pybind11_mkdoc/__main__.py

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,5 @@
1-
from .mkdoc_lib import mkdoc
2-
import sys
3-
41

52
if __name__ == "__main__":
6-
mkdoc_out = None
7-
mkdoc_help = False
8-
mkdoc_args = []
9-
docstring_width = None
10-
11-
i = 1
12-
while i < len(sys.argv):
13-
arg = sys.argv[i]
14-
15-
if arg == '-h':
16-
mkdoc_help = True
17-
elif arg == '-o':
18-
mkdoc_out = sys.argv[i + 1]
19-
i += 1 # Skip next
20-
elif arg.startswith('-o'):
21-
mkdoc_out = arg[2:]
22-
elif arg == '-w':
23-
docstring_width = int(sys.argv[i + 1])
24-
i += 1 # Skip next
25-
elif arg.startswith('-w'):
26-
docstring_width = int(arg[2:])
27-
elif arg == '-I':
28-
# Concatenate include directive and path
29-
mkdoc_args.append(arg + sys.argv[i + 1])
30-
i += 1 # Skip next
31-
else:
32-
mkdoc_args.append(arg)
33-
i += 1
34-
35-
if len(mkdoc_args) == 0 or mkdoc_help:
36-
print("""Syntax: python -m pybind11_mkdoc [options] .. list of headers files ..
37-
38-
This tool processes a sequence of C/C++ headers and extracts comments for use
39-
in pybind11 binding code.
40-
41-
Options:
42-
43-
-h Display this help text
44-
45-
-o <filename> Write to the specified filename (default: use stdout)
46-
47-
-w <width> Specify docstring width before wrapping
48-
49-
-I <path> Specify an include directory
50-
51-
-Dkey=value Specify a compiler definition
3+
from . import main
4+
main()
525

53-
(Other compiler flags that Clang understands can also be supplied)""")
54-
else:
55-
mkdoc(mkdoc_args, docstring_width, mkdoc_out)

0 commit comments

Comments
 (0)