Modified module parser to flag PyQt signal definitions and the module documentor to exclude these from the list of attributes.

Mon, 20 Dec 2010 20:06:59 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 20 Dec 2010 20:06:59 +0100
changeset 766
0940de08fa75
parent 765
e5cbb3f273eb
child 767
27554f80d08f

Modified module parser to flag PyQt signal definitions and the module documentor to exclude these from the list of attributes.

DocumentationTools/ModuleDocumentor.py file | annotate | diff | comparison | revisions
Utilities/ModuleParser.py file | annotate | diff | comparison | revisions
--- a/DocumentationTools/ModuleDocumentor.py	Mon Dec 20 19:39:15 2010 +0100
+++ b/DocumentationTools/ModuleDocumentor.py	Mon Dec 20 20:06:59 2010 +0100
@@ -291,10 +291,13 @@
         @param class_ reference to a class object (Class)
         @return The globals list section. (string)
         """
+        attrNames = []
         if class_ is not None:
-            attrNames = sorted(class_.globals.keys())
+            scope = class_
         else:
-            attrNames = sorted(self.module.globals.keys())
+            scope = self.module
+        attrNames = sorted([attr for attr in scope.globals.keys() 
+                                 if not scope.globals[attr].isSignal])
         if attrNames:
             s = ''.join(
                 [self.listEntrySimpleTemplate.format(**{'Name' : name}) \
@@ -1032,4 +1035,4 @@
         if not self.generated:
             self.genDocument()
         
-        return self.keywords
\ No newline at end of file
+        return self.keywords
--- a/Utilities/ModuleParser.py	Mon Dec 20 19:39:15 2010 +0100
+++ b/Utilities/ModuleParser.py	Mon Dec 20 20:06:59 2010 +0100
@@ -131,7 +131,7 @@
         ^
         (?P<VariableIndent> [ \t]* )
         (?P<VariableName> \w+ )
-        [ \t]* =
+        [ \t]* = [ \t]* (?P<VariableSignal> (?:pyqtSignal)? )
     )
 
 |   (?P<Import>
@@ -651,11 +651,13 @@
             elif m.start("Variable") >= 0:
                 thisindent = _indent(m.group("VariableIndent"))
                 variable_name = m.group("VariableName")
+                isSignal = m.group("VariableSignal") != ""
                 lineno = lineno + src.count('\n', last_lineno_pos, start)
                 last_lineno_pos = start
                 if thisindent == 0:
                     # global variable
-                    attr = Attribute(self.name, variable_name, self.file, lineno)
+                    attr = Attribute(self.name, variable_name, self.file, lineno, 
+                                     isSignal = isSignal)
                     self.__py_setVisibility(attr)
                     self.addGlobal(variable_name, attr)
                 else:
@@ -666,7 +668,8 @@
                         else:
                             if classstack[index][0] is not None and \
                                isinstance(classstack[index][0], Class):
-                                attr = Attribute(self.name, variable_name, self.file, lineno)
+                                attr = Attribute(self.name, variable_name, self.file, 
+                                                 lineno, isSignal = isSignal)
                                 self.__py_setVisibility(attr)
                                 classstack[index][0].addGlobal(variable_name, attr)
                             break
@@ -1236,7 +1239,7 @@
     '''
     Class to represent a Python function or method.
     '''
-    def __init__(self, module, name, file, lineno):
+    def __init__(self, module, name, file, lineno, isSignal = False):
         """
         Constructor
         
@@ -1244,11 +1247,13 @@
         @param name name of the function (string)
         @param file name of file containing this function (string)
         @param lineno linenumber of the function definition (integer)
+        @keyparam isSignal flag indicating a signal definition (boolean)
         """
         self.module = module
         self.name = name
         self.file = file
         self.lineno = lineno
+        self.isSignal = isSignal
         self.setPublic()
 
 def readModule(module, path = [], inpackage = False, basename = "", 

eric ide

mercurial