-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathobjects.py
More file actions
90 lines (60 loc) · 1.99 KB
/
objects.py
File metadata and controls
90 lines (60 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import os
import types
import inspect
import io
import mapscript
OUTPUT_FUNCTIONS_FILE = r"../../en/mapscript/mapscript-api/functions.rst"
OUTPUT_CLASSES_FILE = r"../../en/mapscript/mapscript-api/classes.rst"
def write_output(output_file, header, output):
with io.open(output_file, "w", newline="\n") as f:
f.write(header)
for p in sorted(output):
f.write(" {}\n".format(p))
def get_properties():
props = dir(mapscript)
constants = [p for p in props if isinstance(getattr(mapscript, p), int)]
properties = [
p
for p in props
if p not in constants
and not p.endswith("_swigregister")
and not p.startswith("_")
# the following don't have docstrings and are hidden for now
and p not in ("MapServerError", "MapServerChildError", "intarray", "CompositingFilter",
"LayerCompositer", "intarray_frompointer")
]
return properties
def output_classes(output_file):
properties = get_properties()
print("The following classes are available in mapscript:")
classes = [p for p in properties if inspect.isclass(getattr(mapscript, p))]
for c in classes:
print(" {}".format(c))
header = """
.. currentmodule:: mapscript
.. autosummary::
:toctree: stub
:template: class.rst
"""
write_output(output_file, header, classes)
def output_functions(output_file):
properties = get_properties()
print("The following functions are available on the mapscript object:")
functions = [
"mapscript.{}".format(p)
for p in properties
if isinstance(getattr(mapscript, p), types.FunctionType)
]
for f in sorted(functions):
print(" {}".format(f))
header = """
.. currentmodule:: mapscript
.. autosummary::
"""
write_output(output_file, header, functions)
def main():
output_functions(OUTPUT_FUNCTIONS_FILE)
output_classes(OUTPUT_CLASSES_FILE)
if __name__ == "__main__":
main()
print("Done!")