Imported Upstream version 1.9.4
[platform/upstream/doxygen.git] / src / docbookgen.h
1 /******************************************************************************
2 *
3 *
4 *
5 * Copyright (C) 1997-2015 by Dimitri van Heesch.
6 *
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation under the terms of the GNU General Public License is hereby
9 * granted. No representations are made about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
11 * See the GNU General Public License for more details.
12 *
13 */
14
15 #ifndef DOCBOOKGEN_H
16 #define DOCBOOKGEN_H
17
18 #include <iostream>
19
20 #include "config.h"
21 #include "outputgen.h"
22
23 class DocbookCodeGenerator : public CodeOutputInterface
24 {
25   public:
26     DocbookCodeGenerator(TextStream &t);
27     void setRelativePath(const QCString &path) { m_relPath = path; }
28     void setSourceFileName(const QCString &sourceFileName) { m_sourceFileName = sourceFileName; }
29     QCString sourceFileName() { return m_sourceFileName; }
30
31     void codify(const QCString &text);
32     void writeCodeLink(CodeSymbolType type,
33         const QCString &ref,const QCString &file,
34         const QCString &anchor,const QCString &name,
35         const QCString &tooltip);
36     void writeCodeLinkLine(CodeSymbolType type,
37         const QCString &ref,const QCString &file,
38         const QCString &anchor,const QCString &name,
39         const QCString &tooltip, bool);
40     void writeTooltip(const QCString &, const DocLinkInfo &, const QCString &,
41                       const QCString &, const SourceLinkInfo &, const SourceLinkInfo &
42                      );
43     void startCodeLine(bool);
44     void endCodeLine();
45     void startFontClass(const QCString &colorClass);
46     void endFontClass();
47     void writeCodeAnchor(const QCString &);
48     void writeLineNumber(const QCString &extRef,const QCString &compId,
49         const QCString &anchorId,int l, bool writeLineAnchor);
50     void finish();
51     void startCodeFragment(const QCString &style);
52     void endCodeFragment(const QCString &style);
53
54   private:
55     TextStream &m_t;
56     QCString m_refId;
57     QCString m_external;
58     int m_lineNumber = -1;
59     int m_col = 0;
60     bool m_insideCodeLine = false;
61     bool m_insideSpecialHL = false;
62     QCString m_relPath;
63     QCString m_sourceFileName;
64 };
65
66
67 #if 0
68 // define for cases that have been implemented with an empty body
69 #define DB_GEN_EMPTY  m_t << "<!-- DBG_GEN_head_check " << __LINE__ << " -->\n";
70 #else
71 #define DB_GEN_EMPTY
72 #endif
73
74 #if 0
75 // Generic debug statements
76 #define DB_GEN_H DB_GEN_H1(m_t)
77 #define DB_GEN_H1(x) x << "<!-- DBG_GEN_head " << __LINE__ << " -->\n";
78 #define DB_GEN_H2(y) DB_GEN_H2a(m_t,y)
79 #define DB_GEN_H2a(x,y) x << "<!-- DBG_GEN_head " << __LINE__ << " " << y << " -->\n";
80 // define for cases that have NOT yet been implemented / considered
81 #define DB_GEN_NEW fprintf(stderr,"DBG_GEN_head %d\n",__LINE__); DB_GEN_H
82 #else
83 #define DB_GEN_H
84 #define DB_GEN_H1(x)
85 #define DB_GEN_H2(y)
86 #define DB_GEN_H2a(x,y)
87 #define DB_GEN_NEW
88 #endif
89
90 class DocbookGenerator : public OutputGenerator
91 {
92   public:
93     DocbookGenerator();
94     DocbookGenerator(const DocbookGenerator &o);
95     DocbookGenerator &operator=(const DocbookGenerator &o);
96     virtual ~DocbookGenerator();
97     virtual std::unique_ptr<OutputGenerator> clone() const;
98
99     static void init();
100     void cleanup();
101
102     OutputType type() const { return Docbook; }
103
104     // --- CodeOutputInterface
105     void codify(const QCString &text)
106     { m_codeGen.codify(text); }
107     void writeCodeLink(CodeSymbolType type,
108                        const QCString &ref, const QCString &file,
109                        const QCString &anchor,const QCString &name,
110                        const QCString &tooltip)
111     { m_codeGen.writeCodeLink(type,ref,file,anchor,name,tooltip); }
112     void writeLineNumber(const QCString &ref,const QCString &file,const QCString &anchor,int lineNumber, bool writeLineAnchor)
113     { m_codeGen.writeLineNumber(ref,file,anchor,lineNumber,writeLineAnchor); }
114     void writeTooltip(const QCString &id, const DocLinkInfo &docInfo, const QCString &decl,
115                       const QCString &desc, const SourceLinkInfo &defInfo, const SourceLinkInfo &declInfo
116                      )
117     { m_codeGen.writeTooltip(id,docInfo,decl,desc,defInfo,declInfo); }
118     void startCodeLine(bool hasLineNumbers)
119     { m_codeGen.startCodeLine(hasLineNumbers); }
120     void endCodeLine()
121     { m_codeGen.endCodeLine(); }
122     void startFontClass(const QCString &s)
123     { m_codeGen.startFontClass(s); }
124     void endFontClass()
125     { m_codeGen.endFontClass(); }
126     void writeCodeAnchor(const QCString &anchor)
127     { m_codeGen.writeCodeAnchor(anchor); }
128     void startCodeFragment(const QCString &style)
129     { m_codeGen.startCodeFragment(style); }
130     void endCodeFragment(const QCString &style)
131     { m_codeGen.endCodeFragment(style); }
132     // ---------------------------
133
134     void writeDoc(const IDocNodeAST *node,const Definition *ctx,const MemberDef *md,int id);
135
136     ///////////////////////////////////////////////////////////////
137     // structural output interface
138     ///////////////////////////////////////////////////////////////
139     void startFile(const QCString &name,const QCString &manName,
140                            const QCString &title,int id);
141     void writeSearchInfo(){DB_GEN_EMPTY};
142     void writeFooter(const QCString &){DB_GEN_NEW};
143     void endFile();
144     void startIndexSection(IndexSections);
145     void endIndexSection(IndexSections);
146     void writePageLink(const QCString &,bool);
147     void startProjectNumber(){DB_GEN_NEW};
148     void endProjectNumber(){DB_GEN_NEW};
149     void writeStyleInfo(int){DB_GEN_EMPTY};
150     void startTitleHead(const QCString &);
151     void endTitleHead(const QCString &fileName,const QCString &name);
152     void startIndexListItem(){DB_GEN_NEW};
153     void endIndexListItem(){DB_GEN_NEW};
154     void startIndexList(){DB_GEN_NEW};
155     void endIndexList(){DB_GEN_NEW};
156     void startIndexKey(){DB_GEN_NEW};
157     void endIndexKey(){DB_GEN_NEW};
158     void startIndexValue(bool){DB_GEN_NEW};
159     void endIndexValue(const QCString &,bool){DB_GEN_NEW};
160     void startItemList()  {DB_GEN_EMPTY};
161     void endItemList()    {DB_GEN_EMPTY};
162
163     void startIndexItem(const QCString &,const QCString &){DB_GEN_NEW};
164     void endIndexItem(const QCString &,const QCString &){DB_GEN_NEW};
165     void startItemListItem() {DB_GEN_EMPTY};
166     void endItemListItem() {DB_GEN_EMPTY};
167     void docify(const QCString &text);
168     void writeChar(char);
169     void writeString(const QCString &);
170     void startParagraph(const QCString &);
171     void endParagraph();
172     void writeObjectLink(const QCString &,const QCString &,const QCString &,const QCString &);
173     void startHtmlLink(const QCString &){DB_GEN_NEW};
174     void endHtmlLink(){DB_GEN_NEW};
175     void startBold();
176     void endBold();
177     void startTypewriter();
178     void endTypewriter();
179     void startEmphasis(){DB_GEN_NEW};
180     void endEmphasis(){DB_GEN_NEW};
181     void writeRuler();
182     void startDescription(){DB_GEN_NEW};
183     void endDescription(){DB_GEN_NEW};
184     void startDescItem(){DB_GEN_NEW};
185     void startDescForItem(){DB_GEN_EMPTY};
186     void endDescForItem(){DB_GEN_EMPTY};
187     void endDescItem(){DB_GEN_NEW};
188     void startCenter(){DB_GEN_NEW};
189     void endCenter(){DB_GEN_NEW};
190     void startSmall(){DB_GEN_NEW};
191     void endSmall(){DB_GEN_NEW};
192     void startExamples();
193     void endExamples();
194     void startParamList(BaseOutputDocInterface::ParamListTypes,const QCString &){DB_GEN_NEW};
195     void endParamList(){DB_GEN_NEW};
196     void startTitle(){DB_GEN_NEW};
197     void endTitle(){DB_GEN_NEW};
198     void writeAnchor(const QCString &,const QCString &){DB_GEN_EMPTY};
199     void startSection(const QCString &,const QCString &,SectionType);
200     void endSection(const QCString &,SectionType);
201     void lineBreak(const QCString &);
202     void addIndexItem(const QCString &,const QCString &);
203     void writeNonBreakableSpace(int);
204     void startDescTable(const QCString &);
205     void endDescTable();
206     void startDescTableRow();
207     void endDescTableRow();
208     void startDescTableTitle();
209     void endDescTableTitle();
210     void startDescTableData();
211     void endDescTableData();
212     void startTextLink(const QCString &,const QCString &){DB_GEN_NEW};
213     void endTextLink(){DB_GEN_NEW};
214     void startPageRef(){DB_GEN_NEW};
215     void endPageRef(const QCString &,const QCString &){DB_GEN_NEW};
216     void startSubsection(){DB_GEN_NEW};
217     void endSubsection(){DB_GEN_NEW};
218     void startSubsubsection();
219     void endSubsubsection();
220
221
222     void startGroupHeader(int);
223     void endGroupHeader(int);
224     void startMemberSections(){DB_GEN_EMPTY};
225     void endMemberSections(){DB_GEN_EMPTY};
226     void startHeaderSection(){DB_GEN_EMPTY};
227     void endHeaderSection(){DB_GEN_EMPTY};
228     void startMemberHeader(const QCString &anchor, int typ);
229     void endMemberHeader();
230     void startMemberSubtitle(){DB_GEN_EMPTY};
231     void endMemberSubtitle(){DB_GEN_EMPTY};
232     void startMemberDocList();
233     void endMemberDocList();
234     void startMemberList();
235     void endMemberList();
236     void startInlineHeader(){DB_GEN_NEW};
237     void endInlineHeader(){DB_GEN_NEW};
238     void startAnonTypeScope(int){DB_GEN_EMPTY};
239     void endAnonTypeScope(int){DB_GEN_EMPTY};
240     void startMemberItem(const QCString &,int,const QCString &);
241     void endMemberItem();
242     void startMemberTemplateParams();
243     void endMemberTemplateParams(const QCString &,const QCString &);
244     void startCompoundTemplateParams() { startSubsubsection(); }
245     void endCompoundTemplateParams() { endSubsubsection(); }
246     void startMemberGroupHeader(bool);
247     void endMemberGroupHeader();
248     void startMemberGroupDocs(){DB_GEN_EMPTY};
249     void endMemberGroupDocs(){DB_GEN_EMPTY};
250     void startMemberGroup();
251     void endMemberGroup(bool);
252     void insertMemberAlign(bool){DB_GEN_EMPTY};
253     void insertMemberAlignLeft(int,bool){DB_GEN_EMPTY};
254     void startMemberDoc(const QCString &,const QCString &,
255                         const QCString &,const QCString &,int,int,bool);
256     void endMemberDoc(bool);
257     void startDoxyAnchor(const QCString &fName,const QCString &manName,
258                          const QCString &anchor,const QCString &name,
259                          const QCString &args);
260     void endDoxyAnchor(const QCString &fileName,const QCString &anchor);
261     void writeLatexSpacing(){DB_GEN_EMPTY}
262     void writeStartAnnoItem(const QCString &,const QCString &,
263                             const QCString &,const QCString &){DB_GEN_NEW};
264     void writeEndAnnoItem(const QCString &){DB_GEN_NEW};
265     void startMemberDescription(const QCString &,const QCString &,bool){DB_GEN_EMPTY};
266     void endMemberDescription(){DB_GEN_EMPTY};
267     void startMemberDeclaration(){DB_GEN_EMPTY};
268     void endMemberDeclaration(const QCString &,const QCString &){DB_GEN_EMPTY};
269     void writeInheritedSectionTitle(const QCString &,const QCString &,
270                                     const QCString &,const QCString &,
271                                     const QCString &,const QCString &){DB_GEN_NEW};
272     void startIndent(){DB_GEN_EMPTY};
273     void endIndent(){DB_GEN_EMPTY};
274     void writeSynopsis(){DB_GEN_EMPTY};
275     void startClassDiagram();
276     void endClassDiagram(const ClassDiagram &,const QCString &,const QCString &);
277     void startDotGraph();
278     void endDotGraph(DotClassGraph &g);
279     void startInclDepGraph();
280     void endInclDepGraph(DotInclDepGraph &g);
281     void startGroupCollaboration();
282     void endGroupCollaboration(DotGroupCollaboration &g);
283     void startCallGraph();
284     void endCallGraph(DotCallGraph &g);
285     void startDirDepGraph();
286     void endDirDepGraph(DotDirDeps &g);
287     void writeGraphicalHierarchy(DotGfxHierarchyTable &){DB_GEN_NEW};
288     void startQuickIndices(){DB_GEN_EMPTY};
289     void endQuickIndices(){DB_GEN_EMPTY};
290     void writeSplitBar(const QCString &){DB_GEN_EMPTY};
291     void writeNavigationPath(const QCString &){DB_GEN_NEW};
292     void writeLogo(){DB_GEN_NEW};
293     void writeQuickLinks(bool,HighlightedItem,const QCString &){DB_GEN_EMPTY};
294     void writeSummaryLink(const QCString &,const QCString &,const QCString &,bool){DB_GEN_EMPTY};
295     void startContents(){DB_GEN_EMPTY};
296     void endContents(){DB_GEN_EMPTY};
297     void startPageDoc(const QCString &){DB_GEN_EMPTY}
298     void endPageDoc() {DB_GEN_EMPTY}
299     void startTextBlock(bool);
300     void endTextBlock(bool);
301     void lastIndexPage(){DB_GEN_EMPTY};
302     void startMemberDocPrefixItem();
303     void endMemberDocPrefixItem();
304     void startMemberDocName(bool);
305     void endMemberDocName();
306     void startParameterType(bool,const QCString &){DB_GEN_EMPTY};
307     void endParameterType(){DB_GEN_EMPTY};
308     void startParameterName(bool);
309     void endParameterName(bool,bool,bool);
310     void startParameterList(bool);
311     void endParameterList();
312     void exceptionEntry(const QCString &,bool);
313
314     void startConstraintList(const QCString &);
315     void startConstraintParam();
316     void endConstraintParam();
317     void startConstraintType();
318     void endConstraintType();
319     void startConstraintDocs();
320     void endConstraintDocs();
321     void endConstraintList();
322
323     void startMemberDocSimple(bool);
324     void endMemberDocSimple(bool);
325     void startInlineMemberType();
326     void endInlineMemberType();
327     void startInlineMemberName();
328     void endInlineMemberName();
329     void startInlineMemberDoc();
330     void endInlineMemberDoc();
331
332     void startLabels();
333     void writeLabel(const QCString &,bool);
334     void endLabels();
335
336     void setCurrentDoc(const Definition *,const QCString &,bool) {DB_GEN_EMPTY}
337     void addWord(const QCString &,bool) {DB_GEN_EMPTY}
338
339 private:
340     void openSection(const QCString &attr=QCString());
341     void closeSection();
342     void closeAllSections();
343
344     QCString relPath;
345     DocbookCodeGenerator m_codeGen;
346     bool m_denseText = false;
347     bool m_inGroup = false;
348     int  m_levelListItem = 0;
349     bool m_inListItem[20] = { false, };
350     bool m_inSimpleSect[20] = { false, };
351     bool m_descTable = false;
352     bool m_simpleTable = false;
353     int m_inLevel = -1;
354     bool m_firstMember = false;
355     int m_openSectionCount = 0;
356 };
357
358 #endif