diff options
author | albert-github <albert.tests@gmail.com> | 2018-05-26 15:54:53 (GMT) |
---|---|---|
committer | albert-github <albert.tests@gmail.com> | 2018-05-26 15:54:53 (GMT) |
commit | ed86c707318c1cb005702ef88dbdaa3a2bee5581 (patch) | |
tree | 99838f3b8b9400c81e572daf3e4c2c088c9824f2 /src | |
parent | 63696c08425fc1662c5e76280e3cc74fb3769d80 (diff) | |
download | Doxygen-ed86c707318c1cb005702ef88dbdaa3a2bee5581.zip Doxygen-ed86c707318c1cb005702ef88dbdaa3a2bee5581.tar.gz Doxygen-ed86c707318c1cb005702ef88dbdaa3a2bee5581.tar.bz2 |
Problem with code inside a Doxy table in LaTeX
When code is used inside a problem occurs with \discretionary
- Inside a table \discretionary is disabled when code is used.
- \newline should not be appended to a code line (is already implicitly done by the command).
Diffstat (limited to 'src')
-rw-r--r-- | src/latexdocvisitor.cpp | 25 | ||||
-rw-r--r-- | src/latexgen.cpp | 23 | ||||
-rw-r--r-- | src/latexgen.h | 1 |
3 files changed, 35 insertions, 14 deletions
diff --git a/src/latexdocvisitor.cpp b/src/latexdocvisitor.cpp index 86ceade..69eddf7 100644 --- a/src/latexdocvisitor.cpp +++ b/src/latexdocvisitor.cpp @@ -18,6 +18,7 @@ #include "htmlattrib.h" #include <qfileinfo.h> #include "latexdocvisitor.h" +#include "latexgen.h" #include "docparser.h" #include "language.h" #include "doxygen.h" @@ -291,10 +292,12 @@ void LatexDocVisitor::visit(DocVerbatim *s) { case DocVerbatim::Code: { - m_t << "\n\\begin{DoxyCode}\n"; + m_t << "\n\\begin{DoxyCode}{" << usedTableLevels() << "}\n"; + LatexCodeGenerator::setDoxyCodeOpen(TRUE); Doxygen::parserManager->getParser(lang) ->parseCode(m_ci,s->context(),s->text(),langExt, s->isExample(),s->exampleFile()); + LatexCodeGenerator::setDoxyCodeOpen(FALSE); m_t << "\\end{DoxyCode}\n"; } break; @@ -399,7 +402,8 @@ void LatexDocVisitor::visit(DocInclude *inc) { case DocInclude::IncWithLines: { - m_t << "\n\\begin{DoxyCodeInclude}\n"; + m_t << "\n\\begin{DoxyCodeInclude}{" << usedTableLevels() << "}\n"; + LatexCodeGenerator::setDoxyCodeOpen(TRUE); QFileInfo cfi( inc->file() ); FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() ); Doxygen::parserManager->getParser(inc->extension()) @@ -415,11 +419,13 @@ void LatexDocVisitor::visit(DocInclude *inc) 0, // memberDef TRUE // show line numbers ); + LatexCodeGenerator::setDoxyCodeOpen(FALSE); m_t << "\\end{DoxyCodeInclude}" << endl; } break; case DocInclude::Include: - m_t << "\n\\begin{DoxyCodeInclude}\n"; + m_t << "\n\\begin{DoxyCodeInclude}{" << usedTableLevels() << "}\n"; + LatexCodeGenerator::setDoxyCodeOpen(TRUE); Doxygen::parserManager->getParser(inc->extension()) ->parseCode(m_ci,inc->context(), inc->text(),langExt,inc->isExample(), @@ -431,6 +437,7 @@ void LatexDocVisitor::visit(DocInclude *inc) 0, // memberDef FALSE ); + LatexCodeGenerator::setDoxyCodeOpen(FALSE); m_t << "\\end{DoxyCodeInclude}\n"; break; case DocInclude::DontInclude: @@ -447,7 +454,8 @@ void LatexDocVisitor::visit(DocInclude *inc) break; case DocInclude::Snippet: { - m_t << "\n\\begin{DoxyCodeInclude}\n"; + m_t << "\n\\begin{DoxyCodeInclude}{" << usedTableLevels() << "}\n"; + LatexCodeGenerator::setDoxyCodeOpen(TRUE); Doxygen::parserManager->getParser(inc->extension()) ->parseCode(m_ci, inc->context(), @@ -456,6 +464,7 @@ void LatexDocVisitor::visit(DocInclude *inc) inc->isExample(), inc->exampleFile() ); + LatexCodeGenerator::setDoxyCodeOpen(FALSE); m_t << "\\end{DoxyCodeInclude}" << endl; } break; @@ -463,7 +472,8 @@ void LatexDocVisitor::visit(DocInclude *inc) { QFileInfo cfi( inc->file() ); FileDef fd( cfi.dirPath().utf8(), cfi.fileName().utf8() ); - m_t << "\n\\begin{DoxyCodeInclude}\n"; + m_t << "\n\\begin{DoxyCodeInclude}{" << usedTableLevels() << "}\n"; + LatexCodeGenerator::setDoxyCodeOpen(TRUE); Doxygen::parserManager->getParser(inc->extension()) ->parseCode(m_ci, inc->context(), @@ -478,6 +488,7 @@ void LatexDocVisitor::visit(DocInclude *inc) 0, // memberDef TRUE // show line number ); + LatexCodeGenerator::setDoxyCodeOpen(FALSE); m_t << "\\end{DoxyCodeInclude}" << endl; } break; @@ -495,7 +506,8 @@ void LatexDocVisitor::visit(DocIncOperator *op) // op->type(),op->isFirst(),op->isLast(),op->text().data()); if (op->isFirst()) { - if (!m_hide) m_t << "\n\\begin{DoxyCodeInclude}\n"; + if (!m_hide) m_t << "\n\\begin{DoxyCodeInclude}{" << usedTableLevels() << "}\n"; + LatexCodeGenerator::setDoxyCodeOpen(TRUE); pushEnabled(); m_hide = TRUE; } @@ -515,6 +527,7 @@ void LatexDocVisitor::visit(DocIncOperator *op) if (op->isLast()) { popEnabled(); + LatexCodeGenerator::setDoxyCodeOpen(FALSE); if (!m_hide) m_t << "\n\\end{DoxyCodeInclude}\n"; } else diff --git a/src/latexgen.cpp b/src/latexgen.cpp index 7a2ea59..076b354 100644 --- a/src/latexgen.cpp +++ b/src/latexgen.cpp @@ -39,6 +39,7 @@ #include "resourcemgr.h" static bool DoxyCodeOpen = FALSE; +static bool DoxyCodeLineOpen = FALSE; //------------------------------- LatexCodeGenerator::LatexCodeGenerator(FTextStream &t,const QCString &relPath,const QCString &sourceFileName) @@ -101,7 +102,7 @@ void LatexCodeGenerator::codify(const char *str) m_col+=spacesToNextTabStop; p++; break; - case '\n': (usedTableLevels()>0) ? m_t << "\\newline\n" : m_t << '\n'; m_col=0; p++; + case '\n': (usedTableLevels()>0 && !DoxyCodeOpen) ? m_t << "\\newline\n" : m_t << '\n'; m_col=0; p++; break; default: i=0; @@ -190,10 +191,10 @@ void LatexCodeGenerator::writeLineNumber(const char *ref,const char *fileName,co { static bool usePDFLatex = Config_getBool(USE_PDFLATEX); static bool pdfHyperlinks = Config_getBool(PDF_HYPERLINKS); - if (!DoxyCodeOpen) + if (!DoxyCodeLineOpen) { m_t << "\\DoxyCodeLine{"; - DoxyCodeOpen = TRUE; + DoxyCodeLineOpen = TRUE; } if (m_prettyCode) { @@ -228,19 +229,19 @@ void LatexCodeGenerator::writeLineNumber(const char *ref,const char *fileName,co void LatexCodeGenerator::startCodeLine(bool) { m_col=0; - if (!DoxyCodeOpen) + if (!DoxyCodeLineOpen) { m_t << "\\DoxyCodeLine{"; - DoxyCodeOpen = TRUE; + DoxyCodeLineOpen = TRUE; } } void LatexCodeGenerator::endCodeLine() { - if (DoxyCodeOpen) + if (DoxyCodeLineOpen) { m_t << "}"; - DoxyCodeOpen = FALSE; + DoxyCodeLineOpen = FALSE; } codify("\n"); } @@ -255,6 +256,10 @@ void LatexCodeGenerator::endFontClass() m_t << "}"; } +void LatexCodeGenerator::setDoxyCodeOpen(bool val) +{ + DoxyCodeOpen = val; +} //------------------------------- @@ -2228,12 +2233,14 @@ void LatexGenerator::endConstraintList() void LatexGenerator::startCodeFragment() { - t << "\n\\begin{DoxyCode}\n"; + t << "\n\\begin{DoxyCode}{" << usedTableLevels() << "}\n"; + DoxyCodeOpen = TRUE; } void LatexGenerator::endCodeFragment() { t << "\\end{DoxyCode}\n"; + DoxyCodeOpen = FALSE; } void LatexGenerator::startInlineHeader() diff --git a/src/latexgen.h b/src/latexgen.h index 469e411..07c4080 100644 --- a/src/latexgen.h +++ b/src/latexgen.h @@ -51,6 +51,7 @@ class LatexCodeGenerator : public CodeOutputInterface void writeCodeAnchor(const char *) {} void setCurrentDoc(Definition *,const char *,bool) {} void addWord(const char *,bool) {} + static void setDoxyCodeOpen(bool val); private: void _writeCodeLink(const char *className, |