Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
pybind11
Commits
2c8c5c4e
"testing/python/vscode:/vscode.git/clone" did not exist on "bb8b3cd790b65f88d309c9d6b6dc82156f5281c9"
Commit
2c8c5c4e
authored
May 15, 2019
by
Dan
Committed by
Wenzel Jakob
Jun 11, 2019
Browse files
Split into seperate functions for easier invocation from python.
parent
590e7ace
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
25 deletions
+37
-25
tools/mkdoc.py
tools/mkdoc.py
+37
-25
No files found.
tools/mkdoc.py
View file @
2c8c5c4e
...
@@ -228,7 +228,7 @@ class ExtractionThread(Thread):
...
@@ -228,7 +228,7 @@ class ExtractionThread(Thread):
job_semaphore
.
release
()
job_semaphore
.
release
()
def
mkdoc
(
args
,
out_file
=
sys
.
stdout
):
def
extract_all
(
args
):
parameters
=
[]
parameters
=
[]
filenames
=
[]
filenames
=
[]
if
"-x"
not
in
args
:
if
"-x"
not
in
args
:
...
@@ -273,6 +273,19 @@ def mkdoc(args, out_file=sys.stdout):
...
@@ -273,6 +273,19 @@ def mkdoc(args, out_file=sys.stdout):
if
len
(
filenames
)
==
0
:
if
len
(
filenames
)
==
0
:
raise
NoFilenamesError
(
"args parameter did not contain any filenames"
)
raise
NoFilenamesError
(
"args parameter did not contain any filenames"
)
output
=
[]
for
filename
in
filenames
:
thr
=
ExtractionThread
(
filename
,
parameters
,
output
)
thr
.
start
()
print
(
'Waiting for jobs to finish ..'
,
file
=
sys
.
stderr
)
for
i
in
range
(
job_count
):
job_semaphore
.
acquire
()
return
output
def
write_header
(
comments
,
out_file
=
sys
.
stdout
):
print
(
'''/*
print
(
'''/*
This file contains docstrings for the Python bindings.
This file contains docstrings for the Python bindings.
Do not edit! These were automatically extracted by mkdoc.py
Do not edit! These were automatically extracted by mkdoc.py
...
@@ -298,18 +311,10 @@ def mkdoc(args, out_file=sys.stdout):
...
@@ -298,18 +311,10 @@ def mkdoc(args, out_file=sys.stdout):
#endif
#endif
'''
,
file
=
out_file
)
'''
,
file
=
out_file
)
output
=
[]
for
filename
in
filenames
:
thr
=
ExtractionThread
(
filename
,
parameters
,
output
)
thr
.
start
()
print
(
'Waiting for jobs to finish ..'
,
file
=
sys
.
stderr
)
for
i
in
range
(
job_count
):
job_semaphore
.
acquire
()
name_ctr
=
1
name_ctr
=
1
name_prev
=
None
name_prev
=
None
for
name
,
_
,
comment
in
list
(
sorted
(
output
,
key
=
lambda
x
:
(
x
[
0
],
x
[
1
]))):
for
name
,
_
,
comment
in
list
(
sorted
(
comments
,
key
=
lambda
x
:
(
x
[
0
],
x
[
1
]))):
if
name
==
name_prev
:
if
name
==
name_prev
:
name_ctr
+=
1
name_ctr
+=
1
name
=
name
+
"_%i"
%
name_ctr
name
=
name
+
"_%i"
%
name_ctr
...
@@ -326,8 +331,8 @@ def mkdoc(args, out_file=sys.stdout):
...
@@ -326,8 +331,8 @@ def mkdoc(args, out_file=sys.stdout):
'''
,
file
=
out_file
)
'''
,
file
=
out_file
)
if
__name__
==
'__main__'
:
def
mkdoc
(
args
)
:
args
=
sys
.
argv
[
1
:]
args
=
list
(
args
)
out_path
=
None
out_path
=
None
for
idx
,
arg
in
enumerate
(
args
):
for
idx
,
arg
in
enumerate
(
args
):
if
arg
.
startswith
(
"-o"
):
if
arg
.
startswith
(
"-o"
):
...
@@ -338,21 +343,28 @@ if __name__ == '__main__':
...
@@ -338,21 +343,28 @@ if __name__ == '__main__':
print
(
"-o flag requires an argument"
)
print
(
"-o flag requires an argument"
)
exit
(
-
1
)
exit
(
-
1
)
break
break
try
:
if
out_path
:
comments
=
extract_all
(
args
)
if
out_path
:
try
:
with
open
(
out_path
,
'w'
)
as
out_file
:
write_header
(
comments
,
out_file
)
except
:
# In the event of an error, don't leave a partially-written
# output file.
try
:
try
:
with
open
(
out_path
,
'w'
)
as
out_file
:
os
.
unlink
(
out_path
)
mkdoc
(
args
,
out_file
)
except
:
except
:
# In the event of an error, don't leave a partially-written
pass
# output file.
raise
try
:
else
:
os
.
unlink
(
out_path
)
write_header
(
comments
)
except
:
pass
raise
if
__name__
==
'__main__'
:
else
:
try
:
mkdoc
(
args
)
mkdoc
(
sys
.
argv
[
1
:]
)
except
NoFilenamesError
:
except
NoFilenamesError
:
print
(
'Syntax: %s [.. a list of header files ..]'
%
sys
.
argv
[
0
])
print
(
'Syntax: %s [.. a list of header files ..]'
%
sys
.
argv
[
0
])
exit
(
-
1
)
exit
(
-
1
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment