doxygen
latexgen.h
1 /******************************************************************************
2  *
3  * Copyright (C) 1997-2023 by Dimitri van Heesch.
4  *
5  * Permission to use, copy, modify, and distribute this software and its
6  * documentation under the terms of the GNU General Public License is hereby
7  * granted. No representations are made about the suitability of this software
8  * for any purpose. It is provided "as is" without express or implied warranty.
9  * See the GNU General Public License for more details.
10  *
11  * Documents produced by Doxygen are derivative works derived from the
12  * input used in their production; they are not affected by this license.
13  *
14  */
15 
16 #ifndef LATEXGEN_H
17 #define LATEXGEN_H
18 
19 #include "config.h"
20 #include "outputgen.h"
21 
22 #define LATEX_STYLE_EXTENSION ".sty"
23 
24 class OutputCodeList;
25 
28 {
29  public:
30  LatexCodeGenerator(TextStream *t,const QCString &relPath,const QCString &sourceFile);
32  void setTextStream(TextStream *t) { m_t = t; }
33 
34  OutputType type() const { return OutputType::Latex; }
35 
36  void codify(const QCString &text);
37  void writeCodeLink(CodeSymbolType type,
38  const QCString &ref,const QCString &file,
39  const QCString &anchor,const QCString &name,
40  const QCString &tooltip);
41  void writeTooltip(const QCString &,
42  const DocLinkInfo &,
43  const QCString &,
44  const QCString &,
45  const SourceLinkInfo &,
46  const SourceLinkInfo &
47  ) {}
48  void writeLineNumber(const QCString &,const QCString &,const QCString &,int,bool);
49  void startCodeLine(int);
50  void endCodeLine();
51  void startFontClass(const QCString &);
52  void endFontClass();
53  void writeCodeAnchor(const QCString &) {}
54  void startCodeFragment(const QCString &style);
55  void endCodeFragment(const QCString &style);
56  void startFold(int,const QCString &,const QCString &) {}
57  void endFold() {}
58 
59  // extra methods not part of CodeOutputInterface
60  void incUsedTableLevel() { m_usedTableLevel++; }
61  void decUsedTableLevel() { m_usedTableLevel--; }
62  int usedTableLevel() const { return m_usedTableLevel; }
63 
64  void setRelativePath(const QCString &path);
65  void setSourceFileName(const QCString &sourceFileName);
66  void setInsideTabbing(bool b) { m_insideTabbing=b; }
67  bool insideTabbing() const { return m_insideTabbing; }
68 
69  private:
70  void _writeCodeLink(const QCString &className,
71  const QCString &ref,const QCString &file,
72  const QCString &anchor,const QCString &name,
73  const QCString &tooltip);
74  void docify(const QCString &str);
75  bool m_streamSet = false;
76  TextStream *m_t;
77  QCString m_relPath;
78  QCString m_sourceFileName;
79  size_t m_col = 0;
80  bool m_doxyCodeLineOpen = false;
81  int m_usedTableLevel = 0;
82  bool m_insideTabbing = false;
83 };
84 
87 {
88  public:
91  LatexGenerator &operator=(const LatexGenerator &);
93  LatexGenerator &operator=(LatexGenerator &&) = delete;
94  ~LatexGenerator();
95  OutputType type() const { return OutputType::Latex; }
96 
97  static void init();
98  void cleanup();
99  static void writeStyleSheetFile(TextStream &t);
100  static void writeHeaderFile(TextStream &t);
101  static void writeFooterFile(TextStream &t);
102 
103  void writeDoc(const IDocNodeAST *node,const Definition *ctx,const MemberDef *,int id);
104 
105  void startFile(const QCString &name,const QCString &manName,const QCString &title,int id,int hierarchyLevel);
106  void writeSearchInfo() {}
107  void writeFooter(const QCString &) {}
108  void endFile();
109  void clearBuffer();
110 
111  void startPageDoc(const QCString &) {}
112  void endPageDoc() {}
113  void startIndexSection(IndexSection);
114  void endIndexSection(IndexSection);
115  void writePageLink(const QCString &,bool);
116  void startProjectNumber();
117  void endProjectNumber() {}
118  void writeStyleInfo(int part);
119  void startTitleHead(const QCString &);
120  void endTitleHead(const QCString &,const QCString &name);
121 
122  void startParagraph(const QCString &classDef);
123  void endParagraph();
124  void writeString(const QCString &text);
125  void startIndexListItem() {}
126  void endIndexListItem() {}
127  void startIndexList() { m_t << "\\begin{DoxyCompactList}\n"; }
128  void endIndexList() { m_t << "\\end{DoxyCompactList}\n"; }
129  void startIndexKey();
130  void endIndexKey();
131  void startIndexValue(bool);
132  void endIndexValue(const QCString &,bool);
133  void startItemList() { m_t << "\\begin{DoxyCompactItemize}\n"; }
134  void endItemList() { m_t << "\\end{DoxyCompactItemize}\n"; }
135  void startIndexItem(const QCString &ref,const QCString &file);
136  void endIndexItem(const QCString &ref,const QCString &file);
137  void docify(const QCString &text);
138  void writeObjectLink(const QCString &ref,const QCString &file,
139  const QCString &anchor,const QCString &name);
140 
141  void startTextLink(const QCString &,const QCString &);
142  void endTextLink();
143  void startTypewriter() { m_t << "{\\ttfamily "; }
144  void endTypewriter() { m_t << "}"; }
145  void startGroupHeader(int);
146  void endGroupHeader(int);
147  void startItemListItem() { m_t << "\\item \n"; }
148  void endItemListItem() {}
149 
150  void startMemberSections() {}
151  void endMemberSections() {}
152  void startHeaderSection() {}
153  void endHeaderSection() {}
154  void startMemberHeader(const QCString &,int);
155  void endMemberHeader();
156  void startMemberSubtitle() {}
157  void endMemberSubtitle() {}
158  void startMemberDocList() {}
159  void endMemberDocList() {}
160  void startMemberList();
161  void endMemberList();
162  void startInlineHeader();
163  void endInlineHeader();
164  void startAnonTypeScope(int);
165  void endAnonTypeScope(int);
166  void startMemberItem(const QCString &,MemberItemType,const QCString &);
167  void endMemberItem(MemberItemType);
168  void startMemberTemplateParams();
169  void endMemberTemplateParams(const QCString &,const QCString &);
170  void startCompoundTemplateParams() { m_t << "\\subsubsection*{";}
171  void endCompoundTemplateParams() { m_t << "}\n"; }
172 
173  void startMemberGroupHeader(bool);
174  void endMemberGroupHeader();
175  void startMemberGroupDocs();
176  void endMemberGroupDocs();
177  void startMemberGroup();
178  void endMemberGroup(bool);
179 
180  void insertMemberAlign(bool) {}
181  void insertMemberAlignLeft(MemberItemType,bool){}
182 
183  void writeRuler() { m_t << "\n\n"; }
184  void writeAnchor(const QCString &fileName,const QCString &name);
185  void startEmphasis() { m_t << "{\\em "; }
186  void endEmphasis() { m_t << "}"; }
187  void startBold() { m_t << "{\\bfseries "; }
188  void endBold() { m_t << "}"; }
189  void lineBreak(const QCString &style=QCString());
190  void startMemberDoc(const QCString &,const QCString &,const QCString &,const QCString &,int,int,bool);
191  void endMemberDoc(bool);
192  void startDoxyAnchor(const QCString &,const QCString &,const QCString &,const QCString &,const QCString &);
193  void endDoxyAnchor(const QCString &,const QCString &);
194  void addLabel(const QCString &,const QCString &);
195  void writeChar(char c);
196  void writeLatexSpacing() { m_t << "\\hspace{0.3cm}"; }
197  void writeStartAnnoItem(const QCString &type,const QCString &file,
198  const QCString &path,const QCString &name);
199  void startCenter() { m_t << "\\begin{center}\n"; }
200  void endCenter() { m_t << "\\end{center}\n"; }
201  void startSmall() { m_t << "\\footnotesize "; }
202  void endSmall() { m_t << "\\normalsize "; }
203  void startMemberDescription(const QCString &,const QCString &,bool);
204  void endMemberDescription();
205  void startMemberDeclaration() {}
206  void endMemberDeclaration(const QCString &,const QCString &) {}
207  void writeInheritedSectionTitle(const QCString &,const QCString &,const QCString &,
208  const QCString &,const QCString &,const QCString &);
209  void startExamples();
210  void endExamples();
211  void startDescForItem() { m_t << "\\par\n"; }
212  void endDescForItem() {}
213  void startSection(const QCString &,const QCString &,SectionType);
214  void endSection(const QCString &,SectionType);
215  void addIndexItem(const QCString &,const QCString &);
216  void startIndent() {}
217  void endIndent() {}
218  void writeSynopsis() {}
219  void startClassDiagram();
220  void endClassDiagram(const ClassDiagram &,const QCString &,const QCString &);
221  void startPageRef();
222  void endPageRef(const QCString &,const QCString &);
223  void startQuickIndices() {}
224  void endQuickIndices() {}
225  void writeSplitBar(const QCString &) {}
226  void writeNavigationPath(const QCString &) {}
227  void writeLogo() {}
228  void writeQuickLinks(HighlightedItem,const QCString &) {}
229  void writeSummaryLink(const QCString &,const QCString &,const QCString &,bool) {}
230  void startContents() {}
231  void endContents() {}
232  void writeNonBreakableSpace(int);
233 
234  void startDescTable(const QCString &title);
235  void endDescTable();
236  void startDescTableRow();
237  void endDescTableRow();
238  void startDescTableTitle();
239  void endDescTableTitle();
240  void startDescTableData();
241  void endDescTableData();
242  void lastIndexPage();
243 
244  void startDotGraph();
245  void endDotGraph(DotClassGraph &);
246  void startInclDepGraph();
247  void endInclDepGraph(DotInclDepGraph &);
248  void startCallGraph();
249  void startGroupCollaboration();
250  void endGroupCollaboration(DotGroupCollaboration &g);
251  void endCallGraph(DotCallGraph &);
252  void startDirDepGraph();
253  void endDirDepGraph(DotDirDeps &g);
254  void writeGraphicalHierarchy(DotGfxHierarchyTable &) {}
255 
256  void startTextBlock(bool) {}
257  void endTextBlock(bool) {}
258 
259  void startMemberDocPrefixItem() {}
260  void endMemberDocPrefixItem() { m_t << "\\\\\n"; }
261  void startMemberDocName(bool) {}
262  void endMemberDocName() {}
263  void startParameterType(bool,const QCString &);
264  void endParameterType();
265  void startParameterName(bool);
266  void endParameterName();
267  void startParameterExtra();
268  void endParameterExtra(bool last,bool one,bool bracket);
269  void startParameterDefVal(const char *s) { docify(s); startTypewriter(); }
270  void endParameterDefVal() { endTypewriter(); }
271  void startParameterList(bool);
272  void endParameterList();
273  void exceptionEntry(const QCString &,bool);
274 
275  void startConstraintList(const QCString &);
276  void startConstraintParam();
277  void endConstraintParam();
278  void startConstraintType();
279  void endConstraintType();
280  void startConstraintDocs();
281  void endConstraintDocs();
282  void endConstraintList();
283 
284  void startMemberDocSimple(bool);
285  void endMemberDocSimple(bool);
286  void startInlineMemberType();
287  void endInlineMemberType();
288  void startInlineMemberName();
289  void endInlineMemberName();
290  void startInlineMemberDoc();
291  void endInlineMemberDoc();
292 
293  void startLabels();
294  void writeLabel(const QCString &l,bool isLast);
295  void endLabels();
296 
297  void writeLocalToc(const SectionRefs &sr,const LocalToc &lt);
298 
299  void setCurrentDoc(const Definition *,const QCString &,bool) {}
300  void addWord(const QCString &,bool) {}
301 
302  void addCodeGen(OutputCodeList &list);
303 
304  private:
305  void startTitle();
306  void endTitle() { m_t << "}"; }
307 
308  bool m_firstDescItem = true;
309  bool m_disableLinks = false;
310  QCString m_relPath;
311  int m_indent = 0;
312  bool m_templateMemberItem = false;
313  std::unique_ptr<OutputCodeList> m_codeList;
314  LatexCodeGenerator *m_codeGen;
315  bool m_insideTableEnv = false;
316  int m_hierarchyLevel = 0;
317 };
318 
319 void writeExtraLatexPackages(TextStream &t);
320 void writeLatexSpecialFormulaChars(TextStream &t);
321 QCString convertToLaTeX(const QCString &s,bool insideTabbing,bool keepSpaces=FALSE);
322 
323 void filterLatexString(TextStream &t,const QCString &str,
324  bool insideTabbing,
325  bool insidePre,
326  bool insideItem,
327  bool insideTable,
328  bool keepSpaces,
329  const bool retainNewline = false);
330 
331 QCString latexEscapeLabelName(const QCString &s);
332 QCString latexEscapeIndexChars(const QCString &s);
333 QCString latexEscapePDFString(const QCString &s);
334 QCString latexFilterURL(const QCString &s);
335 
336 
337 #endif
The common base class of all entity definitions found in the sources.
Definition: definition.h:74
A model of a class/file/namespace member symbol.
Definition: memberdef.h:47
Text streaming class that buffers data.
Definition: textstream.h:34
class that represents a list of constant references to sections.
Definition: section.h:104
Represents a graphical class hierarchy.
Definition: dotgfxhierarchytable.h:31
Definition: types.h:308
Representation of a group collaboration graph.
Definition: dotgroupcollaboration.h:28
opaque representation of the abstract syntax tree (AST)
Definition: docparser.h:46
Generator for LaTeX code fragments.
Definition: latexgen.h:27
Class representing a list of different code generators.
Definition: outputlist.h:199
Class representing a built-in class diagram.
Definition: diagram.h:29
Definition: section.h:27
Representation of an call graph.
Definition: dotcallgraph.h:26
Representation of a class inheritance or dependency graph.
Definition: dotclassgraph.h:28
Generator for LaTeX output.
Definition: latexgen.h:86
Base class for specific output generators.
Definition: outputgen.h:64
Representation of an include dependency graph.
Definition: dotincldepgraph.h:30
Representation of an directory dependency graph.
Definition: dotdirdeps.h:25
This is an alternative implementation of QCString.
Definition: qcstring.h:93
Definition: outputgen.h:49
Definition: outputgen.h:41