On 2016-07-20, Peter Burdine wrote:
> [-- Type: text/plain, Encoding: --]
> I'm working on extension that creates a table programmatically, but I can't
> seem to figure out how to add a caption to a table.
> When you create a table, you need to make the following:
> - Make nodes.table
> - Make nodes.tgroup
> - Add tgroup to the table
> - Add headers to the the tgroup
> - Add colspecs to the tgroup
> - Make nodes.thead
> - Add thead to tgroup
> - Add rows to thead
> - Make nodes.tbody
> - Add contents to the table
> - Add the table
> I'm trying to then create a caption like:
> caption = nodes.caption('', '', nodes.Text('Caption Text'))
> But it doesn't seem to matter where I try to add the caption, it doesn't
> work. So far I have been unable to locate an example of how to do this.
> Can someone help me out?
reStructuredText has a "table" directive that creates a "formal table" with
caption.
http://docutils.sourceforge.net/docs/ref/rst/directives.html#tables
Have a look at the native XML (or pseudoXML) output of a document with the
desired content ("hand input" as rST).
(You may find an example also in the Docutils tests in
.../test/functional/expected/standalone_rst_pseudoxml.txt)
Hope this helps.
Günter