From: Guenter M. <mi...@us...> - 2017-07-20 16:53:48
|
On 2017-07-20, Tony Narlock wrote: > On July 19, 2017 at 5:27:15 PM, Guenter Milde via Docutils-users ( > doc...@li...) wrote: > On 2017-07-19, Tony Narlock wrote: > ... >> The transform generates the TOC by travelling the document tree after >> parsing is complete. ... >> https://gist.github.com/tony/c4fc5661fcd4b7de71c65dd8a52c9ea4 > Which contains the description: >> 1. Currently, table of contents is only outputted through directive. > ... >> 3. I want it to be available in "toc" *without* using the directive in the >> source. > For this, you would need to run the "Contents" transform also if the > document does not contain the "contents" directive. >> 2. I do not to position table of contents in the RST. (therefore, I >> specifically do not want it in html_body) I suppose rather than messing with "parts", you can use the publish_* functions in a wrapper script: Don't use ``.. contents..`` in the source. 1. Parse the rst source with publish_doctree() Returns a doctree object. 2. Export doctree to HTML with publish_from_doctree() 3. Run the toc-generating transform on the doctree. Returns a "toc doctree". 4. Export the "toc doctree" with publish_from_doctree(). This is just an idea, not tested and detailled. > It would be indispensable to get a code example or demonstration. This is left as an exercise to the reader. Günter |