]>
jfr.im git - irc/quakenet/snircd.git/blob - tools/autodoc.py
2 # Structure AutoDocumentator for ircu.
5 # Creates a 'structs.html', containing HTML Table definitions
6 # for all structures encountered in *.h in the current directory.
8 # $Id: autodoc.py,v 1.1 2000/03/18 05:20:30 bleep Exp $
10 import string
, fnmatch
, os
13 OutFile
= open('structs.html', 'a')
14 OutFile
.write("<B><H2>"+filename
+"</H2>")
17 IncFile
= open(filename
, 'r')
18 line
= IncFile
.readline()
21 line
= string
.replace(line
,"\n","") # Stript out LF's.
22 splitline
= string
.split(line
, " ")
24 if ((stage
== 2) & (splitline
[0] == "};")):
25 OutFile
.write("</TABLE><P>"+"\n")
28 # Begin reading member information.
29 declr
= string
.split(string
.strip(line
), ";", 1)
30 comment
= string
.replace(declr
[1], "*", "")
31 comment
= string
.replace(comment
, "/", "")
33 OutFile
.write("<tr>\n")
34 OutFile
.write("<td WIDTH=\"22%\">"+string
.strip(declr
[0])+"</td>\n")
35 if (declr
[1][-1] == "/"):
36 OutFile
.write("<td WIDTH=\"78%\">"+string
.strip(comment
)+"</td>\n")
38 # Loop until end of comment string.
39 while (declr
[-1] != "/"):
40 line
= IncFile
.readline()
41 line
= string
.replace(line
,"\n","") # Stript out LF's.
42 declr
= string
.strip(line
)
43 comment
= comment
+ line
44 comment
= string
.replace(comment
, "*", "")
45 comment
= string
.replace(comment
, "/", "")
46 OutFile
.write("<td WIDTH=\"78%\">"+string
.strip(comment
)+"</td>\n")
47 OutFile
.write("</tr>\n")
49 if ((splitline
[0] == "struct") & (splitline
[2] == "{") & (stage
== 1)):
50 # We've found a "Standard" structure definition.
51 OutFile
.write("Structure table for: \"<B>"+splitline
[1]+"</B>\"<P>\n")
52 OutFile
.write("<table BORDER CELLSPACING=0 CELLPADDING=2 WIDTH=\"100%\" ><tr><td VALIGN=TOP WIDTH=\"22%\"><b>Variable</b></td><td VALIGN=TOP WIDTH=\"78%\"><b>Description</b></td></tr>")
53 # Now, carry on until we encounter a "};".
57 line
= IncFile
.readline()
63 print("** Error, File does not exist.")
66 files
= os
.listdir(".")
69 if (fnmatch
.fnmatch(file, "*.h")):