diff options
author | albert-github <albert.tests@gmail.com> | 2019-06-06 10:22:42 (GMT) |
---|---|---|
committer | albert-github <albert.tests@gmail.com> | 2019-06-06 10:22:42 (GMT) |
commit | 313cc456d52ccf41f7b32adc3d0400cb7992549d (patch) | |
tree | cb32ee79524baadb3538764c75eca46c6babbffa | |
parent | e773e6cb9e117621e06fb81098d33417e8a97720 (diff) | |
download | Doxygen-313cc456d52ccf41f7b32adc3d0400cb7992549d.zip Doxygen-313cc456d52ccf41f7b32adc3d0400cb7992549d.tar.gz Doxygen-313cc456d52ccf41f7b32adc3d0400cb7992549d.tar.bz2 |
issue #7033 Syntax highlighting doesn't work when calling \dontinclude from Markdown files
Don't use the file name extension of the including file but of the included file. In case of no included filename or no extension, fall back of the file extension of the including file.
-rw-r--r-- | src/docbookvisitor.cpp | 6 | ||||
-rw-r--r-- | src/htmldocvisitor.cpp | 6 | ||||
-rw-r--r-- | src/latexdocvisitor.cpp | 6 | ||||
-rw-r--r-- | src/mandocvisitor.cpp | 6 | ||||
-rw-r--r-- | src/rtfdocvisitor.cpp | 6 | ||||
-rw-r--r-- | src/util.cpp | 8 | ||||
-rw-r--r-- | src/util.h | 1 | ||||
-rw-r--r-- | src/xmldocvisitor.cpp | 6 | ||||
-rw-r--r-- | testing/021/indexpage.xml | 2 |
9 files changed, 34 insertions, 13 deletions
diff --git a/src/docbookvisitor.cpp b/src/docbookvisitor.cpp index 64425c6..73db25f 100644 --- a/src/docbookvisitor.cpp +++ b/src/docbookvisitor.cpp @@ -472,7 +472,9 @@ DB_VIS_C pushEnabled(); m_hide = TRUE; } - SrcLangExt langExt = getLanguageFromFileName(m_langExt); + QCString locLangExt = getFileNameExtension(op->includeFileName()); + if (locLangExt.isEmpty()) locLangExt = m_langExt; + SrcLangExt langExt = getLanguageFromFileName(locLangExt); if (op->type()!=DocIncOperator::Skip) { popEnabled(); @@ -485,7 +487,7 @@ DB_VIS_C fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() ); } - Doxygen::parserManager->getParser(m_langExt) + Doxygen::parserManager->getParser(locLangExt) ->parseCode(m_ci,op->context(), op->text(),langExt,op->isExample(), op->exampleFile(), diff --git a/src/htmldocvisitor.cpp b/src/htmldocvisitor.cpp index e7d9d57..29298a1 100644 --- a/src/htmldocvisitor.cpp +++ b/src/htmldocvisitor.cpp @@ -784,7 +784,9 @@ void HtmlDocVisitor::visit(DocIncOperator *op) pushEnabled(); m_hide=TRUE; } - SrcLangExt langExt = getLanguageFromFileName(m_langExt); + QCString locLangExt = getFileNameExtension(op->includeFileName()); + if (locLangExt.isEmpty()) locLangExt = m_langExt; + SrcLangExt langExt = getLanguageFromFileName(locLangExt); if (op->type()!=DocIncOperator::Skip) { popEnabled(); @@ -796,7 +798,7 @@ void HtmlDocVisitor::visit(DocIncOperator *op) QFileInfo cfi( op->includeFileName() ); fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() ); } - Doxygen::parserManager->getParser(m_langExt) + Doxygen::parserManager->getParser(locLangExt) ->parseCode( m_ci, op->context(), diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index 2e979bd..f960333 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -566,7 +566,9 @@ void LatexDocVisitor::visit(DocIncOperator *op) pushEnabled(); m_hide = TRUE; } - SrcLangExt langExt = getLanguageFromFileName(m_langExt); + QCString locLangExt = getFileNameExtension(op->includeFileName()); + if (locLangExt.isEmpty()) locLangExt = m_langExt; + SrcLangExt langExt = getLanguageFromFileName(locLangExt); if (op->type()!=DocIncOperator::Skip) { popEnabled(); @@ -579,7 +581,7 @@ void LatexDocVisitor::visit(DocIncOperator *op) fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() ); } - Doxygen::parserManager->getParser(m_langExt) + Doxygen::parserManager->getParser(locLangExt) ->parseCode(m_ci,op->context(),op->text(),langExt, op->isExample(),op->exampleFile(), fd, // fileDef diff --git a/src/mandocvisitor.cpp b/src/mandocvisitor.cpp index 5c98c6f..e407642 100644 --- a/src/mandocvisitor.cpp +++ b/src/mandocvisitor.cpp @@ -367,7 +367,9 @@ void ManDocVisitor::visit(DocInclude *inc) void ManDocVisitor::visit(DocIncOperator *op) { - SrcLangExt langExt = getLanguageFromFileName(m_langExt); + QCString locLangExt = getFileNameExtension(op->includeFileName()); + if (locLangExt.isEmpty()) locLangExt = m_langExt; + SrcLangExt langExt = getLanguageFromFileName(locLangExt); //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n", // op->type(),op->isFirst(),op->isLast(),op->text().data()); if (op->isFirst()) @@ -393,7 +395,7 @@ void ManDocVisitor::visit(DocIncOperator *op) fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() ); } - Doxygen::parserManager->getParser(m_langExt) + Doxygen::parserManager->getParser(locLangExt) ->parseCode(m_ci,op->context(),op->text(),langExt, op->isExample(),op->exampleFile(), fd, // fileDef diff --git a/src/rtfdocvisitor.cpp b/src/rtfdocvisitor.cpp index 55c03a5..040375d 100644 --- a/src/rtfdocvisitor.cpp +++ b/src/rtfdocvisitor.cpp @@ -532,7 +532,9 @@ void RTFDocVisitor::visit(DocIncOperator *op) //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n", // op->type(),op->isFirst(),op->isLast(),op->text().data()); DBG_RTF("{\\comment RTFDocVisitor::visit(DocIncOperator)}\n"); - SrcLangExt langExt = getLanguageFromFileName(m_langExt); + QCString locLangExt = getFileNameExtension(op->includeFileName()); + if (locLangExt.isEmpty()) locLangExt = m_langExt; + SrcLangExt langExt = getLanguageFromFileName(locLangExt); if (op->isFirst()) { if (!m_hide) @@ -556,7 +558,7 @@ void RTFDocVisitor::visit(DocIncOperator *op) fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() ); } - Doxygen::parserManager->getParser(m_langExt) + Doxygen::parserManager->getParser(locLangExt) ->parseCode(m_ci,op->context(),op->text(),langExt, op->isExample(),op->exampleFile(), fd, // fileDef diff --git a/src/util.cpp b/src/util.cpp index a6ae004..931c07f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -7432,6 +7432,14 @@ SrcLangExt getLanguageFromFileName(const QCString& fileName) return SrcLangExt_Cpp; // not listed => assume C-ish language. } +QCString getFileNameExtension(QCString fn) +{ + if (fn.isEmpty()) return ""; + int lastDot = fn.findRev('.'); + if (lastDot!=-1) return fn.mid(lastDot); + return ""; +} + //-------------------------------------------------------------------------- MemberDef *getMemberFromSymbol(const Definition *scope,const FileDef *fileScope, @@ -389,6 +389,7 @@ QCString stripLeadingAndTrailingEmptyLines(const QCString &s,int &docLine); bool updateLanguageMapping(const QCString &extension,const QCString &parser); SrcLangExt getLanguageFromFileName(const QCString& fileName); +QCString getFileNameExtension(QCString fn); void initDefaultExtensionMapping(); void addCodeOnlyMappings(); diff --git a/src/xmldocvisitor.cpp b/src/xmldocvisitor.cpp index 1005719..0f11315 100644 --- a/src/xmldocvisitor.cpp +++ b/src/xmldocvisitor.cpp @@ -415,7 +415,9 @@ void XmlDocVisitor::visit(DocIncOperator *op) pushEnabled(); m_hide = TRUE; } - SrcLangExt langExt = getLanguageFromFileName(m_langExt); + QCString locLangExt = getFileNameExtension(op->includeFileName()); + if (locLangExt.isEmpty()) locLangExt = m_langExt; + SrcLangExt langExt = getLanguageFromFileName(locLangExt); if (op->type()!=DocIncOperator::Skip) { popEnabled(); @@ -428,7 +430,7 @@ void XmlDocVisitor::visit(DocIncOperator *op) fd = createFileDef( cfi.dirPath().utf8(), cfi.fileName().utf8() ); } - Doxygen::parserManager->getParser(m_langExt) + Doxygen::parserManager->getParser(locLangExt) ->parseCode(m_ci,op->context(), op->text(),langExt,op->isExample(), op->exampleFile(), diff --git a/testing/021/indexpage.xml b/testing/021/indexpage.xml index 7c93a78..3ecbd0a 100644 --- a/testing/021/indexpage.xml +++ b/testing/021/indexpage.xml @@ -6,7 +6,7 @@ <briefdescription> </briefdescription> <detaileddescription> - <para> Our main function starts like this: <programlisting filename="example_test.cpp"><codeline><highlight class="normal">void<sp/>main()</highlight></codeline><codeline><highlight class="normal">{</highlight></codeline></programlisting> First we create a object <computeroutput>t</computeroutput> of the <ref refid="class_test" kindref="compound">Test</ref> class. <programlisting filename="example_test.cpp"><codeline><highlight class="normal"><sp/><sp/>Test<sp/>t;</highlight></codeline></programlisting> Then we call the example member function <programlisting filename="example_test.cpp"><codeline><highlight class="normal"><sp/><sp/>t.example();</highlight></codeline></programlisting> After that our little test routine ends. <programlisting filename="example_test.cpp"><codeline><highlight class="normal">}</highlight></codeline></programlisting> </para> + <para> Our main function starts like this: <programlisting filename="example_test.cpp"><codeline><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>main()</highlight></codeline><codeline><highlight class="normal">{</highlight></codeline></programlisting> First we create a object <computeroutput>t</computeroutput> of the <ref refid="class_test" kindref="compound">Test</ref> class. <programlisting filename="example_test.cpp"><codeline><highlight class="normal"><sp/><sp/><ref refid="class_test" kindref="compound">Test</ref><sp/>t;</highlight></codeline></programlisting> Then we call the example member function <programlisting filename="example_test.cpp"><codeline><highlight class="normal"><sp/><sp/>t.<ref refid="class_test_1a47b775f65718978f1ffcd96376f8ecfa" kindref="member">example</ref>();</highlight></codeline></programlisting> After that our little test routine ends. <programlisting filename="example_test.cpp"><codeline><highlight class="normal">}</highlight></codeline></programlisting> </para> </detaileddescription> </compounddef> </doxygen> |