annotate make/docdiridx.py @ 57:999825a029ee

Found a second multiline 00-INDEX entry (first in powerpc, second in networking), so teach the script to handle those.
author Rob Landley <rob@landley.net>
date Sun, 30 Sep 2007 23:30:38 -0500
parents b5481d0c89c1
children 09c09067584c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 #!/usr/bin/python
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
2
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 # Convert kernel Documentation/.../00-INDEX to index.html
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
4
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 import os,sys
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
6
22
b5481d0c89c1 Teach docdiridx to traverse Documentation itself, without "find".
Rob Landley <rob@landley.net>
parents: 20
diff changeset
7 for dir in os.walk("Documentation"):
b5481d0c89c1 Teach docdiridx to traverse Documentation itself, without "find".
Rob Landley <rob@landley.net>
parents: 20
diff changeset
8 if not "00-INDEX" in dir[2]: continue
18
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
9
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
10 # Read input
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
11
22
b5481d0c89c1 Teach docdiridx to traverse Documentation itself, without "find".
Rob Landley <rob@landley.net>
parents: 20
diff changeset
12 lines = open("%s/00-INDEX" % dir[0]).read()
18
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
13
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 # Open output, write header and <pre> section (if any)
22
b5481d0c89c1 Teach docdiridx to traverse Documentation itself, without "find".
Rob Landley <rob@landley.net>
parents: 20
diff changeset
15 out = open("%s/index.html" % dir[0], "w")
b5481d0c89c1 Teach docdiridx to traverse Documentation itself, without "find".
Rob Landley <rob@landley.net>
parents: 20
diff changeset
16 out.write("<html>\n<title>%s</title>\n<body>\n<ul>\n" % dir[0])
18
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
17 lines = lines.split("00-INDEX",1)
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
18 if lines[0]: out.write("<pre>%s</pre>\n" % lines[0])
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 lines = lines[1].split("\n")
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
20 lines[0] = "00-INDEX"
31787234d021 Add a script to convert 00-INDEX files to index.html, and add comments.
Rob Landley <rob@landley.net>
parents:
diff changeset
21
57
999825a029ee Found a second multiline 00-INDEX entry (first in powerpc, second in
Rob Landley <rob@landley.net>
parents: 22
diff changeset
22 close = 0
999825a029ee Found a second multiline 00-INDEX entry (first in powerpc, second in
Rob Landley <rob@landley.net>
parents: 22
diff changeset
23 for idx in range(len(lines)):
999825a029ee Found a second multiline 00-INDEX entry (first in powerpc, second in
Rob Landley <rob@landley.net>
parents: 22
diff changeset
24 if not lines[idx]: continue
999825a029ee Found a second multiline 00-INDEX entry (first in powerpc, second in
Rob Landley <rob@landley.net>
parents: 22
diff changeset
25 if not lines[idx][0].isspace():
999825a029ee Found a second multiline 00-INDEX entry (first in powerpc, second in
Rob Landley <rob@landley.net>
parents: 22
diff changeset
26 if close: out.write('</li>\n')
999825a029ee Found a second multiline 00-INDEX entry (first in powerpc, second in
Rob Landley <rob@landley.net>
parents: 22
diff changeset
27 out.write('<li><a href="%s">%s</a>' % (lines[idx].strip(), lines[idx].strip()))
999825a029ee Found a second multiline 00-INDEX entry (first in powerpc, second in
Rob Landley <rob@landley.net>
parents: 22
diff changeset
28 close = 1
999825a029ee Found a second multiline 00-INDEX entry (first in powerpc, second in
Rob Landley <rob@landley.net>
parents: 22
diff changeset
29 else: out.write(" %s" % lines[idx].strip())
999825a029ee Found a second multiline 00-INDEX entry (first in powerpc, second in
Rob Landley <rob@landley.net>
parents: 22
diff changeset
30 out.write("</li>\n</ul>\n</body>\n</html>\n")