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
590e7ace
Commit
590e7ace
authored
May 15, 2019
by
Dan
Committed by
Wenzel Jakob
Jun 11, 2019
Browse files
Avoid storing global state.
parent
a163f881
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
tools/mkdoc.py
tools/mkdoc.py
+7
-9
No files found.
tools/mkdoc.py
View file @
590e7ace
...
@@ -57,8 +57,6 @@ CPP_OPERATORS = OrderedDict(
...
@@ -57,8 +57,6 @@ CPP_OPERATORS = OrderedDict(
job_count
=
cpu_count
()
job_count
=
cpu_count
()
job_semaphore
=
Semaphore
(
job_count
)
job_semaphore
=
Semaphore
(
job_count
)
output
=
[]
class
NoFilenamesError
(
ValueError
):
class
NoFilenamesError
(
ValueError
):
pass
pass
...
@@ -188,7 +186,7 @@ def process_comment(comment):
...
@@ -188,7 +186,7 @@ def process_comment(comment):
return
result
.
rstrip
().
lstrip
(
'
\n
'
)
return
result
.
rstrip
().
lstrip
(
'
\n
'
)
def
extract
(
filename
,
node
,
prefix
):
def
extract
(
filename
,
node
,
prefix
,
output
):
if
not
(
node
.
location
.
file
is
None
or
if
not
(
node
.
location
.
file
is
None
or
os
.
path
.
samefile
(
d
(
node
.
location
.
file
.
name
),
filename
)):
os
.
path
.
samefile
(
d
(
node
.
location
.
file
.
name
),
filename
)):
return
0
return
0
...
@@ -199,7 +197,7 @@ def extract(filename, node, prefix):
...
@@ -199,7 +197,7 @@ def extract(filename, node, prefix):
sub_prefix
+=
'_'
sub_prefix
+=
'_'
sub_prefix
+=
d
(
node
.
spelling
)
sub_prefix
+=
d
(
node
.
spelling
)
for
i
in
node
.
get_children
():
for
i
in
node
.
get_children
():
extract
(
filename
,
i
,
sub_prefix
)
extract
(
filename
,
i
,
sub_prefix
,
output
)
if
node
.
kind
in
PRINT_LIST
:
if
node
.
kind
in
PRINT_LIST
:
comment
=
d
(
node
.
raw_comment
)
if
node
.
raw_comment
is
not
None
else
''
comment
=
d
(
node
.
raw_comment
)
if
node
.
raw_comment
is
not
None
else
''
comment
=
process_comment
(
comment
)
comment
=
process_comment
(
comment
)
...
@@ -208,15 +206,15 @@ def extract(filename, node, prefix):
...
@@ -208,15 +206,15 @@ def extract(filename, node, prefix):
sub_prefix
+=
'_'
sub_prefix
+=
'_'
if
len
(
node
.
spelling
)
>
0
:
if
len
(
node
.
spelling
)
>
0
:
name
=
sanitize_name
(
sub_prefix
+
d
(
node
.
spelling
))
name
=
sanitize_name
(
sub_prefix
+
d
(
node
.
spelling
))
global
output
output
.
append
((
name
,
filename
,
comment
))
output
.
append
((
name
,
filename
,
comment
))
class
ExtractionThread
(
Thread
):
class
ExtractionThread
(
Thread
):
def
__init__
(
self
,
filename
,
parameters
):
def
__init__
(
self
,
filename
,
parameters
,
output
):
Thread
.
__init__
(
self
)
Thread
.
__init__
(
self
)
self
.
filename
=
filename
self
.
filename
=
filename
self
.
parameters
=
parameters
self
.
parameters
=
parameters
self
.
output
=
output
job_semaphore
.
acquire
()
job_semaphore
.
acquire
()
def
run
(
self
):
def
run
(
self
):
...
@@ -225,7 +223,7 @@ class ExtractionThread(Thread):
...
@@ -225,7 +223,7 @@ class ExtractionThread(Thread):
index
=
cindex
.
Index
(
index
=
cindex
.
Index
(
cindex
.
conf
.
lib
.
clang_createIndex
(
False
,
True
))
cindex
.
conf
.
lib
.
clang_createIndex
(
False
,
True
))
tu
=
index
.
parse
(
self
.
filename
,
self
.
parameters
)
tu
=
index
.
parse
(
self
.
filename
,
self
.
parameters
)
extract
(
self
.
filename
,
tu
.
cursor
,
''
)
extract
(
self
.
filename
,
tu
.
cursor
,
''
,
self
.
output
)
finally
:
finally
:
job_semaphore
.
release
()
job_semaphore
.
release
()
...
@@ -300,9 +298,9 @@ def mkdoc(args, out_file=sys.stdout):
...
@@ -300,9 +298,9 @@ def mkdoc(args, out_file=sys.stdout):
#endif
#endif
'''
,
file
=
out_file
)
'''
,
file
=
out_file
)
output
.
clear
()
output
=
[]
for
filename
in
filenames
:
for
filename
in
filenames
:
thr
=
ExtractionThread
(
filename
,
parameters
)
thr
=
ExtractionThread
(
filename
,
parameters
,
output
)
thr
.
start
()
thr
.
start
()
print
(
'Waiting for jobs to finish ..'
,
file
=
sys
.
stderr
)
print
(
'Waiting for jobs to finish ..'
,
file
=
sys
.
stderr
)
...
...
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