~ubuntu-branches/ubuntu/feisty/pygame/feisty

« back to all changes in this revision

Viewing changes to docs/util/makedocs.py

  • Committer: Bazaar Package Importer
  • Author(s): Ed Boraas
  • Date: 2004-08-08 00:10:10 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040808001010-nts9g4z69jf1ryb1
Tags: 1.6-2
* Actually build-depend on python (for dh_python)
  * Closes: #264086

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
SOURCES = ['../../src/*.c']
9
9
IGNORE_SOURCES = ['rwobject.c']
10
 
PYTHONSRC =['cursors', 'version', 'sprite']
 
10
PYTHONSRC = ['color', 'cursors', 'version', 'sprite', 'sysfont']
11
11
 
12
12
OUTPUTDIR = '../ref/'
13
13
PAGETEMPLATE = open('pagelate.html').readlines()
22
22
 
23
23
 
24
24
mainindex_desc = """
 
25
<tr><td>
25
26
The <b>pygame documentation</b> is mainly generated automatically from the
26
 
documentation. Each module and object in the package is broken into its
 
27
source code. Each module and object in the package is broken into its
27
28
own page in the reference documentation. The names of the objects are
28
29
capitalized, while the regular module names are lower case.
29
30
<br>&nbsp;<br>
30
31
The <b>pygame documentation</b> also comes with a full set of tutorials.
31
32
You can find links to these tutorials and other documentation files below.
 
33
</td></tr>
32
34
 
33
35
"""
34
36
 
72
74
            lines = [line]
73
75
            while 1:
74
76
                line = file.readline()
 
77
                if line.find("NODOC") >= 0 or line[0]=='#': continue
75
78
                if not line or line.find('"') == -1: break
76
79
                line = line[line.find('"')+1:line.rfind('"')]
77
80
                line = line.rstrip()
102
105
    documents.append([title] + getpydoclines(module.__doc__))
103
106
    modname = name
104
107
    for name, obj in module.__dict__.items():
105
 
        if type(obj) is types.ClassType:
 
108
        if type(obj) in (types.ClassType, types.TypeType):
106
109
            title = '    /*DOC*/ static char doc_%s[] =\n'%(name)
107
110
            initdocs = []
108
111
            if hasattr(obj, '__init__'):
109
112
                    init = getattr(obj, '__init__')
110
113
                    if hasattr(init, '__doc__'):
111
 
                            initdocs = getpydoclines(init.__doc__)
112
 
                            if not initdocs: initdocs = []
 
114
                            initdocs = getpydoclines(init.__doc__)
 
115
                            if not initdocs: initdocs = []
113
116
            try:
114
117
                docs = getpydoclines(obj.__doc__)
115
118
                if docs:
123
126
            except AttributeError:
124
127
                documents.append([title] + ['%s.%s'&(modname,name),'noclassdocs'])
125
128
            for methname, meth in obj.__dict__.items():
126
 
                if methname is '__init__': continue
 
129
                if methname[0] == '_': continue
 
130
                if type(meth)  is not types.FunctionType: continue
127
131
                title = '    /*DOC*/ static char doc_%s_%s[] =\n'%(name,methname)
128
132
                try:
129
133
                    docs = getpydoclines(meth.__doc__)
132
136
                        documents.append([title] + docs)
133
137
                except AttributeError: pass
134
138
 
135
 
        elif hasattr(obj, '__doc__'):
 
139
        elif type(obj) in (types.FunctionType,):# types.BuiltinFunctionType):
 
140
            if not hasattr(obj, '__doc__'): continue
136
141
            title = '    /*DOC*/ static char doc_' + name + '[] =\n'
137
 
            documents.append([title] + getpydoclines(obj.__doc__))
 
142
            doclines = getpydoclines(obj.__doc__)
 
143
            if doclines:
 
144
                documents.append([title] + doclines)
138
145
    return documents
139
146
 
140
147
 
144
151
    funcs = []
145
152
 
146
153
    for d in docs:
 
154
        #print d
