1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | #!/usr/bin/env python
# Horribly hacked-together script to generate an HTML index page for
# Haddock-generated Haskell package docs. Note that the docs
# directory is hard-coded, below: see the comments there.
import os
import re
import StringIO
# This is the path to the docs. Any subdirectory which contains an
# 'html/index.html' will get an entry in the index (all the other are
# listed separately at the end).
# The index is written to 'index.html' at this path.
PATH = "/usr/local/share/doc"
class Package:
def __init__(self, name, path):
self.name = name
self.path = path
self.title = self._seekTitle()
def __cmp__(self, other):
return cmp(self.name.lower(), other.name.lower())
def index(self):
return os.path.join(self.path, 'html', 'index.html')
titleRE = r'>.*: (.*)</TITLE'
def _seekTitle(self):
f = open(self.index())
d = f.read()
f.close()
m = re.search(self.titleRE, d)
if not m:
raise ValueError, "Can't extract title from %s" % self.index()
return m.group(1)
class Builder:
def __init__(self, path):
self.path = path
libs = [l for l in os.listdir(self.path)
if os.path.isdir(os.path.join(path, l))]
self.has_html = []
self.no_html = []
for lib in libs:
full = os.path.join(path, lib)
if self.seek_html(full):
self.has_html.append(Package(lib, full))
else:
self.no_html.append((lib, full))
self.has_html.sort()
p = os.path.join(path, 'index.html')
o = open(p, 'w')
o.write(self.html())
o.close()
def html(self):
s = StringIO.StringIO()
s.write('<html>\n')
s.write('<head>\n')
s.write('<title>Local Haskell package docs (from Haddock)</title>\n')
s.write(('<link rel="stylesheet" type="text/css" '
'href="http://hackage.haskell.org/packages/hackage.css"/>\n'))
s.write('</head>\n')
s.write('<body>\n')
s.write('<h2>Local packages with docs</h2>\n')
split = self.splitAlpha()
keys = split.keys()
keys.sort()
s.write('<p class="toc">\n')
links = ['<a href="#%s">%s</a>' % (start, start) for start in keys]
s.write(' • '.join(links))
s.write('</p>\n')
for start in keys:
packages = split[start]
s.write('<h3 class="category"><a name="%s">%s</a></h3>\n' % (start, start))
s.write(' <ul class="packages">\n')
for package in packages:
s.write(' <li>')
s.write('<a href="file://%s">' % package.path)
s.write(package.name)
s.write('</a>: %s</li>\n' % package.title)
s.write(' </ul>\n')
s.write('<hr />')
s.write('<h2>Directories without HTML docs</h2>\n')
s.write('<ul>\n')
for (name, path) in self.no_html:
s.write(' <li><a href="file://%s">%s</li>\n' % (path, name))
s.write('</ul>\n')
s.write('</body>\n')
s.write('</html>\n')
h = s.getvalue()
return h
def splitAlpha(self):
al = {}
for package in self.has_html:
start = package.name[0].upper()
try:
al[start].append(package)
except KeyError:
al[start] = [package]
return al
def seek_html(self, path):
items = os.listdir(path)
if 'html' not in items:
return False
html = os.path.join(path, 'html')
if not os.path.isdir(html):
return False
return 'index.html' in os.listdir(html)
if __name__ == '__main__':
builder = Builder(PATH)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | #!/usr/bin/env python
# Horribly hacked-together script to generate an HTML index page for
# Haddock-generated Haskell package docs. Note that the docs
# directory is hard-coded, below: see the comments there.
import os
import re
import StringIO
# This is the path to the docs. Any subdirectory which contains an
# 'html/index.html' will get an entry in the index (all the other are
# listed separately at the end).
# The index is written to 'index.html' at this path.
PATH = "/usr/local/share/doc"
class Package:
def __init__(self, name, path):
self.name = name
self.path = path
self.title = self._seekTitle()
def __cmp__(self, other):
return cmp(self.name.lower(), other.name.lower())
def index(self):
return os.path.join(self.path, 'html', 'index.html')
titleRE = r'>.*: (.*)</TITLE'
def _seekTitle(self):
f = open(self.index())
d = f.read()
f.close()
m = re.search(self.titleRE, d)
if not m:
raise ValueError, "Can't extract title from %s" % self.index()
return m.group(1)
class Builder:
def __init__(self, path):
self.path = path
libs = [l for l in os.listdir(self.path)
if os.path.isdir(os.path.join(path, l))]
self.has_html = []
self.no_html = []
for lib in libs:
full = os.path.join(path, lib)
if self.seek_html(full):
self.has_html.append(Package(lib, full))
else:
self.no_html.append((lib, full))
self.has_html.sort()
p = os.path.join(path, 'index.html')
o = open(p, 'w')
o.write(self.html())
o.close()
def html(self):
s = StringIO.StringIO()
s.write('<html>\n')
s.write('<head>\n')
s.write('<title>Local Haskell package docs (from Haddock)</title>\n')
s.write(('<link rel="stylesheet" type="text/css" '
'href="http://hackage.haskell.org/packages/hackage.css"/>\n'))
s.write('</head>\n')
s.write('<body>\n')
s.write('<h2>Local packages with docs</h2>\n')
split = self.splitAlpha()
keys = split.keys()
keys.sort()
s.write('<p class="toc">\n')
links = ['<a href="#%s">%s</a>' % (start, start) for start in keys]
s.write(' • '.join(links))
s.write('</p>\n')
for start in keys:
packages = split[start]
s.write('<h3 class="category"><a name="%s">%s</a></h3>\n' % (start, start))
s.write(' <ul class="packages">\n')
for package in packages:
s.write(' <li>')
s.write('<a href="file://%s">' % os.path.join(package.path, 'html', 'index.html'))
s.write(package.name)
s.write('</a>: %s</li>\n' % package.title)
s.write(' </ul>\n')
s.write('<hr />')
s.write('<h2>Directories without HTML docs</h2>\n')
s.write('<ul>\n')
for (name, path) in self.no_html:
s.write(' <li><a href="file://%s">%s</li>\n' % (path, name))
s.write('</ul>\n')
s.write('</body>\n')
s.write('</html>\n')
h = s.getvalue()
return h
def splitAlpha(self):
al = {}
for package in self.has_html:
start = package.name[0].upper()
try:
al[start].append(package)
except KeyError:
al[start] = [package]
return al
def seek_html(self, path):
items = os.listdir(path)
if 'html' not in items:
return False
html = os.path.join(path, 'html')
if not os.path.isdir(html):
return False
return 'index.html' in os.listdir(html)
if __name__ == '__main__':
builder = Builder(PATH)
|
1 | Le4h3B <a href="http://nqzbozordree.com/">nqzbozordree</a>, [url=http://tbotyycufbdq.com/]tbotyycufbdq[/url], [link=http://sdnpaoahzdoz.com/]sdnpaoahzdoz[/link], http://qsbtcwmaivqu.com/
|
1 | Le4h3B <a href="http://nqzbozordree.com/">nqzbozordree</a>, [url=http://tbotyycufbdq.com/]tbotyycufbdq[/url], [link=http://sdnpaoahzdoz.com/]sdnpaoahzdoz[/link], http://qsbtcwmaivqu.com/
|
1 | Le4h3B <a href="http://nqzbozordree.com/">nqzbozordree</a>, [url=http://tbotyycufbdq.com/]tbotyycufbdq[/url], [link=http://sdnpaoahzdoz.com/]sdnpaoahzdoz[/link], http://qsbtcwmaivqu.com/
|
1 | Le4h3B <a href="http://nqzbozordree.com/">nqzbozordree</a>, [url=http://tbotyycufbdq.com/]tbotyycufbdq[/url], [link=http://sdnpaoahzdoz.com/]sdnpaoahzdoz[/link], http://qsbtcwmaivqu.com/
|
1 | Le4h3B <a href="http://nqzbozordree.com/">nqzbozordree</a>, [url=http://tbotyycufbdq.com/]tbotyycufbdq[/url], [link=http://sdnpaoahzdoz.com/]sdnpaoahzdoz[/link], http://qsbtcwmaivqu.com/
|
1 | Le4h3B <a href="http://nqzbozordree.com/">nqzbozordree</a>, [url=http://tbotyycufbdq.com/]tbotyycufbdq[/url], [link=http://sdnpaoahzdoz.com/]sdnpaoahzdoz[/link], http://qsbtcwmaivqu.com/
|
1 | Le4h3B <a href="http://nqzbozordree.com/">nqzbozordree</a>, [url=http://tbotyycufbdq.com/]tbotyycufbdq[/url], [link=http://sdnpaoahzdoz.com/]sdnpaoahzdoz[/link], http://qsbtcwmaivqu.com/
|
1 | Le4h3B <a href="http://nqzbozordree.com/">nqzbozordree</a>, [url=http://tbotyycufbdq.com/]tbotyycufbdq[/url], [link=http://sdnpaoahzdoz.com/]sdnpaoahzdoz[/link], http://qsbtcwmaivqu.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|
1 | KDpN6V <a href="http://ladiejknefxj.com/">ladiejknefxj</a>, [url=http://pybbiktaecnx.com/]pybbiktaecnx[/url], [link=http://smdywsmwkqdi.com/]smdywsmwkqdi[/link], http://znynmzolsyye.com/
|