I am using wkhtmktopdf to transform my sphinx documentation into PDF. My problem comes with the TOC that is generated, which due to the different HTML pages, is not in order.
My current situation is as follows:
root/index.html:
[Heading_1]
[content]
[Heading_2]
[content]
[Heading_3]
[content]
root/child/index.html:
[Subheading_1, child of Heading_2]
[content]
This basic example returns a TOC as follows:
[Heading_1] ------------------------ Page 1
[Heading_2] ------------------------ Page 2
[Heading_3] ------------------------ Page 3
[Subheading_1] --------------------- Page 4
But my expected result, because of the sphinx toctree is (for example):
[Heading_1] ------------------------ Page 1
[Heading_2] ------------------------ Page 2
[Subheading_1] ----------------- Page 4
[Heading_3] ------------------------ Page 3
Since it seems like I cannot generate this result using the default toc
options, I have been thinking of generating dynamically my own HTML page with the Table of Contents, correctly ordered based on the sphinx toctree BUT I cannot figure out how to get dynamically the page number.
Any ideas how to achieve my expected result? I am using the python-pdfkit
wrapper and I do have the toctree of the entire document.
Thanks!