25 def genAPI(self, newStyle, basePackage, includePrivate): |
25 def genAPI(self, newStyle, basePackage, includePrivate): |
26 """ |
26 """ |
27 Method to generate the source code documentation. |
27 Method to generate the source code documentation. |
28 |
28 |
29 @param newStyle flag indicating the api generation for QScintilla 1.7 and |
29 @param newStyle flag indicating the api generation for QScintilla 1.7 and |
30 newer (boolean) |
30 newer (boolean) (ignored) |
31 @param basePackage name of the base package (string) |
31 @param basePackage name of the base package (string) |
32 @param includePrivate flag indicating to include |
32 @param includePrivate flag indicating to include |
33 private methods/functions (boolean) |
33 private methods/functions (boolean) |
34 @return The API information. (string) |
34 @return The API information. (string) |
35 """ |
35 """ |
36 self.includePrivate = includePrivate |
36 self.includePrivate = includePrivate |
37 self.newStyle = newStyle |
37 modulePath = self.module.name.split('.') |
38 if self.newStyle: |
38 if modulePath[-1] == '__init__': |
39 modulePath = self.module.name.split('.') |
39 del modulePath[-1] |
40 if modulePath[-1] == '__init__': |
40 if basePackage: |
41 del modulePath[-1] |
41 modulePath[0] = basePackage |
42 if basePackage: |
42 self.moduleName = "%s." % '.'.join(modulePath) |
43 modulePath[0] = basePackage |
|
44 self.moduleName = "%s." % '.'.join(modulePath) |
|
45 else: |
|
46 self.moduleName = "" |
|
47 self.api = [] |
43 self.api = [] |
48 self.__addGlobalsAPI() |
44 self.__addGlobalsAPI() |
49 self.__addClassesAPI() |
45 self.__addClassesAPI() |
50 self.__addFunctionsAPI() |
46 self.__addFunctionsAPI() |
51 return self.api |
47 return self.api |
62 |
58 |
63 def __addGlobalsAPI(self): |
59 def __addGlobalsAPI(self): |
64 """ |
60 """ |
65 Private method to generate the api section for global variables. |
61 Private method to generate the api section for global variables. |
66 """ |
62 """ |
67 if self.newStyle: |
63 moduleNameStr = "%s" % self.moduleName |
68 moduleNameStr = "%s" % self.moduleName |
|
69 else: |
|
70 moduleNameStr = "" |
|
71 |
64 |
72 for globalName in sorted(self.module.globals.keys()): |
65 for globalName in sorted(self.module.globals.keys()): |
73 if not self.__isPrivate(self.module.globals[globalName]): |
66 if not self.__isPrivate(self.module.globals[globalName]): |
74 if self.module.globals[globalName].isPublic(): |
67 if self.module.globals[globalName].isPublic(): |
75 id = Editor.AttributeID |
68 id = Editor.AttributeID |
107 id = Editor.ClassPrivateID |
100 id = Editor.ClassPrivateID |
108 self.api.append('%s%s?%d(%s)' % \ |
101 self.api.append('%s%s?%d(%s)' % \ |
109 (self.moduleName, _class.name, id, |
102 (self.moduleName, _class.name, id, |
110 ', '.join(_class.methods['__init__'].parameters[1:]))) |
103 ', '.join(_class.methods['__init__'].parameters[1:]))) |
111 |
104 |
112 if self.newStyle: |
105 classNameStr = "%s%s." % (self.moduleName, className) |
113 classNameStr = "%s%s." % (self.moduleName, className) |
|
114 else: |
|
115 classNameStr = "" |
|
116 for method in methods: |
106 for method in methods: |
117 if not self.__isPrivate(_class.methods[method]): |
107 if not self.__isPrivate(_class.methods[method]): |
118 if _class.methods[method].isPublic(): |
108 if _class.methods[method].isPublic(): |
119 id = Editor.MethodID |
109 id = Editor.MethodID |
120 elif _class.methods[method].isProtected(): |
110 elif _class.methods[method].isProtected(): |
130 Private method to generate class api section for class variables. |
120 Private method to generate class api section for class variables. |
131 |
121 |
132 @param classname Name of the class containing the class variables. (string) |
122 @param classname Name of the class containing the class variables. (string) |
133 """ |
123 """ |
134 _class = self.module.classes[className] |
124 _class = self.module.classes[className] |
135 if self.newStyle: |
125 classNameStr = "%s%s." % (self.moduleName, className) |
136 classNameStr = "%s%s." % (self.moduleName, className) |
|
137 else: |
|
138 classNameStr = "" |
|
139 for variable in sorted(_class.globals.keys()): |
126 for variable in sorted(_class.globals.keys()): |
140 if not self.__isPrivate(_class.globals[variable]): |
127 if not self.__isPrivate(_class.globals[variable]): |
141 if _class.globals[variable].isPublic(): |
128 if _class.globals[variable].isPublic(): |
142 id = Editor.AttributeID |
129 id = Editor.AttributeID |
143 elif _class.globals[variable].isProtected(): |
130 elif _class.globals[variable].isProtected(): |