#!/usr/bin/env python # ex:ts=4:sw=4:sts=4:et # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- # # Copyright (C) 2005 Holger Hans Peter Freyther # # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT # SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR # THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # import optparse, os, sys # bitbake sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) import bb import bb.parse from string import split, join __version__ = "0.0.2" class HTMLFormatter: """ Simple class to help to generate some sort of HTML files. It is quite inferior solution compared to docbook, gtkdoc, doxygen but it should work for now. We've a global introduction site (index.html) and then one site for the list of keys (alphabetical sorted) and one for the list of groups, one site for each key with links to the relations and groups. index.html all_keys.html all_groups.html groupNAME.html keyNAME.html """ def replace(self, text, *pairs): """ From pydoc... almost identical at least """ while pairs: (a,b) = pairs[0] text = join(split(text, a), b) pairs = pairs[1:] return text def escape(self, text): """ Escape string to be conform HTML """ return self.replace(text, ('&', '&'), ('<', '<' ), ('>', '>' ) ) def createNavigator(self): """ Create the navgiator """ return """
| Home | Groups | Keys |
See also:
"
txts = []
for it in item.related():
txts.append("""%(it)s""" % vars() )
return txt + ",".join(txts)
def groups(self,item):
"""
Create HTML to link to related groups
"""
if len(item.groups()) == 0:
return ""
txt = "
See also:
"
txts = []
for group in item.groups():
txts.append( """%s """ % (group,group) )
return txt + ",".join(txts)
def createKeySite(self,item):
"""
Create a site for a key. It contains the header/navigator, a heading,
the description, links to related keys and to the groups.
"""
return """
%s
%s
%s
%s