[Happydoc-checkins] CVS: HappyDoc3/happydoclib scanner.py,1.6,1.7
Brought to you by:
doughellmann,
krlosaqp
From: Doug H. <dou...@us...> - 2002-12-08 17:01:33
|
Update of /cvsroot/happydoc/HappyDoc3/happydoclib In directory sc8-pr-cvs1:/tmp/cvs-serv10133/happydoclib Modified Files: scanner.py Log Message: Clean up docstrings from Python modules to remove the surrounding quotes. Add getPathToModule() for computing relative paths between nodes of the tree. Index: scanner.py =================================================================== RCS file: /cvsroot/happydoc/HappyDoc3/happydoclib/scanner.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** scanner.py 8 Dec 2002 16:23:24 -0000 1.6 --- scanner.py 8 Dec 2002 17:01:29 -0000 1.7 *************** *** 251,254 **** --- 251,266 ---- trace.outof(filename) return filename + + def _unquoteString(self, str): + "Remove surrounding quotes from a string." + str = str.strip() + while ( str + and + (str[0] == str[-1]) + and + str[0] in ('"', "'") + ): + str = str[1:-1] + return str def getDocStringAndFormat(self): *************** *** 258,261 **** --- 270,274 ---- if hasattr(self, 'module_info'): docstring = self.module_info.getDocString() + docstring = self._unquoteString(docstring) format = self.module_info.getDocStringFormat() return (docstring, format) *************** *** 349,352 **** --- 362,394 ---- trace.outof(path) return path + + def getPathToNode(self, otherNode): + """Returns a sequence of nodes to be traversed to reach the otherNode. + + The sequence assumes that traversal begins at the current node. + A '..' indicates moving up to the parent one level. + """ + my_path = self.getPath() + other_path = otherNode.getPath() + if my_path == other_path: + return () + + # + # Strip the top parts of the paths which match. + # + while my_path and other_path and my_path[0] == other_path[0]: + my_path = my_path[1:] + other_path = other_path[1:] + + if self.items(): + is_file = 0 + else: + is_file = 1 + + going_up = ('..',) * (len(my_path) - is_file) + + relative_path = going_up + other_path + + return relative_path def addSubNode(self, name): |