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 void writePageNavigation(OutputList &ol) const override;
69
70 private:
73 PageLinkedRefMap m_subPages; // list of pages in the group
78};
79
80std::unique_ptr<PageDef> createPageDef(const QCString &f,int l,const QCString &n,const QCString &d,const QCString &t)
81{
82 return std::make_unique<PageDefImpl>(f,l,n,d,t);
83}
84
85//------------------------------------------------------------------------------------------
86
88 const QCString &d,const QCString &t)
89 : DefinitionMixin(f,l,1,n), m_title(!t.isEmpty() ? t : n)
90{
91 setDocumentation(d,f,l);
92 m_pageScope = nullptr;
96}
97
101
108
110{
111 return !partOfGroups().empty() ? partOfGroups().front() : nullptr;
112}
113
115{
116 if (getGroupDef())
117 return getGroupDef()->getOutputFileBase();
118 else
119 return m_fileName;
120}
121
126
128{
130 {
131 PageDef *pd = toPageDef(def);
132 if (pd)
133 {
134 m_subPages.add(pd->name(),pd);
135 pd->setOuterScope(this);
136 if (this==Doxygen::mainPage.get())
137 {
139 }
140 else
141 {
143 }
144 }
145 }
146}
147
149{
150 const SectionRefs &sectionRefs = getSectionRefs();
151 if (sectionRefs.empty()) return;
152 //printf("PageDefImpl::addSectionsToIndex()\n");
153 int level=1;
154 for (auto it = sectionRefs.begin(); it!=sectionRefs.end(); ++it)
155 {
156 const SectionInfo *si = *it;
157 SectionType type = si->type();
158 if (type.isSection())
159 {
160 //printf(" level=%d title=%s\n",level,qPrint(si->title));
161 int nextLevel = type.level();
162 if (nextLevel>level)
163 {
164 for (int i=level;i<nextLevel;i++)
165 {
166 Doxygen::indexList->incContentsDepth();
167 }
168 }
169 else if (nextLevel<level)
170 {
171 for (int i=nextLevel;i<level;i++)
172 {
173 Doxygen::indexList->decContentsDepth();
174 }
175 }
176 QCString title = si->title();
177 if (title.isEmpty()) title = si->label();
178 title = parseCommentAsText(this,nullptr,title,si->fileName(),si->lineNr());
179 QCString titleAsHtml = parseCommentAsHtml(this,nullptr,si->title(),si->fileName(),si->lineNr());
180 // determine if there is a next level inside this item, but be aware of the anchor and table section references.
181 auto it_next = std::next(it);
182 bool isDir = (it_next!=sectionRefs.end()) ? ((*it_next)->type().isSection() && (*it_next)->type().level() > nextLevel) : false;
183 Doxygen::indexList->addContentsItem(isDir, // isDir
184 title, // name
185 getReference(), // ref
186 getOutputFileBase(), // file
187 si->label(), // anchor
188 false, // separateIndex
189 true, // addToNavIndex
190 nullptr, // def
191 titleAsHtml); // nameAsHtml
192 level = nextLevel;
193 }
194 }
195 while (level>1)
196 {
197 Doxygen::indexList->decContentsDepth();
198 level--;
199 }
200}
201
207
209{
210 bool found = name()=="citelist";
212 {
213 if (rl->listName()==name())
214 {
215 found=TRUE;
216 break;
217 }
218 }
219 if (!found) // not one of the generated related pages
220 {
223 tagFile << " <compound kind=\"page\">\n";
224 tagFile << " <name>" << name() << "</name>\n";
225 tagFile << " <title>" << convertToXML(title()) << "</title>\n";
226 tagFile << " <filename>" << fn << "</filename>\n";
227 for (const auto &subPage : m_subPages)
228 {
229 QCString sfn = subPage->getOutputFileBase();
231 tagFile << " <subpage>" << sfn << "</subpage>\n";
232 }
234 tagFile << " </compound>\n";
235 }
236}
237
239{
240 bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
241 int hierarchyLevel = -1; // Pages start at the root
242 PageDef *pd = this;
243 while (pd->hasParentPage())
244 {
245 pd = (PageDef *)pd->getOuterScope();
246 ++hierarchyLevel;
247 }
248
249 //outputList->disable(OutputType::Man);
250 QCString pageName,manPageName;
251 pageName = escapeCharsInString(name(),FALSE,TRUE);
252 manPageName = escapeCharsInString(name(),TRUE,TRUE);
253
254 //printf("PageDefImpl::writeDocumentation: %s\n",getOutputFileBase().data());
255
257 //1.{
258
260 //2.{
262 startFile(ol,getOutputFileBase(),manPageName,title(),HighlightedItem::Pages,!generateTreeView,
263 QCString() /* altSidebarName */, hierarchyLevel);
264 ol.enableAll();
266 startFile(ol,getOutputFileBase(),pageName,title(),HighlightedItem::Pages,!generateTreeView,
267 QCString() /* altSidebarName */, hierarchyLevel);
269 //2.}
270
271 if (!generateTreeView)
272 {
273 if (getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
274 {
276 if (outerScope)
277 {
278 outerScope->writeNavigationPath(ol);
279 }
280 }
281 ol.endQuickIndices();
282 }
284
285 // save old generator state and write title only to Man generator
287 //2.{
289 ol.startTitleHead(manPageName);
290 ol.endTitleHead(manPageName, manPageName);
291 if (si)
292 {
293 ol.writeString(" - ");
294
295 if (si->title() != manPageName)
296 {
297 ol.generateDoc(docFile(),getStartBodyLine(),this,nullptr,si->title(),true,false,
298 QCString(),true,false,Config_getBool(MARKDOWN_SUPPORT),false);
299 ol.endSection(si->label(),si->type());
300 }
301 }
303 //2.}
304
306 //2.{
309 if (this == Doxygen::mainPage.get() && !hasTitle())
310 title = theTranslator->trMainPage();
311 else
312 title = m_title;
313
314 if (!title.isEmpty() && !name().isEmpty() && si!=nullptr)
315 {
316 ol.startPageDoc(si->title());
319 ol.generateDoc(docFile(),getStartBodyLine(),this,nullptr,title,true,false,
320 QCString(),true,false,Config_getBool(MARKDOWN_SUPPORT),false);
322 ol.endHeaderSection();
323 }
324 else
325 {
326 ol.startPageDoc("");
327 }
329 //2.}
330
331 bool pageWithSections = hasSections();
332 ol.startContents();
333 if ((m_localToc.isHtmlEnabled() || m_localToc.isLatexEnabled() || m_localToc.isDocbookEnabled())
334 && pageWithSections)
335 {
336 writeToc(ol, m_localToc);
337 }
338
340 ol.endContents();
341 ol.endPageDoc();
342
343 if (generateTreeView && getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
344 {
346 }
347 else
348 {
349 if (generateTreeView && Config_getBool(PAGE_OUTLINE_PANEL) && pageWithSections)
350 {
353 ol.writeString("</div><!-- doc-content -->\n");
355 ol.writeString("</div><!-- container -->\n");
357 endFile(ol,true);
358 }
359 else
360 {
361 endFile(ol,false,true);
362 }
363 }
364
366 //1.}
367}
368
370{
371 ol.startTextBlock();
374 {
377 ol.writeString(" - ");
379 }
381 ol.generateDoc(
382 docFile(), // fileName
383 docLine(), // startLine
384 this, // context
385 nullptr, // memberdef
386 docStr, // docStr
387 true, // index words
388 false, // not an example
389 QCString(), // exampleName
390 false, // singleLine
391 false, // linkFromIndex
392 TRUE // markdown support
393 );
394 ol.enableAll();
396 ol.generateDoc(
397 docFile(), // fileName
398 docLine(), // startLine
399 this, // context
400 nullptr, // memberdef
401 docStr, // docStr
402 false, // index words
403 false, // not an example
404 QCString(), // exampleName
405 false, // singleLine
406 false, // linkFromIndex
407 TRUE // markdown support
408 );
410 ol.endTextBlock();
411
412 if (hasSubPages())
413 {
414 // for printed documentation we write subpages as section's of the
415 // parent page.
417 ol.disableAll();
421
422 for (const auto &subPage : m_subPages)
423 {
424 ol.writePageLink(subPage->getOutputFileBase(), FALSE);
425 }
426
428 }
429}
430
435
437{
438 bool externalPages = Config_getBool(EXTERNAL_PAGES);
439 return // not part of a group
440 !getGroupDef() &&
441 // not an externally defined page
442 (!isReference() || externalPages);
443}
444
446{
447 return // not part of a group
448 !getGroupDef() &&
449 // not an externally defined page
450 !isReference();
451}
452
454{
455 return !m_subPages.empty();
456}
457
459{
460 m_nestingLevel = l;
461}
462
464{
465 m_localToc = lt;
466}
467
469{
470 m_showLineNo = b;
471}
472
474{
475 return m_showLineNo;
476}
477
479{
480 return !m_title.isEmpty() && m_title.lower()!="notitle";
481}
482
484{
485 m_title = title;
486}
487
488// --- Cast functions
489
491{
492 if (d==nullptr) return nullptr;
493 if (d && typeid(*d)==typeid(PageDefImpl))
494 {
495 return static_cast<PageDef*>(d);
496 }
497 else
498 {
499 return nullptr;
500 }
501}
502
504{
505 if (d==nullptr) return nullptr;
506 if (d && typeid(*d)==typeid(PageDefImpl))
507 {
508 return static_cast<const PageDef*>(d);
509 }
510 else
511 {
512 return nullptr;
513 }
514}
515
The common base class of all entity definitions found in the sources.
Definition definition.h:76
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
bool hasSections() 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
std::unique_ptr< RefList > Ptr
Definition linkedmap.h:38
const T * find(const std::string &key) const
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:674
void writeString(const QCString &text)
Definition outputlist.h:413
void endTitleHead(const QCString &fileName, const QCString &name)
Definition outputlist.h:407
void endSection(const QCString &lab, SectionType t)
Definition outputlist.h:590
void disable(OutputType o)
void startTitleHead(const QCString &fileName)
Definition outputlist.h:405
void enable(OutputType o)
void endContents()
Definition outputlist.h:622
void endHeaderSection()
Definition outputlist.h:469
void startHeaderSection()
Definition outputlist.h:467
void endPageDoc()
Definition outputlist.h:626
void startTextBlock(bool dense=FALSE)
Definition outputlist.h:672
void disableAll()
void pushGeneratorState()
void disableAllBut(OutputType o)
void popGeneratorState()
void endQuickIndices()
Definition outputlist.h:606
void startPageDoc(const QCString &pageTitle)
Definition outputlist.h:624
void writePageOutline()
Definition outputlist.h:618
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=Config_getBool(MARKDOWN_SUPPORT), bool autolinkSupport=Config_getBool(AUTOLINK_SUPPORT))
void startContents()
Definition outputlist.h:620
void writePageLink(const QCString &name, bool first)
Definition outputlist.h:391
void enableAll()
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:478
void setNestingLevel(int l) override
Definition pagedef.cpp:458
void writeDocumentation(OutputList &ol) override
Definition pagedef.cpp:238
bool hasParentPage() const override
Definition pagedef.cpp:202
bool documentedPage() const override
Definition pagedef.cpp:445
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:87
void addInnerCompound(Definition *d) override
Definition pagedef.cpp:127
~PageDefImpl() override
Definition pagedef.cpp:98
bool m_showLineNo
Definition pagedef.cpp:77
Definition * m_pageScope
Definition pagedef.cpp:74
LocalToc m_localToc
Definition pagedef.cpp:76
QCString m_title
Definition pagedef.cpp:72
void writeTagFile(TextStream &) override
Definition pagedef.cpp:208
bool showLineNo() const override
Definition pagedef.cpp:473
void setFileName(const QCString &name) override
Definition pagedef.cpp:122
void findSectionsInDocumentation() override
Definition pagedef.cpp:102
void writePageNavigation(OutputList &ol) const override
Definition pagedef.cpp:431
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:483
void setShowLineNo(bool) override
Definition pagedef.cpp:468
QCString getOutputFileBase() const override
Definition pagedef.cpp:114
const PageLinkedRefMap & getSubPages() const override
Definition pagedef.cpp:50
int m_nestingLevel
Definition pagedef.cpp:75
CodeSymbolType codeSymbolType() const override
Definition pagedef.cpp:42
const GroupDef * getGroupDef() const override
Definition pagedef.cpp:109
bool visibleInIndex() const override
Definition pagedef.cpp:436
void writePageDocumentation(OutputList &ol) const override
Definition pagedef.cpp:369
void addSectionsToIndex() override
Definition pagedef.cpp:148
QCString title() const override
Definition pagedef.cpp:48
void setLocalToc(const LocalToc &tl) override
Definition pagedef.cpp:463
QCString m_fileName
Definition pagedef.cpp:71
void setPageScope(Definition *d) override
Definition pagedef.cpp:58
QCString anchor() const override
Definition pagedef.cpp:46
PageLinkedRefMap m_subPages
Definition pagedef.cpp:73
bool hasSubPages() const override
Definition pagedef.cpp:453
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
class that provide information about a section.
Definition section.h:57
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:178
class that represents a list of constant references to sections.
Definition section.h:102
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
#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:427
void startFile(OutputList &ol, const QCString &name, const QCString &manName, const QCString &title, HighlightedItem hli, bool additionalIndices, const QCString &altSidebarName, int hierarchyLevel, const QCString &allMembersFile)
Definition index.cpp:401
void endFileWithNavPath(OutputList &ol, const DefinitionMutable *d, bool showPageNavigation)
Definition index.cpp:448
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:80
PageDef * toPageDef(Definition *d)
Definition pagedef.cpp:490
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
CodeSymbolType
Definition types.h:481
QCString parseCommentAsHtml(const Definition *scope, const MemberDef *member, const QCString &doc, const QCString &fileName, int lineNr)
Definition util.cpp:5927
QCString parseCommentAsText(const Definition *scope, const MemberDef *md, const QCString &doc, const QCString &fileName, int lineNr)
Definition util.cpp:5876
QCString escapeCharsInString(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:3843
QCString convertNameToFile(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:4017
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:4425
void addHtmlExtensionIfMissing(QCString &fName)
Definition util.cpp:5412
A bunch of utility functions.