useblocks / sphinx-simplepdf

A simple PDF builder for Sphinx documentations
https://sphinx-simplepdf.readthedocs.io
MIT License
36 stars 15 forks source link

Missing section number in front of the section names (html and pdf) #27

Closed kreuzberger closed 9 months ago

kreuzberger commented 1 year ago

Ok, my index.rst uses toctree :numbered: The generated html has a numbered toc after the cover page, but the entries in the html have not. I attached the pdf from the demo as example. The toc is numbered, the sections in the pdf are not. I am using Sphinx 4.5.0. Maybe this is the issue.

Sphinx-SimplePDF-DEMO.pdf

Originally posted by @kreuzberger in https://github.com/useblocks/sphinx-simplepdf/issues/19#issuecomment-1249155694

kreuzberger commented 1 year ago

I currently have no idea there it comes from.

sachin-suresh-rapyuta commented 1 year ago

@kreuzberger - Off topic, I was curious to know your configuration for the "page numbers" for top-left-content and "section titles" for top-right-content?

danwos commented 1 year ago

@sachin-suresh-rapyuta That's the default configuration.

Not used anymore for the DEMO PDF, to test certain things. But each other PDF should start with this config.

The default config can be found in this file: https://github.com/useblocks/sphinx-simplepdf/blob/main/sphinx_simplepdf/themes/simplepdf_theme/static/styles/sources/_variables.scss

$top-left-content: config('top-left-content', 'counter(page)') !default;
$top-center-content: config('top-center-content', '') !default;
$top-right-content: config('top-right-content', 'string(heading)') !default;

So its counter(page) for top-left-content and string(heading) for top-right-content.

These magic strings are coming from the weasyprint library. Unfortunately I haven't found a nice overview for these magic strings yet.

sachin-suresh-rapyuta commented 1 year ago

Oh, that was silly to ask, 'bottom-right-content' already had this. Thanks, @danwos!

kreuzberger commented 1 year ago

Seems the error with the section numbers comes from sphinx, where concrete name checks are used to identfy the build to add section and figure numbers. Refer to the Sphinx issue provided here

kreuzberger commented 1 year ago

Due to the answers in https://github.com/sphinx-doc/sphinx/issues/11640 the desired way to be is to have a custom simplepdf writer (could extend Html5Translator) to get the two functions (sectionnumber and fignumber) implemented properly

danwos commented 1 year ago

Interesting and thanks for diving deeper into the root cause. Do you have some time to create such a customized writer? I'm currently totally overloaded with other projects, but happy to test stuff if needed.

kreuzberger commented 1 year ago

Currently this issues (missing section numbers) does not block my current project, which is planned to have a release end of 09/2023. So currently i have no idea if i could spend some hours in September. But i would say no issue, the one who has time first should log the "start of work" here in this issue.