blob: 4f7fe9697789a6ed6a09b703d9ecfa183d35d971 [file] [log] [blame]
Joe Gregorioafc45f22011-02-20 16:11:28 -05001import os
2import pydoc
3import re
4
5from apiclient.discovery import build
6
7BASE = 'docs/dyn'
8
9APIS = [
10 ('buzz', 'v1'),
11 ('moderator', 'v1'),
12 ('latitude', 'v1'),
13 ('customsearch', 'v1'),
14 ('diacritize', 'v1'),
15 ('translate', 'v2'),
16 ('prediction', 'v1.1'),
17 ('shopping', 'v1'),
18 ('urlshortener', 'v1'),
19 ]
20
21def document(resource, path):
22 print path
23 collections = []
24 for name in dir(resource):
25 if not "_" in name and callable(getattr(resource, name)) and hasattr(
26 getattr(resource, name), '__is_resource__'):
27 collections.append(name)
28
29 obj, name = pydoc.resolve(type(resource))
30 page = pydoc.html.page(
31 pydoc.describe(obj), pydoc.html.document(obj, name))
32
33 for name in collections:
34 page = re.sub('strong>(%s)<' % name, r'strong><a href="%s">\1</a><' % (path + name + ".html"), page)
35 for name in collections:
36 document(getattr(resource, name)(), path + name + ".")
37
38 f = open(os.path.join(BASE, path + 'html'), 'w')
39 f.write(page)
40 f.close()
41
42def document_api(name, version):
43 service = build(name, version)
44 document(service, '%s.%s.' % (name, version))
45
46if __name__ == '__main__':
47 for name, version in APIS:
48 document_api(name, version)
49