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

Skip to content

Commit 56aa628

Browse files
committed
list_documented_items(): Basic implementation.
This still does not work well since ctags does not do a good job with the Python headers, appearantly due to the DL_IMPORT macro. ;-(
1 parent a65375c commit 56aa628

1 file changed

Lines changed: 33 additions & 4 deletions

File tree

Doc/tools/findcsyms

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import errno
44
import os
5+
import re
56
import sys
67

78
if __name__ == "__main__":
@@ -25,10 +26,38 @@ def list_headers():
2526
return [fn for fn in os.listdir(incdir)
2627
if fn.endswith(".h") and fn not in EXCLUDES]
2728

29+
30+
def matcher(pattern):
31+
return re.compile(pattern).match
32+
33+
MATCHERS = [
34+
matcher(r"\\begin\{cfuncdesc\}\{[^{]*\}\{(?P<sym>[^{]*)\}"),
35+
matcher(r"\\cfuncline\{[^{]*\}\{(?P<sym>[^{]*)\}"),
36+
matcher(r"\\begin\{ctypedesc\}(\[[^{]*\])?\{(?P<sym>[^{]*)\}"),
37+
matcher(r"\\begin\{cvardesc\}\{[^{]*\}\{(?P<sym>[^{]*)\}"),
38+
matcher(r"\\begin\{cmemberdesc\}\{[^{]*\}\{(?P<sym>[^{]*)\}"),
39+
matcher(r"\\cmemberline\{[^{]*\}\{(?P<sym>[^{]*)\}"),
40+
matcher(r"\\begin\{csimplemacrodesc\}\{(?P<sym>[^{]*)\}"),
41+
]
42+
43+
2844
def list_documented_items():
2945
"""Return a list of everything that's already documented."""
30-
docdir = os.path.join(srcdir, "Doc")
31-
return []
46+
apidir = os.path.join(srcdir, "Doc", "api")
47+
files = [fn for fn in os.listdir(apidir) if fn.endswith(".tex")]
48+
L = []
49+
for fn in files:
50+
fullname = os.path.join(apidir, fn)
51+
for line in open(fullname):
52+
line = line.lstrip()
53+
if not line.startswith("\\"):
54+
continue
55+
for matcher in MATCHERS:
56+
m = matcher(line)
57+
if m:
58+
L.append(m.group("sym"))
59+
break
60+
return L
3261

3362
def split_documented(all, documented):
3463
"""Split the list of all symbols into documented and undocumented
@@ -70,8 +99,8 @@ def main():
7099
headers = list_headers()
71100
documented = list_documented_items()
72101

73-
cmd = ("ctags -f - --file-scope=no --c-types=-mv "
74-
"-Istaticforward -Istatichere "
102+
cmd = ("ctags -f - --file-scope=no --c-types=dgpstux "
103+
"-Istaticforward -Istatichere=static "
75104
+ _spcjoin(headers))
76105
fp = os.popen(cmd)
77106
L = []

0 commit comments

Comments
 (0)