Mercurial > hg > kdocs
view make/docdiridx.py @ 21:8dc7c0651c06
Link checker for Documentation, shows 404 errors and files not linked to.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 09 Aug 2007 22:16:32 -0500 |
parents | 8e9357f5cb1b |
children | b5481d0c89c1 |
line wrap: on
line source
#!/usr/bin/python # Convert kernel Documentation/.../00-INDEX to index.html import os,sys if len(sys.argv)==1: print "Usage: docdiridx.py `find Documentation -name 00-INDEX`" sys.exit(1) for name in sys.argv[1:]: # Read input name = "/".join(name.split("/")[:-1]) lines = open("%s/00-INDEX" % name).read() # Open output, write header and <pre> section (if any) out = open("%s/index.html" % name, "w") out.write("<html>\n<title>%s</title>\n<body>\n<ul>\n" % name) lines = lines.split("00-INDEX",1) if lines[0]: out.write("<pre>%s</pre>\n" % lines[0]) lines = lines[1].split("\n") lines = map(lambda a: a.strip(), lines) lines[0] = "00-INDEX" idx = 0 while idx<len(lines): if not lines[idx]: idx += 1 continue out.write('<li><a href="%s">%s</a> %s</li>\n' % (lines[idx], lines[idx], lines[idx+1])) idx += 2 out.write("</ul>\n</body>\n</html>\n")