Mercurial > hg > kdocs
comparison make/menuconfig2html.py @ 110:01b77829d010
Lots of stuff bit-rotted in scripts to extract documentation from current kernel sources. De-bit-rot it.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 19 Feb 2011 21:32:24 -0600 |
parents | 841aab0fd204 |
children |
comparison
equal
deleted
inserted
replaced
109:cfaf44286c4a | 110:01b77829d010 |
---|---|
15 return str | 15 return str |
16 | 16 |
17 def htmlescape(str): | 17 def htmlescape(str): |
18 return str.strip().replace("&","&").replace("<","<").replace(">",">") | 18 return str.strip().replace("&","&").replace("<","<").replace(">",">") |
19 | 19 |
20 def starthtml(out): | 20 def starthtml(out, myfn): |
21 | 21 |
22 out.write("<html><title>%s %s</title><body><h1>%s %s</h1>\n" % (sys.argv[1],sys.argv[3],sys.argv[1],sys.argv[3])) | 22 out.write("<html><title>%s %s</title><body><h1>%s %s</h1>\n" % (myfn,sys.argv[3],myfn,sys.argv[3])) |
23 | 23 |
24 def readfile(filename): | 24 def readfile(filename): |
25 global helplen | 25 global helplen |
26 | 26 |
27 myfn="%s.html" % "-".join(filename.split("/")) | 27 myfn="%s.html" % "-".join(filename.split("/")) |
31 try: | 31 try: |
32 lines = open(filename).read().split("\n") | 32 lines = open(filename).read().split("\n") |
33 except IOError: | 33 except IOError: |
34 sys.stderr.write("File %s missing\n" % filename) | 34 sys.stderr.write("File %s missing\n" % filename) |
35 return | 35 return |
36 starthtml(out) | 36 starthtml(out,filename) |
37 config = None | 37 config = None |
38 description = None | 38 description = None |
39 for i in lines: | 39 for i in lines: |
40 if helplen: | 40 if helplen: |
41 i = i.expandtabs() | 41 i = i.expandtabs() |
73 out.write("<hr>\n") | 73 out.write("<hr>\n") |
74 sys.stdout.write("</ul>\n") | 74 sys.stdout.write("</ul>\n") |
75 elif words[0] == "source": | 75 elif words[0] == "source": |
76 fn=zapquotes(words[1]) | 76 fn=zapquotes(words[1]) |
77 readfile(fn) | 77 readfile(fn) |
78 out.write('<h2><a href="%(link)s">%(link)s</a></h2>\n' % {"link": "%s/%s.html" % (sys.argv[2], "-".join(fn.split("/")))}) | 78 out.write('<h2><a href="%s">%s</a></h2>\n' % ("%s.html" % "-".join(fn.split("/")), fn)) |
79 elif words[0] in ("default","depends", "select", "if", "endif", "#"): pass | 79 elif words[0] in ("default","depends", "select", "if", "endif", "#"): pass |
80 #else: sys.stderr.write("unknown: %s\n" % i) | 80 #else: sys.stderr.write("unknown: %s\n" % i) |
81 if helplen: out.write("</pre></blockquote>\n") | 81 if helplen: out.write("</pre></blockquote>\n") |
82 out.write("</html>\n") | 82 out.write("</html>\n") |
83 | 83 |
84 starthtml(sys.stdout) | 84 starthtml(sys.stdout,sys.argv[1]) |
85 sys.stdout.write("<ul>\n") | 85 sys.stdout.write("<ul>\n") |
86 readfile(sys.argv[1]) | 86 readfile(sys.argv[1]) |
87 sys.stdout.write("</ul>\n</html>\n") | 87 sys.stdout.write("</ul>\n</html>\n") |