[docs] Update buildTableList to write documentation into ttx.rst

Have to do this a little bit differently because of the way that RtD handles comments/code blocks.
This commit is contained in:
Simon Cozens 2020-05-03 22:53:28 +01:00
parent d51566a2c3
commit 52298f273c
2 changed files with 13 additions and 8 deletions

View File

@ -31,16 +31,20 @@ When using TTX from the command line there are a bunch of extra options. These a
The TTX file format The TTX file format
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
.. begin table list
The following tables are currently supported:: The following tables are currently supported::
BASE, CBDT, CBLC, CFF, CFF2, COLR, CPAL, DSIG, EBDT, EBLC, FFTM, BASE, CBDT, CBLC, CFF, CFF2, COLR, CPAL, DSIG, EBDT, EBLC, FFTM,
Feat, GDEF, GMAP, GPKG, GPOS, GSUB, Glat, Gloc, HVAR, JSTF, LTSH, Feat, GDEF, GMAP, GPKG, GPOS, GSUB, Glat, Gloc, HVAR, JSTF, LTSH,
MATH, META, MVAR, OS/2, SING, STAT, SVG, Silf, Sill, TSI0, TSI1, MATH, META, MVAR, OS/2, SING, STAT, SVG, Silf, Sill, TSI0, TSI1,
TSI2, TSI3, TSI5, TSIB, TSID, TSIJ, TSIP, TSIS, TSIV, TTFA, VDMX, TSI2, TSI3, TSI5, TSIB, TSIC, TSID, TSIJ, TSIP, TSIS, TSIV, TTFA,
VORG, VVAR, ankr, avar, bsln, cidg, cmap, cvar, cvt, feat, fpgm, VDMX, VORG, VVAR, ankr, avar, bsln, cidg, cmap, cvar, cvt, feat,
fvar, gasp, gcid, glyf, gvar, hdmx, head, hhea, hmtx, kern, lcar, fpgm, fvar, gasp, gcid, glyf, gvar, hdmx, head, hhea, hmtx, kern,
loca, ltag, maxp, meta, mort, morx, name, opbd, post, prep, prop, lcar, loca, ltag, maxp, meta, mort, morx, name, opbd, post, prep,
sbix, trak, vhea and vmtx prop, sbix, trak, vhea and vmtx
.. end table list
Other tables are dumped as hexadecimal data. Other tables are dumped as hexadecimal data.

View File

@ -11,7 +11,7 @@ fontToolsDir = os.path.dirname(os.path.dirname(os.path.join(os.getcwd(), sys.arg
fontToolsDir= os.path.normpath(fontToolsDir) fontToolsDir= os.path.normpath(fontToolsDir)
tablesDir = os.path.join(fontToolsDir, tablesDir = os.path.join(fontToolsDir,
"Lib", "fontTools", "ttLib", "tables") "Lib", "fontTools", "ttLib", "tables")
docFile = os.path.join(fontToolsDir, "README.rst") docFile = os.path.join(fontToolsDir, "Doc/source/ttx.rst")
names = glob.glob1(tablesDir, "*.py") names = glob.glob1(tablesDir, "*.py")
@ -54,7 +54,7 @@ if __name__ == "__main__":
''') ''')
begin = ".. begin table list\n.. code::\n" begin = ".. begin table list\n"
end = ".. end table list" end = ".. end table list"
with open(docFile) as f: with open(docFile) as f:
doc = f.read() doc = f.read()
@ -64,9 +64,10 @@ beginPos = beginPos + len(begin) + 1
endPos = doc.find(end) endPos = doc.find(end)
lines = textwrap.wrap(", ".join(tables[:-1]) + " and " + tables[-1], 66) lines = textwrap.wrap(", ".join(tables[:-1]) + " and " + tables[-1], 66)
intro = "The following tables are currently supported::\n\n"
blockquote = "\n".join(" "*4 + line for line in lines) + "\n" blockquote = "\n".join(" "*4 + line for line in lines) + "\n"
doc = doc[:beginPos] + blockquote + doc[endPos:] doc = doc[:beginPos] + intro + blockquote + "\n" + doc[endPos:]
with open(docFile, "w") as f: with open(docFile, "w") as f:
f.write(doc) f.write(doc)