MCPcopy Create free account
hub / github.com/bspaans/python-mingus / Documize

Class Documize

scripts/api_doc_generator.py:61–223  ·  view source on GitHub ↗

Generate documents from modules.

Source from the content-addressed store, hash-verified

59
60
61class Documize(object):
62
63 """Generate documents from modules."""
64
65 functions = []
66 classes = []
67 attributes = []
68
69 _ALLOWED_DUNDER_METHODS = {
70 '__add__',
71 '__del__',
72 '__eq__',
73 '__ge__',
74 '__getitem__',
75 '__gt__',
76 '__init__',
77 '__int__',
78 '__le__',
79 '__len__',
80 '__lt__',
81 '__ne__',
82 '__nonzero__',
83 '__repr__',
84 '__setitem__',
85 '__str__',
86 '__sub__',
87 }
88
89 def __init__(self, module_string=''):
90 self.set_module(module_string)
91
92 def _filter_dunder_attributes(self, attrs):
93 return (
94 attr
95 for attr in attrs
96 if not attr.startswith('__') or attr in self._ALLOWED_DUNDER_METHODS
97 )
98
99 def process_element_recursively(self, element_string, element_evaled, is_class = False):
100 for element in self._filter_dunder_attributes(dir(element_evaled)):
101 e = eval('{0}.{1}'.format(element_string, element))
102 if not callable(e):
103 self.generate_non_callable_docs(element_string, element, e, is_class)
104 else:
105 self.generate_callable_wikidocs(element_string, element, e, is_class)
106
107 def generate_module_wikidocs(self):
108 self.reset()
109 header = '=' * len(self.module_string)
110 res = '.. module:: %s\n\n' % self.module_string
111 res += '%s\n%s\n%s\n\n' % (header, self.module_string, header)
112
113 if self.module.__doc__ is not None:
114 res += self.module.__doc__ + '\n\n'
115
116 # Gather all the documentation
117 self.process_element_recursively(self.module_string, self.module)
118

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected