- Code that is delimited from surrounding paragraphs with an empty line is
considered as block.
-- Code that is not alone in a paragraph is considered as inline.
+- Code that is coming from ``@include``, ``@snippet`` and related commands
+ that paste external file content is always considered as block.
+- Code that is coming from ``@code`` and is not alone in a paragraph is
+ considered as inline.
- For compatibility reasons, if code that is detected as inline consists of
more than one line, it's rendered as code block and a warning is printed to
output.
.. block-warning:: Doxygen limitations
- Due to Doxygen limitations, sometimes a single-line code block coming from
- ``@skipline`` and related commands is detected as inline code and prepended
- to the immediately following paragraph. In order to prevent that, add a
- stray :html:`<p>` tag right
- after the block:
-
- .. code:: c++
-
- /**
- Text paragraph before a code block.
-
- @skipline foo
- <p>
-
- Next text paragraph after a code block.
- */
-
- Besides that, it's not possible to use inline code highlighting in
- ``@brief`` description. Code placed there is moved by Doxygen to the
- detailed description.
+ It's not possible to use inline code highlighting in ``@brief``
+ description. Code placed there is moved by Doxygen to the detailed
+ description.
.. block-warning:: Doxygen patches
elif i.tag == 'programlisting':
# Seems to be a standalone code paragraph, don't wrap it in <p>
- # and use <pre>
- if element.tag == 'para' and (not element.text or not element.text.strip()) and (not i.tail or not i.tail.strip()) and len([listing for listing in element]) == 1:
+ # and use <pre>:
+ # - is either alone in the paragraph, with no text or other
+ # elements around
+ # - or is a code snippet (filename instead of just .ext). Doxygen
+ # unfortunately doesn't put @snippet in its own paragraph even
+ # if it's separated by blank lines. It does so for @include and
+ # related, though.
+ if element.tag == 'para' and (((not element.text or not element.text.strip()) and (not i.tail or not i.tail.strip()) and len([listing for listing in element]) == 1) or ('filename' in i.attrib and not i.attrib['filename'].startswith('.'))):
code_block = True
# Looks like inline code, but has multiple code lines, so it's
# Doxygen doesn't add a space before <programlisting> if it's
# inline, add it manually in case there should be a space
# before it. However, it does add a space after it always.
- # TODO: could this be used to detect the problematic case?
if out.parsed and not out.parsed[-1].isspace() and not out.parsed[-1] in '([{':
out.parsed += ' '