Update of /cvsroot/happydoc/HappyDoc/happydoclib/formatter
In directory usw-pr-cvs1:/tmp/cvs-serv11703/happydoclib/formatter
Modified Files:
formatter_HTMLFile.py
Log Message:
Potential fix for defect 515232, to convert platform-specific
filenames to URL paths.
Index: formatter_HTMLFile.py
===================================================================
RCS file: /cvsroot/happydoc/HappyDoc/happydoclib/formatter/formatter_HTMLFile.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** formatter_HTMLFile.py 3 Feb 2002 18:50:09 -0000 1.4
--- formatter_HTMLFile.py 10 Feb 2002 13:37:12 -0000 1.5
***************
*** 192,195 ****
--- 192,208 ----
##
+ def _fixReference(self, reference, sep=os.sep):
+ """All HTML links use the '/' separator, so here the current
+ platform separator needs to be replaced with the '/'.
+ """
+ happydoclib.TRACE.into('HTMLTableFormatter', '_fixReference',
+ reference=reference)
+ new_ref = reference.replace(sep, '/')
+ if sep == ':':
+ if new_ref[:4] == 'http':
+ new_ref = 'http://%s' % new_ref[5:]
+ return happydoclib.TRACE.outof(new_ref)
+
+
def getReference(self, infoSource, relativeSource, name=None):
"""Returns a reference to the 'infoSource' from 'relativeSource'.
***************
*** 201,205 ****
if not name:
name = self.getNameForInfoSource( infoSource )
! #print 'FORMATTER_HTMLFILE: getReference(', name, ',', relativeSource, ')'
info_source_path = self.getOutputNameForObject( infoSource )
link = happydoclib.path.computeRelativeHTMLLink(
--- 214,221 ----
if not name:
name = self.getNameForInfoSource( infoSource )
! happydoclib.TRACE.into('HTMLTableFormatter', 'getReference',
! name=name,
! relativeSource=relativeSource,
! )
info_source_path = self.getOutputNameForObject( infoSource )
link = happydoclib.path.computeRelativeHTMLLink(
***************
*** 208,214 ****
self._docset.getOutputBaseDirectory()
)
! #print 'FORMATTER_HTMLFILE: link to %s: %s' % (name, link)
! #if link[0] == '/':
! # print 'FORMATTER_HTMLFILE: STARTS AT ROOT'
info = {
--- 224,232 ----
self._docset.getOutputBaseDirectory()
)
! happydoclib.TRACE.write('link to %s: %s' % (name, link))
! if link[0] == '/':
! happydoclib.TRACE.write('starts at root')
!
! link = self._fixReference(link)
info = {
***************
*** 217,221 ****
}
ref = '<a href="%(link)s">%(name)s</a>' % info
! return ref
def getNamedReference(self, infoSource, name, relativeSource):
--- 235,240 ----
}
ref = '<a href="%(link)s">%(name)s</a>' % info
! return happydoclib.TRACE.outof(ref)
!
def getNamedReference(self, infoSource, name, relativeSource):
***************
*** 223,229 ****
'infoSource' from 'relativeSource'.
"""
! #print '\nFORMATTER: getNamedReference(', \
! # infoSource.getName(), ',', name, ',', relativeSource, ')'
! #print '\toutput name:', self.getOutputNameForObject(infoSource)
link = happydoclib.path.computeRelativeHTMLLink(
--- 242,251 ----
'infoSource' from 'relativeSource'.
"""
! happydoclib.TRACE.into('HTMLTableFormatter', 'getNamedReference',
! infoSource=infoSource.getName(),
! name=name,
! relativeSource=relativeSource,
! )
! happydoclib.TRACE.writeVar(output_name=self.getOutputNameForObject(infoSource))
link = happydoclib.path.computeRelativeHTMLLink(
***************
*** 232,236 ****
self._docset.getOutputBaseDirectory()
)
! #print '\tLINK:', link
info = {
'name':infoSource.getName(),
--- 254,262 ----
self._docset.getOutputBaseDirectory()
)
!
! happydoclib.TRACE.writeVar(link=link)
!
! link = self._fixReference(link)
!
info = {
'name':infoSource.getName(),
***************
*** 239,244 ****
}
ref = '<a href="%(link)s#%(target)s">%(target)s</a>' % info
! #print '\tREF:', ref
! return ref
def getInternalReference(self, infoSource):
--- 265,271 ----
}
ref = '<a href="%(link)s#%(target)s">%(target)s</a>' % info
!
! return happydoclib.TRACE.outof(ref)
!
def getInternalReference(self, infoSource):
***************
*** 461,466 ****
else:
root_node_name = 'index.html'
! happydoclib.TRACE.outof(root_node_name)
! return root_node_name
##
--- 488,492 ----
else:
root_node_name = 'index.html'
! return happydoclib.TRACE.outof(root_node_name)
##
***************
*** 782,787 ****
(reference, expected_reference)
return
!
!
if __name__ == '__main__':
--- 808,853 ----
(reference, expected_reference)
return
!
! def testFixReferencesWindows(self):
! filenames = [ os.path.join(os.curdir, 'happydoclib', 'CommandLineApp.py') ]
! import happydoclib.parseinfo
! import happydoclib.happydocset
! docset = happydoclib.happydocset.DocSet(
! formatterFactory=HTMLTableFormatter,
! parserFunc=happydoclib.parseinfo.getDocs,
! defaultParserConfigValues={'docStringFormat':'StructuredText'},
! inputModuleNames=filenames,
! outputBaseDirectory=self.output_dir,
! )
! cla = docset[0]
! formatter = docset._formatter
!
! input = 'http:\\\\full\\url\\path\\index.html'
! expected = 'http://full/url/path/index.html'
! actual = formatter._fixReference(input, sep='\\')
! assert expected == actual, \
! 'Fixing Windows URL failed (%s, %s)' % (expected, actual)
! return
!
! def testFixReferencesMacOS(self):
! filenames = [ os.path.join(os.curdir, 'happydoclib', 'CommandLineApp.py') ]
! import happydoclib.parseinfo
! import happydoclib.happydocset
! docset = happydoclib.happydocset.DocSet(
! formatterFactory=HTMLTableFormatter,
! parserFunc=happydoclib.parseinfo.getDocs,
! defaultParserConfigValues={'docStringFormat':'StructuredText'},
! inputModuleNames=filenames,
! outputBaseDirectory=self.output_dir,
! )
! cla = docset[0]
! formatter = docset._formatter
!
! input = 'http:full:url:path:index.html'
! expected = 'http://full/url/path/index.html'
! actual = formatter._fixReference(input, sep=':')
! assert expected == actual, \
! 'Fixing MacOS URL failed (%s, %s)' % (expected, actual)
! return
if __name__ == '__main__':
|