From b96dd8bb97110598763a5cd502dfeb8396d21b26 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 12 Jul 2014 19:26:29 +0200 Subject: [PATCH] Implement translation of Doxygen formulae to Sphinx notation. This allows to automatically have nicely looking formulae in HTML output when using Sphinx with e.g. sphinx.ext.mathjax extension. --- .../doxygen_translate_all_tags_runme.py | 10 ++-- .../DoxygenTranslator/src/PyDocConverter.cpp | 47 +++++++++++++++++-- Source/DoxygenTranslator/src/PyDocConverter.h | 6 +++ 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py index 1913eaf42..44b4f536d 100644 --- a/Examples/test-suite/python/doxygen_translate_all_tags_runme.py +++ b/Examples/test-suite/python/doxygen_translate_all_tags_runme.py @@ -93,13 +93,16 @@ r""" - \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} + :math:`\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}` + + .. math:: - \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} - + + .. math:: + \sqrt{(x_2-x_1)^2+(y_2-y_1)^2} @@ -113,6 +116,7 @@ r""" + This will only appear in hmtl """) diff --git a/Source/DoxygenTranslator/src/PyDocConverter.cpp b/Source/DoxygenTranslator/src/PyDocConverter.cpp index edeb056c1..883bc9bd9 100644 --- a/Source/DoxygenTranslator/src/PyDocConverter.cpp +++ b/Source/DoxygenTranslator/src/PyDocConverter.cpp @@ -147,9 +147,9 @@ void PyDocConverter::fillStaticTables() tagHandlers["n"] = make_handler(&PyDocConverter::handleNewLine); // \f commands output literal Latex formula, which is still better than nothing. - tagHandlers["f$"] = make_handler(&PyDocConverter::handleTagVerbatim); - tagHandlers["f["] = make_handler(&PyDocConverter::handleTagVerbatim); - tagHandlers["f{"] = make_handler(&PyDocConverter::handleTagVerbatim); + tagHandlers["f$"] = + tagHandlers["f["] = + tagHandlers["f{"] = make_handler(&PyDocConverter::handleMath); // HTML tags tagHandlers["