147
155
        modpos = d[0].find('_MODULE')
148
156
        extpos = d[0].find('_EXTRA')
149
157
 
161
169
            dot = name.rfind('.')
162
170
            name = name.replace('?', '.')
163
171
            if dot == -1:
 
172
                print 'NODOTFOUND, MISC:', name, dot
164
173
                obj['category'] = 'misc'
165
174
                obj['name'] = name
166
175
                obj['fullname'] = name
173
182
                obj['quick'] = d[2]
174
183
                obj['docs'] = d[4:]
175
184
            except IndexError: pass
 
185
            #print '##APPEND FUNC:', obj['name']
176
186
            funcs.append(obj)
177
187
 
178
188
    return [modules, extras, funcs]
179
189
 
180
190
 
181
191
def getdocinfo(file, prefix=''):
182
 
    path = os.path.join(prefix, file[3:])
 
192
    path = '/'.join((prefix, file[3:]))[1:]
183
193
    prettyname = (os.path.splitext(os.path.split(file)[-1])[0])
184
194
    prettyname = prettyname[0].capitalize() + prettyname[1:]
185
195
    if file.find('html') >= 0:
191
201
 
192
202
def findtutorials():
193
203
    fileline = '<li><a href=%s>%s</a> - %s</li>'
194
 
    texthead = '<font size=+1><b>Basic Documentation</b></font><br>'
195
 
    tuthead = '<font size=+1><b>Tutorials / Introductions</b></font><br>'
 
204
    texthead = '<font size=+1><b>Included With Pygame</b></font><br>'
 
205
    tuthead = '<font size=+2><b>Tutorials</b></font><br>'
196
206
    texts1 =  ['../../readme.html', '../../install.html', '../LGPL', '../logos.html']
197
207
    texts = [fileline%x for x in [getdocinfo(x) for x in texts1]]
198
208
    finaltext = texthead + '\n'.join(texts)
199
 
    tuts1 =  glob.glob('../tut/*.html') 
 
209
    htmlfiles = glob.glob('../tut/*.html') + glob.glob('../tut/*/*.html')
 
210
    tuts1 =  [x.replace('\\','/') for x in htmlfiles]
200
211
    tuts1.sort()
201
212
    tuts = [fileline%(x[0],x[1],x[2][9:]) for x in [getdocinfo(x) for x in tuts1] if x[2].startswith('TUTORIAL:')]
202
213
    finaltut = tuthead + '\n'.join(tuts)
203
 
    return finaltext + '<br>&nbsp;<br>' + finaltut
 
214
    return finaltut + '<br>&nbsp;<br>' + finaltext
204
215
 
205
216
 
206
217
def lookupdoc(docs, name, category):
289
300
        if m[7:] in PYTHONSRC:
290
301
            l = l_py
291
302
        elif m[0].lower() == m[0]:
292
 
            l = l_mod
293
 
        else:
294
 
            l = l_type
 
303
            l = l_mod
 
304
        else:
 
305
            l = l_type
295
306
 
296
307
        file = m.replace('.', '_') + '.html'
297
 
        if m[:7] == 'pygame_':
298
 
            m = m[7:]
299
 
        str = '<a href=%s%s>%s</a>' % (prefix, file, m)
300
 
        l.append(str)
 
308
        if m[:7] == 'pygame_':
 
309
            m = m[7:]
 
310
        str = '<a href=%s%s>%s</a>' % (prefix, file, m)
 
311
        l.append(str)
301
312
 
302
313
    l_py.sort()
303
314
    l_mod.sort()
360
371
        htmllist = []
361
372
        docs.sort(namesort)
362
373
        for d in docs:
363
 
            d['mod'] = d['category'].replace('_', '.')
 
374
            name = d['category'].replace('_', '.')
 
375
            if name.startswith('pygame.'):
 
376
                name = name[7:]
 
377
            d['mod'] = name
364
378
            s = filltemplate(INDEXTEMPLATE, d)
365
379
            fullindex.append(s)
366
380
    fullindex.sort()