Doxygen
Loading...
Searching...
No Matches
pagedef.cpp
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2015 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#include "pagedef.h"
17#include "groupdef.h"
18#include "docparser.h"
19#include "config.h"
20#include "util.h"
21#include "outputlist.h"
22#include "doxygen.h"
23#include "language.h"
24#include "namespacedef.h"
25#include "reflist.h"
26#include "definitionimpl.h"
27#include "indexlist.h"
28
29//------------------------------------------------------------------------------------------
30
31class PageDefImpl : public DefinitionMixin<PageDef>
32{
33 public:
34 PageDefImpl(const QCString &f,int l,const QCString &n,const QCString &d,const QCString &t);
35 ~PageDefImpl() override;
37
38 void setFileName(const QCString &name) override;
39 void setLocalToc(const LocalToc &tl) override;
40 void setShowLineNo(bool) override;
41 DefType definitionType() const override { return TypePage; }
43 bool isLinkableInProject() const override { return /*hasDocumentation() &&*/ !isReference(); }
44 bool isLinkable() const override { return isLinkableInProject() || isReference(); }
45 QCString getOutputFileBase() const override;
46 QCString anchor() const override { return QCString(); }
47 void findSectionsInDocumentation() override;
48 QCString title() const override { return m_title; }
49 const GroupDef * getGroupDef() const override;
50 const PageLinkedRefMap &getSubPages() const override { return m_subPages; }
51 void addInnerCompound(Definition *d) override;
52 bool visibleInIndex() const override;
53 bool documentedPage() const override;
54 bool hasSubPages() const override;
55 bool hasParentPage() const override;
56 bool hasTitle() const override;
57 LocalToc localToc() const override { return m_localToc; }
58 void setPageScope(Definition *d) override { m_pageScope = d; }
59 Definition *getPageScope() const override { return m_pageScope; }
60 QCString displayName(bool=TRUE) const override { return hasTitle() ? m_title : DefinitionMixin::name(); }
61 bool showLineNo() const override;
62 void setTitle(const QCString &title) override;
63 void writeDocumentation(OutputList &ol) override;
64 void writeTagFile(TextStream &) override;
65 void setNestingLevel(int l) override;
66 void writePageDocumentation(OutputList &ol) const override;
67 void addSectionsToIndex() override;
68
69 private:
70 QCString m_fileName;
71 QCString m_title;
72 PageLinkedRefMap m_subPages; // list of pages in the group
73 Definition *m_pageScope;
75 LocalToc m_localToc;
77};
78
79std::unique_ptr<PageDef> createPageDef(const QCString &f,int l,const QCString &n,const QCString &d,const QCString &t)
80{
81 return std::make_unique<PageDefImpl>(f,l,n,d,t);
82}
83
84//------------------------------------------------------------------------------------------
85
87 const QCString &d,const QCString &t)
88 : DefinitionMixin(f,l,1,n), m_title(!t.isEmpty() ? t : n)
89{
90 setDocumentation(d,f,l);
91 m_pageScope = nullptr;
95}
96
100
107
109{
110 return !partOfGroups().empty() ? partOfGroups().front() : nullptr;
111}
112
114{
115 if (getGroupDef())
116 return getGroupDef()->getOutputFileBase();
117 else
118 return m_fileName;
119}
120
125
127{
129 {
130 PageDef *pd = toPageDef(def);
131 if (pd)
132 {
133 m_subPages.add(pd->name(),pd);
134 pd->setOuterScope(this);
135 if (this==Doxygen::mainPage.get())
136 {
138 }
139 else
140 {
142 }
143 }
144 }
145}
146
148{
149 const SectionRefs &sectionRefs = getSectionRefs();
150 if (sectionRefs.empty()) return;
151 //printf("PageDefImpl::addSectionsToIndex()\n");
152 int level=1;
153 for (auto it = sectionRefs.begin(); it!=sectionRefs.end(); ++it)
154 {
155 const SectionInfo *si = *it;
156 SectionType type = si->type();
157 if (type.isSection())
158 {
159 //printf(" level=%d title=%s\n",level,qPrint(si->title));
160 int nextLevel = type.level();
161 if (nextLevel>level)
162 {
163 for (int i=level;i<nextLevel;i++)
164 {
166 }
167 }
168 else if (nextLevel<level)
169 {
170 for (int i=nextLevel;i<level;i++)
171 {
173 }
174 }
175 QCString title = si->title();
176 if (title.isEmpty()) title = si->label();
177 title = parseCommentAsText(this,nullptr,title,si->fileName(),si->lineNr());
178 // determine if there is a next level inside this item, but be aware of the anchor and table section references.
179 auto it_next = std::next(it);
180 bool isDir = (it_next!=sectionRefs.end()) ? ((*it_next)->type().isSection() && (*it_next)->type().level() > nextLevel) : false;
182 getReference(),
184 si->label(),
185 false,
186 true);
187 level = nextLevel;
188 }
189 }
190 while (level>1)
191 {
193 level--;
194 }
195}
196
202
204{
205 bool found = name()=="citelist";
207 {
208 if (rl->listName()==name())
209 {
210 found=TRUE;
211 break;
212 }
213 }
214 if (!found) // not one of the generated related pages
215 {
216 QCString fn = getOutputFileBase();
218 tagFile << " <compound kind=\"page\">\n";
219 tagFile << " <name>" << name() << "</name>\n";
220 tagFile << " <title>" << convertToXML(title()) << "</title>\n";
221 tagFile << " <filename>" << fn << "</filename>\n";
222 for (const auto &subPage : m_subPages)
223 {
224 QCString sfn = subPage->getOutputFileBase();
226 tagFile << " <subpage>" << sfn << "</subpage>\n";
227 }
229 tagFile << " </compound>\n";
230 }
231}
232
234{
235 bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
236 int hierarchyLevel = -1; // Pages start at the root
237 PageDef *pd = this;
238 while (pd->hasParentPage())
239 {
240 pd = (PageDef *)pd->getOuterScope();
241 ++hierarchyLevel;
242 }
243
244 //outputList->disable(OutputType::Man);
245 QCString pageName,manPageName;
246 pageName = escapeCharsInString(name(),FALSE,TRUE);
247 manPageName = escapeCharsInString(name(),TRUE,TRUE);
248
249 //printf("PageDefImpl::writeDocumentation: %s\n",getOutputFileBase().data());
250
252 //1.{
253
255 //2.{
257 startFile(ol,getOutputFileBase(),manPageName,title(),HighlightedItem::Pages,!generateTreeView,
258 QCString() /* altSidebarName */, hierarchyLevel);
259 ol.enableAll();
261 startFile(ol,getOutputFileBase(),pageName,title(),HighlightedItem::Pages,!generateTreeView,
262 QCString() /* altSidebarName */, hierarchyLevel);
264 //2.}
265
266 if (!generateTreeView)
267 {
268 if (getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
269 {
270 DefinitionMutable *outerScope = toDefinitionMutable(getOuterScope());
271 if (outerScope)
272 {
273 outerScope->writeNavigationPath(ol);
274 }
275 }
276 ol.endQuickIndices();
277 }
278 const SectionInfo *si=SectionManager::instance().find(name());
279
280 // save old generator state and write title only to Man generator
282 //2.{
284 ol.startTitleHead(manPageName);
285 ol.endTitleHead(manPageName, manPageName);
286 if (si)
287 {
288 ol.writeString(" - ");
289
290 if (si->title() != manPageName)
291 {
292 ol.generateDoc(docFile(),getStartBodyLine(),this,nullptr,si->title(),TRUE,FALSE,
293 QCString(),TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT));
294 ol.endSection(si->label(),si->type());
295 }
296 }
298 //2.}
299
301 //2.{
303 QCString title;
304 if (this == Doxygen::mainPage.get() && !hasTitle())
306 else
307 title = m_title;
308
309 if (!title.isEmpty() && !name().isEmpty() && si!=nullptr)
310 {
311 ol.startPageDoc(si->title());
312 //ol.startSection(si->label,si->title,si->type);
315 ol.parseText(title);
317 ol.endHeaderSection();
318
319 /*ol.generateDoc(docFile(),getStartBodyLine(),this,nullptr,si->title(),TRUE,FALSE,
320 QCString(),TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT));*/
321 }
322 else
323 ol.startPageDoc("");
325 //2.}
326
327 ol.startContents();
328 if ((m_localToc.isHtmlEnabled() || m_localToc.isLatexEnabled() || m_localToc.isDocbookEnabled())
329 && hasSections())
330 {
331 writeToc(ol, m_localToc);
332 }
333
335 ol.endContents();
336 ol.endPageDoc();
337
338 if (generateTreeView && getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
339 {
341 }
342 else
343 {
344 endFile(ol,FALSE,TRUE);
345 }
346
348 //1.}
349}
350
352{
353 ol.startTextBlock();
354 QCString docStr = (briefDescription().isEmpty()?"":briefDescription()+"\n\n")+documentation()+inbodyDocumentation();
356 {
359 ol.writeString(" - ");
361 }
363 ol.generateDoc(
364 docFile(), // fileName
365 docLine(), // startLine
366 this, // context
367 nullptr, // memberdef
368 docStr, // docStr
369 true, // index words
370 false, // not an example
371 QCString(), // exampleName
372 false, // singleLine
373 false, // linkFromIndex
374 TRUE // markdown support
375 );
376 ol.enableAll();
378 ol.generateDoc(
379 docFile(), // fileName
380 docLine(), // startLine
381 this, // context
382 nullptr, // memberdef
383 docStr, // docStr
384 false, // index words
385 false, // not an example
386 QCString(), // exampleName
387 false, // singleLine
388 false, // linkFromIndex
389 TRUE // markdown support
390 );
392 ol.endTextBlock();
393
394 if (hasSubPages())
395 {
396 // for printed documentation we write subpages as section's of the
397 // parent page.
399 ol.disableAll();
403
404 for (const auto &subPage : m_subPages)
405 {
406 ol.writePageLink(subPage->getOutputFileBase(), FALSE);
407 }
408
410 }
411}
412
414{
415 bool externalPages = Config_getBool(EXTERNAL_PAGES);
416 return // not part of a group
417 !getGroupDef() &&
418 // not an externally defined page
419 (!isReference() || externalPages);
420}
421
423{
424 return // not part of a group
425 !getGroupDef() &&
426 // not an externally defined page
427 !isReference();
428}
429
431{
432 return !m_subPages.empty();
433}
434
436{
437 m_nestingLevel = l;
438}
439
441{
442 m_localToc = lt;
443}
444
446{
447 m_showLineNo = b;
448}
449
451{
452 return m_showLineNo;
453}
454
456{
457 return !m_title.isEmpty() && m_title.lower()!="notitle";
458}
459
461{
462 m_title = title;
463}
464
465// --- Cast functions
466
468{
469 if (d==nullptr) return nullptr;
470 if (d && typeid(*d)==typeid(PageDefImpl))
471 {
472 return static_cast<PageDef*>(d);
473 }
474 else
475 {
476 return nullptr;
477 }
478}
479
481{
482 if (d==nullptr) return nullptr;
483 if (d && typeid(*d)==typeid(PageDefImpl))
484 {
485 return static_cast<const PageDef*>(d);
486 }
487 else
488 {
489 return nullptr;
490 }
491}
492
The common base class of all entity definitions found in the sources.
Definition definition.h:76
virtual bool hasSections() const =0
virtual DefType definitionType() const =0
virtual QCString getOutputFileBase() const =0
virtual Definition * getOuterScope() const =0
virtual const QCString & name() const =0
friend DefinitionMutable * toDefinitionMutable(Definition *)
bool isReference() const override
const QCString & name() const override
bool hasBriefDescription() const override
QCString docFile() const override
void setDocumentation(const QCString &doc, const QCString &docFile, int docLine, bool stripWhiteSpace=TRUE) override
QCString briefDescription(bool abbreviate=FALSE) const override
Definition * getOuterScope() const override
QCString getReference() const override
DefinitionMixin(const QCString &defFileName, int defLine, int defColumn, const QCString &name, const char *b=nullptr, const char *d=nullptr, bool isSymbol=TRUE)
const GroupList & partOfGroups() const override
int getStartBodyLine() const override
void writeToc(OutputList &ol, const LocalToc &lt) const override
QCString inbodyDocumentation() const override
int docLine() const override
const SectionRefs & getSectionRefs() const override
QCString documentation() const override
void writeDocAnchorsToTagFile(TextStream &fs) const override
virtual void setOuterScope(Definition *d)=0
virtual void writeNavigationPath(OutputList &ol) const =0
static std::unique_ptr< PageDef > mainPage
Definition doxygen.h:101
static NamespaceDefMutable * globalScope
Definition doxygen.h:121
static IndexList * indexList
Definition doxygen.h:134
A model of a group of symbols.
Definition groupdef.h:52
void decContentsDepth()
Definition indexlist.h:112
void addContentsItem(bool isDir, const QCString &name, const QCString &ref, const QCString &file, const QCString &anchor, bool separateIndex=FALSE, bool addToNavIndex=FALSE, const Definition *def=nullptr)
Definition indexlist.h:115
void incContentsDepth()
Definition indexlist.h:109
std::unique_ptr< RefList > Ptr
Definition linkedmap.h:38
const T * find(const std::string &key) const
Find an object given the key.
Definition linkedmap.h:47
Class representing a list of output generators that are written to in parallel.
Definition outputlist.h:314
void endTextBlock(bool paraBreak=FALSE)
Definition outputlist.h:671
void writeString(const QCString &text)
Definition outputlist.h:412
void endTitleHead(const QCString &fileName, const QCString &name)
Definition outputlist.h:406
void endSection(const QCString &lab, SectionType t)
Definition outputlist.h:589
void disable(OutputType o)
void startTitleHead(const QCString &fileName)
Definition outputlist.h:404
void enable(OutputType o)
void endContents()
Definition outputlist.h:619
void endHeaderSection()
Definition outputlist.h:468
void startHeaderSection()
Definition outputlist.h:466
void endPageDoc()
Definition outputlist.h:623
void startTextBlock(bool dense=FALSE)
Definition outputlist.h:669
void disableAll()
void generateDoc(const QCString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const QCString &docStr, bool indexWords, bool isExample, const QCString &exampleName, bool singleLine, bool linkFromIndex, bool markdownSupport)
void pushGeneratorState()
void disableAllBut(OutputType o)
void popGeneratorState()
void endQuickIndices()
Definition outputlist.h:605
void startPageDoc(const QCString &pageTitle)
Definition outputlist.h:621
void startContents()
Definition outputlist.h:617
void writePageLink(const QCString &name, bool first)
Definition outputlist.h:390
void enableAll()
void parseText(const QCString &textStr)
A model of a page symbol.
Definition pagedef.h:26
virtual bool hasParentPage() const =0
virtual void setNestingLevel(int)=0
bool hasTitle() const override
Definition pagedef.cpp:455
void setNestingLevel(int l) override
Definition pagedef.cpp:435
void writeDocumentation(OutputList &ol) override
Definition pagedef.cpp:233
bool hasParentPage() const override
Definition pagedef.cpp:197
bool documentedPage() const override
Definition pagedef.cpp:422
LocalToc localToc() const override
Definition pagedef.cpp:57
PageDefImpl(const QCString &f, int l, const QCString &n, const QCString &d, const QCString &t)
Definition pagedef.cpp:86
void addInnerCompound(Definition *d) override
Definition pagedef.cpp:126
~PageDefImpl() override
Definition pagedef.cpp:97
bool m_showLineNo
Definition pagedef.cpp:76
Definition * m_pageScope
Definition pagedef.cpp:73
LocalToc m_localToc
Definition pagedef.cpp:75
QCString m_title
Definition pagedef.cpp:71
void writeTagFile(TextStream &) override
Definition pagedef.cpp:203
bool showLineNo() const override
Definition pagedef.cpp:450
void setFileName(const QCString &name) override
Definition pagedef.cpp:121
void findSectionsInDocumentation() override
Definition pagedef.cpp:101
DefType definitionType() const override
Definition pagedef.cpp:41
bool isLinkable() const override
Definition pagedef.cpp:44
QCString displayName(bool=TRUE) const override
Definition pagedef.cpp:60
bool isLinkableInProject() const override
Definition pagedef.cpp:43
void setTitle(const QCString &title) override
Definition pagedef.cpp:460
void setShowLineNo(bool) override
Definition pagedef.cpp:445
QCString getOutputFileBase() const override
Definition pagedef.cpp:113
const PageLinkedRefMap & getSubPages() const override
Definition pagedef.cpp:50
int m_nestingLevel
Definition pagedef.cpp:74
CodeSymbolType codeSymbolType() const override
Definition pagedef.cpp:42
const GroupDef * getGroupDef() const override
Definition pagedef.cpp:108
bool visibleInIndex() const override
Definition pagedef.cpp:413
void writePageDocumentation(OutputList &ol) const override
Definition pagedef.cpp:351
void addSectionsToIndex() override
Definition pagedef.cpp:147
QCString title() const override
Definition pagedef.cpp:48
void setLocalToc(const LocalToc &tl) override
Definition pagedef.cpp:440
QCString m_fileName
Definition pagedef.cpp:70
void setPageScope(Definition *d) override
Definition pagedef.cpp:58
QCString anchor() const override
Definition pagedef.cpp:46
PageLinkedRefMap m_subPages
Definition pagedef.cpp:72
bool hasSubPages() const override
Definition pagedef.cpp:430
Definition * getPageScope() const override
Definition pagedef.cpp:59
This is an alternative implementation of QCString.
Definition qcstring.h:101
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
static RefListManager & instance()
Definition reflist.h:121
QCString label() const
Definition section.h:68
QCString fileName() const
Definition section.h:73
int lineNr() const
Definition section.h:72
QCString title() const
Definition section.h:69
SectionType type() const
Definition section.h:70
static SectionManager & instance()
returns a reference to the singleton
Definition section.h:175
bool empty() const
Definition section.h:124
const_iterator end() const
Definition section.h:123
const_iterator begin() const
Definition section.h:122
constexpr bool isSection() const
Definition section.h:46
constexpr int level() const
Definition section.h:45
Text streaming class that buffers data.
Definition textstream.h:36
virtual QCString trMainPage()=0
#define Config_getBool(name)
Definition config.h:33
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition construct.h:37
void docFindSections(const QCString &input, const Definition *d, const QCString &fileName)
static void writeTagFile()
void endFile(OutputList &ol, bool skipNavIndex, bool skipEndContents, const QCString &navPath)
Definition index.cpp:421
void startFile(OutputList &ol, const QCString &name, const QCString &manName, const QCString &title, HighlightedItem hli, bool additionalIndices, const QCString &altSidebarName, int hierarchyLevel)
Definition index.cpp:402
void endFileWithNavPath(OutputList &ol, const Definition *d)
Definition index.cpp:441
Translator * theTranslator
Definition language.cpp:71
std::unique_ptr< PageDef > createPageDef(const QCString &f, int l, const QCString &n, const QCString &d, const QCString &t)
Definition pagedef.cpp:79
PageDef * toPageDef(Definition *d)
Definition pagedef.cpp:467
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
CodeSymbolType
Definition types.h:319
QCString parseCommentAsText(const Definition *scope, const MemberDef *md, const QCString &doc, const QCString &fileName, int lineNr)
Definition util.cpp:5707
QCString escapeCharsInString(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:3684
bool found
Definition util.cpp:984
QCString convertNameToFile(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:3858
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:4266
void addHtmlExtensionIfMissing(QCString &fName)
Definition util.cpp:5243
A bunch of utility functions.