2002-09-10 13:09:27 +00:00
|
|
|
#! /usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import glob
|
|
|
|
from fontTools.ttLib import identifierToTag
|
|
|
|
|
|
|
|
|
2002-09-10 20:42:35 +00:00
|
|
|
fontToolsDir = os.path.dirname(os.path.dirname(os.path.join(os.getcwd(), sys.argv[0])))
|
|
|
|
fontToolsDir= os.path.normpath(fontToolsDir)
|
|
|
|
tablesDir = os.path.join(fontToolsDir,
|
|
|
|
"Lib", "fontTools", "ttLib", "tables")
|
|
|
|
docFile = os.path.join(fontToolsDir, "Doc", "documentation.html")
|
2002-09-10 13:09:27 +00:00
|
|
|
|
|
|
|
names = glob.glob1(tablesDir, "*.py")
|
|
|
|
|
|
|
|
modules = []
|
2002-09-10 20:42:35 +00:00
|
|
|
tables = []
|
2002-09-10 13:09:27 +00:00
|
|
|
for name in names:
|
|
|
|
try:
|
|
|
|
tag = identifierToTag(name[:-3])
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
modules.append(name[:-3])
|
2002-09-10 20:42:35 +00:00
|
|
|
tables.append(tag.strip())
|
2002-09-10 13:09:27 +00:00
|
|
|
|
|
|
|
modules.sort()
|
2002-09-10 20:42:35 +00:00
|
|
|
tables.sort()
|
|
|
|
|
2002-09-10 13:09:27 +00:00
|
|
|
|
|
|
|
file = open(os.path.join(tablesDir, "__init__.py"), "w")
|
|
|
|
|
2003-08-25 21:19:47 +00:00
|
|
|
file.write("# DON'T EDIT! This file is generated by MetaTools/buildTableList.py.\n")
|
2002-09-10 13:09:27 +00:00
|
|
|
file.write("def _moduleFinderHint():\n")
|
|
|
|
file.write('\t"""Dummy function to let modulefinder know what tables may be\n')
|
|
|
|
file.write('\tdynamically imported. Generated by MetaTools/buildTableList.py.\n')
|
|
|
|
file.write('\t"""\n')
|
|
|
|
for module in modules:
|
|
|
|
file.write("\timport %s\n" % module)
|
|
|
|
|
|
|
|
file.close()
|
2002-09-10 20:42:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
begin = "<!-- begin table list -->"
|
|
|
|
end = "<!-- end table list -->"
|
|
|
|
doc = open(docFile).read()
|
|
|
|
beginPos = doc.find(begin)
|
|
|
|
assert beginPos > 0
|
|
|
|
beginPos = beginPos + len(begin) + 1
|
|
|
|
endPos = doc.find(end)
|
|
|
|
|
|
|
|
doc = doc[:beginPos] + ", ".join(tables[:-1]) + " and " + tables[-1] + "\n" + doc[endPos:]
|
|
|
|
|
|
|
|
open(docFile, "w").write(doc)
|