Re: publish_parts and table of contents?

Guenter Milde via Docutils-users <[email protected]>
Newsgroups gmane.text.docutils.user
Message-ID <[email protected]>
On 2017-07-21, Tony Narlock wrote:

> So here is where I am:
> https://gist.github.com/tony/1a03b7668c9e33672f4465dd63c6076b

No time to look.

> On July 20, 2017 at 11:54:07 AM, Guenter Milde via Docutils-users (
> On 2017-07-20, Tony Narlock wrote:
>> On July 19, 2017 at 5:27:15 PM, Guenter Milde via Docutils-users (

>> ...


> > 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()

Does this work?


> > 3. Run the toc-generating transform on the doctree.
> > Returns a "toc doctree".

> Where would it be? 

In docutils/transforms/parts.py

> Am I applying the transform correctly in the paste?

>> 4. Export the "toc doctree" with publish_from_doctree().

> Assuming I’m running the transform correctly, I see no difference in the
> output.

So I suppose you don't apply it correctly.

The idea is to collect generate a TOC by travelling over the doctree in
the same manner as it is done by the "Contents" transform.

Therefore, it should be possible to use
docutils.transforms.parts.Contents.build_contents() and pass it the
startnode of the doctree returned by "publish_parts".

>> This is just an idea, not tested and detailled.

Günter



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Docutils-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.