Section headings in only directives are not correctly handled

Christian Jann avatarChristian Jann created an issue

I'm not completely sure if it's a bug or just my fault, because I'm relatively new to sphinx.

So the following does not work:

.. only:: html

  This is missing in html
  =======================

  This is completely missing in html

  * :ref:`genindex`
  * :ref:`modindex`
  * :ref:`search`
  * :doc:`TODO <todo>`

while the following does:

.. only:: html

  This Works

In http://sphinx.pocoo.org/changes.html#release-1-1-oct-9-2011 is written: "Section headings in only directives are now correctly handled.", I don't think this is the case, I'm using Sphinx 1.2pre, compiled yesterday.

I've noticed that it works in other rst files which are included via toctree but not in index.rst. I've even created an new empty documentation via sphinx-quickstart with the same result. Is this even possible? Could somebody confirm this?

Comments (6)

  1. Anonymous

    I'm experiencing the same issue, with Sphinx 1.1.2. To make it more concrete, I want to include a "see also" section only in the manpage version of a document:

    .. only:: man
    
        See Also
        --------
    
        blah blah
    

    However, I notice that this problem doesn't occur if the heading level is below that of the previous section.

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.