Conditional toctree in Sphinx

后端 未结 4 1266
故里飘歌
故里飘歌 2020-12-30 12:31

I want to do multiple versions of a documentation, which differ in the sections that are included. To achieve this I would usually use either the only directive or the ifcon

4条回答
  •  天命终不由人
    2020-12-30 12:34

    My solution is to place the conditional content in a separate directory 'intern' and using a tag 'internal'.

    In conf.py I added the lines

    if tags.has('internal'):
        exclude_patters = ['_build']
    else:
        exclude_patterns = ['_build', 'intern*']
    

    Now when I pass the 'internal' flag on the command line I get all, otherwise everything except the contents in the intern directory.

    The tag internal can be used in combination with only.

    The ToC contains references to intern/somedoc and they are included or skipped as required. I do get a number of warnings about missing pages but those can be silenced.

提交回复
热议问题