blob: 1e77492dc6bd87e86b238dfa353a48f9b54b8a56 [file] [log] [blame]
jvrda15a422002-09-10 13:09:27 +00001#! /usr/bin/env python
2
3import sys
4import os
5import glob
6from fontTools.ttLib import identifierToTag
7
8
jvr9151a0c2002-09-10 20:42:35 +00009fontToolsDir = os.path.dirname(os.path.dirname(os.path.join(os.getcwd(), sys.argv[0])))
10fontToolsDir= os.path.normpath(fontToolsDir)
11tablesDir = os.path.join(fontToolsDir,
12 "Lib", "fontTools", "ttLib", "tables")
13docFile = os.path.join(fontToolsDir, "Doc", "documentation.html")
jvrda15a422002-09-10 13:09:27 +000014
15names = glob.glob1(tablesDir, "*.py")
16
17modules = []
jvr9151a0c2002-09-10 20:42:35 +000018tables = []
jvrda15a422002-09-10 13:09:27 +000019for name in names:
20 try:
21 tag = identifierToTag(name[:-3])
22 except:
23 pass
24 else:
25 modules.append(name[:-3])
jvr9151a0c2002-09-10 20:42:35 +000026 tables.append(tag.strip())
jvrda15a422002-09-10 13:09:27 +000027
28modules.sort()
jvr9151a0c2002-09-10 20:42:35 +000029tables.sort()
30
jvrda15a422002-09-10 13:09:27 +000031
32file = open(os.path.join(tablesDir, "__init__.py"), "w")
33
jvr4ca01ea2003-08-25 21:19:47 +000034file.write("# DON'T EDIT! This file is generated by MetaTools/buildTableList.py.\n")
jvrda15a422002-09-10 13:09:27 +000035file.write("def _moduleFinderHint():\n")
36file.write('\t"""Dummy function to let modulefinder know what tables may be\n')
37file.write('\tdynamically imported. Generated by MetaTools/buildTableList.py.\n')
38file.write('\t"""\n')
39for module in modules:
Behdad Esfahbode07cc6a2013-12-06 19:54:59 -050040 file.write("\tfrom . import %s\n" % module)
jvrda15a422002-09-10 13:09:27 +000041
42file.close()
jvr9151a0c2002-09-10 20:42:35 +000043
44
45begin = "<!-- begin table list -->"
46end = "<!-- end table list -->"
47doc = open(docFile).read()
48beginPos = doc.find(begin)
49assert beginPos > 0
50beginPos = beginPos + len(begin) + 1
51endPos = doc.find(end)
52
53doc = doc[:beginPos] + ", ".join(tables[:-1]) + " and " + tables[-1] + "\n" + doc[endPos:]
54
55open(docFile, "w").write(doc)