useblocks / sphinx-simplepdf

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

Can there be 2 `simplepdf_vars` for generating multiple PDFs #65

Closed sachin-suresh-rapyuta closed 1 year ago

sachin-suresh-rapyuta commented 1 year ago

I want to generate 2 PDFs from a single conf.py file. Is there such flexibility?

2 PDFs with different top-right-content or cover-bg.

danwos commented 1 year ago

You can combine different solutions to get this done:

  1. Use sphinx-tags and set the needed tag during the build command: sphinx-build -t first_pdf -b simplepdf sources/ build/
  2. Check in conf.py if a tag is set:
    # Untested, pseudo code
    if "first_pdf" in tags:
    simplepdf_vars = {version_A}
    else:
     simplepdf_vars = {version_B}  

    That's it.

Or you could have a different conf.py and select via: sphinx-build -c another_conf.py -b simplepdf sources/

sachin-suresh-rapyuta commented 1 year ago

How to define tags? For example, if I simply: tags.add('footag') even after importing them by: from sphinx.util.tags import Tags, I get the error:

"tags" is not defined PylancereportUndefinedVariable

danwos commented 1 year ago

For such common details please ask this question in the related Sphinx community. They will be able to help you much better and faster than I can.

silopolis commented 1 year ago

You can combine different solutions to get this done:

This would be a nice addition to the config vars docs section, maybe like a Note or Tip

sachin-suresh-rapyuta commented 1 year ago

Yes trying this out. Having some issues in the "only" directive or still unsure how to use the conditional outputting.

sachin-suresh-rapyuta commented 1 year ago

You can combine different solutions to get this done:

This would be a nice addition to the config vars docs section, maybe like a Note or Tip

Would be happy to see if you have achieved this or did something similar.