annotate makeref.py @ 1849:301bc61643a9 math_module

merged changes from trunk
author lorenz
date Mon, 16 Nov 2009 18:31:40 +0000
parents fdf70a7fb220
children c777771e11f1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
1 #!/usr/bin/env python
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
2
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
3 import os, glob
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
4
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
5
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
6 def sortkey(x):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
7 return os.path.basename(x).lower()
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
8
632
1db7cdb9ab5a Added a backwards fix to allow makeref.py to run on <= python2.4
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
9 def sort_list_by_keyfunc(alist, akey):
1db7cdb9ab5a Added a backwards fix to allow makeref.py to run on <= python2.4
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
10 """ sort(key=sortkey) is only in python2.4.
1db7cdb9ab5a Added a backwards fix to allow makeref.py to run on <= python2.4
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
11 this is not inplace like list.sort()
1db7cdb9ab5a Added a backwards fix to allow makeref.py to run on <= python2.4
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
12 """
1db7cdb9ab5a Added a backwards fix to allow makeref.py to run on <= python2.4
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
13 # make a list of tupples with the key as the first.
1553
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1503
diff changeset
14 keys_and_list = list( zip(map(akey, alist), alist) )
632
1db7cdb9ab5a Added a backwards fix to allow makeref.py to run on <= python2.4
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
15 keys_and_list.sort()
1553
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1503
diff changeset
16 alist = list( map(lambda x:x[1], keys_and_list) )
632
1db7cdb9ab5a Added a backwards fix to allow makeref.py to run on <= python2.4
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
17 return alist
1db7cdb9ab5a Added a backwards fix to allow makeref.py to run on <= python2.4
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
18
1259
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
19 def collect_doc_files():
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
20 # ABSPATH ONLY WORKS FOR docs_as_dict
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
21 #
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
22 # if __name__ == '__main__': Run()
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
23 # must be ran from in trunk dir
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
24
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
25 # get files and shuffle ordering
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
26 trunk_dir = os.path.abspath(os.path.dirname(__file__))
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
27
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
28 src_dir = os.path.join(trunk_dir, 'src')
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
29 lib_dir = os.path.join(trunk_dir, 'lib')
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
30
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
31 pygame_doc = os.path.join(src_dir, "pygame.doc")
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
32
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
33 files = (
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
34 glob.glob(os.path.join(src_dir,'*.doc')) +
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
35 glob.glob(os.path.join(lib_dir,'*.doc'))
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
36 )
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
37
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
38 files.remove(pygame_doc)
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
39
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
40 #XXX: sort(key=) is only available in >= python2.4
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
41 # files.sort(key=sortkey)
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
42 files = sort_list_by_keyfunc(files, sortkey)
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
43
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
44 files.insert(0, pygame_doc)
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
45
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
46 return files
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
47
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
48 def Run():
1609
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
49
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
50 from optparse import OptionParser
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
51 parser = OptionParser()
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
52 parser.add_option("", "--no-code-docs", dest="have_code_docs",
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
53 action="store_false", default=True,
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
54 help="No python documentation in code.")
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
55 (options, args) = parser.parse_args()
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
56
1259
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
57 files = collect_doc_files()
836
70b95d5b61a4 using os.path.join. Thanks DR0ID
Rene Dudfield <renesd@gmail.com>
parents: 821
diff changeset
58 for file in files:
1259
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
59 # print file
1553
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1503
diff changeset
60 print (os.path.basename(file))
1259
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
61
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
62 docs = []
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
63 pages = []
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
64 for f in files:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
65 name = os.path.splitext(os.path.basename(f))[0]
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
66 pages.append(name)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
67 d = name, Doc('', open(f, "U"))
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
68 docs.append(d)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
69
632
1db7cdb9ab5a Added a backwards fix to allow makeref.py to run on <= python2.4
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
70 #pages.sort(key=str.lower)
1db7cdb9ab5a Added a backwards fix to allow makeref.py to run on <= python2.4
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
71 pages = sort_list_by_keyfunc(pages, str.lower)
1db7cdb9ab5a Added a backwards fix to allow makeref.py to run on <= python2.4
Rene Dudfield <renesd@gmail.com>
parents: 627
diff changeset
72
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
73 pages.insert(0, "index")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
74
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
75 index = {}
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
76 justDocs = []
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
77 for name, doc in docs:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
78 justDocs.append(doc)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
79 MakeIndex(name, doc, index)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
80
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
81 for name, doc in docs:
836
70b95d5b61a4 using os.path.join. Thanks DR0ID
Rene Dudfield <renesd@gmail.com>
parents: 821
diff changeset
82 fullname = os.path.join("docs","ref","%s.html") % name
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
83 outFile = open(fullname, "w")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
84 outFile.write(HTMLHeader % name)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
85 WritePageLinks(outFile, pages)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
86 outFile.write(HTMLMid)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
87 HtmlOut(doc, index, outFile)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
88 outFile.write(HTMLFinish)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
89 outFile.close()
1849
301bc61643a9 merged changes from trunk
lorenz
parents: 1609
diff changeset
90
301bc61643a9 merged changes from trunk
lorenz
parents: 1609
diff changeset
91 for name, doc in docs:
301bc61643a9 merged changes from trunk
lorenz
parents: 1609
diff changeset
92 outFile = open(os.path.join("src", "doc", "%s_doc.h") % name, "w")
301bc61643a9 merged changes from trunk
lorenz
parents: 1609
diff changeset
93 outFile.write("/* Auto generated file: with makeref.py . Docs go in src/ *.doc . */\n")
1609
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
94 WriteDocHeader(outFile, doc, options.have_code_docs)
1849
301bc61643a9 merged changes from trunk
lorenz
parents: 1609
diff changeset
95 outFile.write("\n\n/* Docs in a comments... slightly easier to read. */\n\n\n/*")
1503
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
96 WriteDocHeaderComments(outFile, doc)
1849
301bc61643a9 merged changes from trunk
lorenz
parents: 1609
diff changeset
97 outFile.write("\n\n*/\n\n")
1503
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
98
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
99 topDoc = LayoutDocs(justDocs)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
100
836
70b95d5b61a4 using os.path.join. Thanks DR0ID
Rene Dudfield <renesd@gmail.com>
parents: 821
diff changeset
101 outFile = open(os.path.join("docs","ref","index.html"), "w")
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
102 outFile.write(HTMLHeader % "Index")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
103 WritePageLinks(outFile, pages)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
104 outFile.write(HTMLMid)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
105 outFile.write("<ul>\n\n")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
106 WriteIndex(outFile, index, topDoc)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
107 outFile.write("\n\n</ul>\n")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
108 outFile.write(HTMLFinish)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
109 outFile.close()
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
110
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
111
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
112 def HtmlOut(doc, index, f):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
113 f.write('\n\n<a name="%s">\n' % doc.fullname)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
114 f.write("<big><b>%s</big></b><br><ul>\n" % doc.fullname)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
115 if doc.descr:
1849
301bc61643a9 merged changes from trunk
lorenz
parents: 1609
diff changeset
116 f.write(" <i>%s</i><br>\n" % doc.descr)
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
117 if doc.protos:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
118 for p in doc.protos:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
119 f.write(" <tt>%s</tt><br>\n" % p)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
120 if doc.kids:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
121 f.write("<ul><small><table>\n")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
122 for kid in doc.kids:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
123 f.write(" <tr><td>%s</td><td>%s</td></tr>\n"
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
124 % (index.get(kid.fullname + "()"), kid.descr or ""))
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
125 f.write("</table></small></ul>\n")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
126 if doc.docs:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
127 pre = False
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
128 for d in doc.docs:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
129 if d[0] == '*':
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
130 f.write("<ul>\n")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
131 for li in d[1:].split('*'):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
132 txt = HtmlPrettyWord(li)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
133 f.write(" <li>%s</li>\n" % txt)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
134 f.write("</ul>\n")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
135 else:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
136 txt, pre = HtmlPrettyLine(d, index, pre)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
137 f.write(txt)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
138 if pre:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
139 f.write("</pre>\n")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
140 else:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
141 f.write(" &nbsp;<br> \n")
638
131cb70cf3a3 a mod by phillhassey to support his super duper new doc comments website
Rene Dudfield <renesd@gmail.com>
parents: 632
diff changeset
142
131cb70cf3a3 a mod by phillhassey to support his super duper new doc comments website
Rene Dudfield <renesd@gmail.com>
parents: 632
diff changeset
143 f.write("<!--COMMENTS:"+doc.fullname+"-->")
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
144 f.write(" &nbsp;<br> \n")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
145
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
146 if doc.kids:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
147 for k in doc.kids:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
148 HtmlOut(k, index, f)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
149 f.write("<br></ul>\n")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
150
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
151
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
152
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
153 def HtmlPrettyWord(word):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
154 if "." in word[:-1] or word.isupper():
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
155 return "<tt>%s</tt>" % word
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
156 return word
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
157
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
158
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
159
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
160 def HtmlPrettyLine(line, index, pre):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
161 pretty = ""
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
162
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
163 if line[0].isspace():
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
164 if not pre:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
165 pretty += "<pre>"
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
166 pre = True
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
167 elif pre:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
168 pre = False
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
169 pretty += "</pre>"
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
170
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
171 if not pre:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
172 pretty += "<p>"
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
173 for word in line.split():
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
174 if word[-1] in ",.":
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
175 finish = word[-1]
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
176 word = word[:-1]
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
177 else:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
178 finish = ""
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
179 link = index.get(word)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
180 if link:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
181 pretty += "<tt>%s</tt>%s " % (link, finish)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
182 elif word.isupper() or "." in word[1:-1]:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
183 pretty += "<tt>%s</tt>%s " % (word, finish)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
184 else:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
185 pretty += "%s%s " % (word, finish)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
186 pretty += "</p>\n"
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
187 else:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
188 pretty += line + "\n"
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
189 return pretty, pre
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
190
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
191
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
192
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
193 def WritePageLinks(outFile, pages):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
194 links = []
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
195 for page in pages[1:]:
975
ac7e80646aa5 Fixed typo in doc generator, added note for PixelArray
marcus
parents: 836
diff changeset
196 link = '<a href="%s.html">%s</a>' % (page, page.title())
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
197 links.append(link)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
198 outFile.write("&nbsp;||&nbsp;\n".join(links))
641
b7d1a9cbcffb changes from philhassey for adjustments to the design
Rene Dudfield <renesd@gmail.com>
parents: 640
diff changeset
199 #outFile.write("\n</p>\n\n")
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
200
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
201
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
202 def MakeIndex(name, doc, index):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
203 if doc.fullname:
642
07e4026ed724 added the short description to the reference index page. thanks for the suggestion Laura Creighton
Rene Dudfield <renesd@gmail.com>
parents: 641
diff changeset
204 link = '<a href="%s.html#%s">%s</a> - <font size=-1>%s</font>' % (name, doc.fullname, doc.fullname, doc.descr)
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
205 index[doc.fullname + "()"] = link
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
206 if doc.kids:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
207 for kid in doc.kids:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
208 MakeIndex(name, kid, index)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
209
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
210
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
211 def LayoutDocs(docs):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
212 levels = {}
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
213 for doc in docs:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
214 if doc.fullname:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
215 topName = doc.fullname.split(".")[-1]
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
216 levels[topName] = doc
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
217
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
218 top = levels["pygame"]
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
219 for doc in docs:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
220 if doc is top:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
221 continue
1553
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1503
diff changeset
222 #print (doc)
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1503
diff changeset
223 if doc.fullname:
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1503
diff changeset
224 parentName = doc.fullname.split(".")[-2]
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1503
diff changeset
225 else:
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1503
diff changeset
226 parentName = ""
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
227 parent = levels.get(parentName)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
228 if parent is not None:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
229 parent.kids.append(doc)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
230
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
231 return top
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
232
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
233
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
234 def WriteIndex(outFile, index, doc):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
235 link = index.get(doc.fullname + "()", doc.fullname)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
236 outFile.write("<li>%s</li>\n" % link)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
237 if doc.kids:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
238 outFile.write("<ul>\n")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
239 sortKids = list(doc.kids)
1553
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1503
diff changeset
240 #print(sortKids)
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1503
diff changeset
241 sortKids = sort_list_by_keyfunc(sortKids, lambda x: x.fullname)
ebd545641c8b merging with python3 branch r 2048
Lenard Lindstrom <len-l@telus.net>
parents: 1503
diff changeset
242 #sortKids = sorted( sortKids )
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
243 for kid in sortKids:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
244 WriteIndex(outFile, index, kid)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
245 outFile.write("</ul>\n")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
246
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
247
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
248
1609
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
249 def WriteDocHeader(f, doc, have_code_docs ):
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
250 name = doc.fullname.replace(".", "")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
251 name = name.replace("_", "")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
252 name = name.upper()
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
253 defineName = "DOC_" + name
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
254 text = ""
1609
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
255 if have_code_docs:
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
256 if doc.protos:
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
257 text = "\\n".join(doc.protos)
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
258 if doc.descr:
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
259 if text:
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
260 text += "\\n"
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
261 text += doc.descr
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
262
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
263 f.write('#define %s "%s"\n\n' % (defineName, text))
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
264
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
265 if doc.kids:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
266 for kid in doc.kids:
1609
fdf70a7fb220 Fixed color.c for Symbian
gamedude
parents: 1553
diff changeset
267 WriteDocHeader(f, kid, have_code_docs)
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
268
1503
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
269 def WriteDocHeaderComments(f, doc):
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
270 name = doc.fullname
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
271
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
272 defineName = name
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
273 text = ""
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
274 if doc.protos:
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
275 text = "\n".join(doc.protos)
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
276 if doc.descr:
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
277 if text:
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
278 text += "\n"
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
279 text += doc.descr
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
280 text = text.replace("\\n", "\n")
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
281 #f.write('\n\n/*\n%s\n %s\n\n*/' % (defineName, text))
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
282 f.write('\n\n%s\n %s\n\n' % (defineName, text))
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
283
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
284 if doc.kids:
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
285 for kid in doc.kids:
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
286 WriteDocHeaderComments(f, kid)
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
287
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
288
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
289
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
290
b89b475b9a74 Add easier to read versions of docs in .h file at the end.
Rene Dudfield <renesd@gmail.com>
parents: 1373
diff changeset
291
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
292
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
293 class Doc(object):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
294 def __init__(self, parentname, f):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
295 self.kids = None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
296 self.protos = []
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
297 self.docs = None
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
298 self.descr = ""
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
299 self.name = ""
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
300 self.fullname = ""
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
301 self.finished = False
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
302
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
303 curdocline = ""
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
304 while True:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
305 line = f.readline()
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
306 if not line:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
307 break
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
308 line = line.rstrip()
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
309
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
310 if line == "<END>":
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
311 if curdocline:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
312 self.docs.append(curdocline)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
313 curdocline = ""
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
314 self.finished = True
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
315 break
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
316
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
317 if self.kids is not None:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
318 kid = Doc(self.fullname, f)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
319 if kid:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
320 self.kids.append(kid)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
321
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
322
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
323 if line == "<SECTION>":
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
324 if curdocline:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
325 self.docs.append(curdocline)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
326 curdocline = ""
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
327 self.kids = []
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
328 continue
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
329
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
330 if line:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
331 if self.docs is not None:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
332 if line[0].isspace():
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
333 if curdocline:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
334 self.docs.append(curdocline)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
335 curdocline = ""
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
336 self.docs.append(line)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
337 else:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
338 curdocline += line + " "
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
339 elif not self.name:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
340 self.name = line
1373
d0e31483bd3b Added a pygame.locals module page back into the docs
Lenard Lindstrom <len-l@telus.net>
parents: 1259
diff changeset
341 if len(line) > 1 and line[0] == '"' and line[-1] == '"':
d0e31483bd3b Added a pygame.locals module page back into the docs
Lenard Lindstrom <len-l@telus.net>
parents: 1259
diff changeset
342 self.fullname = line[1:-1]
d0e31483bd3b Added a pygame.locals module page back into the docs
Lenard Lindstrom <len-l@telus.net>
parents: 1259
diff changeset
343 elif parentname:
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
344 splitparent = parentname.split(".")
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
345 if splitparent[-1][0].isupper():
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
346 self.fullname = splitparent[-1] + "." + line
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
347 else:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
348 self.fullname = parentname + "." + line
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
349 else:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
350 self.fullname = line
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
351 elif not self.descr:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
352 self.descr = line
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
353 else:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
354 self.protos.append(line)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
355 else:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
356 if self.docs is not None:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
357 if curdocline:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
358 self.docs.append(curdocline)
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
359 curdocline = ""
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
360 elif self.name and self.kids is None:
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
361 self.docs = []
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
362
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
363 def __repr__(self):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
364 return "<Doc '%s'>" % self.name
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
365
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
366 def __nonzero__(self):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
367 return self.finished
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
368
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
369 def __cmp__(self, b):
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
370 return cmp(self.name.lower(), b.name.lower())
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
371
1259
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
372 def docs_as_dict():
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
373 """
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
374
1259
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
375 Dict Format:
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
376
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
377 {'pygame.rect.Rect.center': 'Rect.center: ...' ...}
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
378
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
379 Generally works, has some workarounds, inspect results manually.
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
380
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
381 """
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
382
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
383 import pygame
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
384 files = collect_doc_files()
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
385
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
386 def make_mapping(doc, parent_name):
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
387 docs = {}
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
388 for k in doc.kids:
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
389 if k.docs:
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
390 kid_name = k.fullname
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
391
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
392 if parent_name == 'pygame':
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
393 if hasattr(pygame.base, k.name):
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
394 kid_name = '%s.%s' % ('pygame.base', k.name)
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
395
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
396 elif not kid_name.startswith(parent_name):
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
397 kid_name = '%s.%s' % (parent_name, kid_name)
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
398
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
399 docs[kid_name] = '\n'.join(k.docs)
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
400
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
401 if k.kids:
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
402 docs.update(make_mapping(k, parent_name))
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
403 return docs
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
404
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
405 mapping = {}
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
406 for f in files:
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
407 doc = Doc('', open(f, "U"))
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
408 mapping.update(make_mapping(doc, doc.name.lower()))
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
409
9ca221a18f66 added docs_as_dict() function to makeref.py, and ability to use it when imported while getcwd() other than trunk
akalias
parents: 975
diff changeset
410 return mapping
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
411
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
412 HTMLHeader = """
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
413 <html>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
414 <title>%s - Pygame Documentation</title>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
415 <body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
416
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
417
641
b7d1a9cbcffb changes from philhassey for adjustments to the design
Rene Dudfield <renesd@gmail.com>
parents: 640
diff changeset
418 <table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%%'>
b7d1a9cbcffb changes from philhassey for adjustments to the design
Rene Dudfield <renesd@gmail.com>
parents: 640
diff changeset
419 <tr>
b7d1a9cbcffb changes from philhassey for adjustments to the design
Rene Dudfield <renesd@gmail.com>
parents: 640
diff changeset
420 <td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
b7d1a9cbcffb changes from philhassey for adjustments to the design
Rene Dudfield <renesd@gmail.com>
parents: 640
diff changeset
421 <td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
422 ||&nbsp;
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
423 <a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
424 <a href=../index.html>Help Contents</a> &nbsp;||
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
425 <a href=index.html>Reference Index</a> &nbsp;||
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
426 <br>&nbsp;<br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
427
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
428 """
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
429
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
430 HTMLMid = """
641
b7d1a9cbcffb changes from philhassey for adjustments to the design
Rene Dudfield <renesd@gmail.com>
parents: 640
diff changeset
431 </td></tr></table>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
432 <br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
433 """
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
434
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
435 HTMLFinish = """
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
436 </body></html>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
437 """
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
438
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
439 if __name__ == '__main__':
1373
d0e31483bd3b Added a pygame.locals module page back into the docs
Lenard Lindstrom <len-l@telus.net>
parents: 1259
diff changeset
440 Run()