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(),false,manPageName,title(),HighlightedItem::Pages,!generateTreeView,
263 QCString() /* altSidebarName */, hierarchyLevel);
264 ol.enableAll();
266 startFile(ol,getOutputFileBase(),false,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(),
299 this,
300 nullptr,
301 si->title(),
302 DocOptions()
303 .setSingleLine(true)
304 .setAutolinkSupport(false));
305 ol.endSection(si->label(),si->type());
306 }
307 }
309 //2.}
310
312 //2.{
315 if (this == Doxygen::mainPage.get() && !hasTitle())
316 title = theTranslator->trMainPage();
317 else
318 title = m_title;
319
320 if (!title.isEmpty() && !name().isEmpty() && si!=nullptr)
321 {
322 ol.startPageDoc(si->title());
325 ol.generateDoc(docFile(),
327 this,
328 nullptr,
329 title,
330 DocOptions()
331 .setIndexWords(true)
332 .setSingleLine(true)
333 .setAutolinkSupport(false));
335 ol.endHeaderSection();
336 }
337 else
338 {
339 ol.startPageDoc("");
340 }
342 //2.}
343
344 bool pageWithSections = hasSections();
345 ol.startContents();
346 if ((m_localToc.isHtmlEnabled() || m_localToc.isLatexEnabled() || m_localToc.isDocbookEnabled())
347 && pageWithSections)
348 {
349 writeToc(ol, m_localToc);
350 }
351
353 ol.endContents();
354 ol.endPageDoc();
355
356 if (generateTreeView && getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
357 {
359 }
360 else
361 {
362 if (generateTreeView && Config_getBool(PAGE_OUTLINE_PANEL) && pageWithSections)
363 {
366 ol.writeString("</div><!-- doc-content -->\n");
368 ol.writeString("</div><!-- container -->\n");
370 endFile(ol,true);
371 }
372 else
373 {
374 endFile(ol,false,true);
375 }
376 }
377
379 //1.}
380}
381
383{
384 ol.startTextBlock();
387 {
390 ol.writeString(" - ");
392 }
393 ol.generateDoc(
394 docFile(), // fileName
395 docLine(), // startLine
396 this, // context
397 nullptr, // memberdef
398 docStr, // docStr
399 DocOptions()
400 .setIndexWords(true));
401 ol.endTextBlock();
402
403 if (hasSubPages())
404 {
405 // for printed documentation we write subpages as section's of the
406 // parent page.
408 ol.disableAll();
412
413 for (const auto &subPage : m_subPages)
414 {
415 ol.writePageLink(subPage->getOutputFileBase(), FALSE);
416 }
417
419 }
420}
421
426
428{
429 bool externalPages = Config_getBool(EXTERNAL_PAGES);
430 return // not part of a group
431 !getGroupDef() &&
432 // not an externally defined page
433 (!isReference() || externalPages);
434}
435
437{
438 return // not part of a group
439 !getGroupDef() &&
440 // not an externally defined page
441 !isReference();
442}
443
445{
446 return !m_subPages.empty();
447}
448
450{
451 m_nestingLevel = l;
452}
453
455{
456 m_localToc = lt;
457}
458
460{
461 m_showLineNo = b;
462}
463
465{
466 return m_showLineNo;
467}
468
470{
471 return !m_title.isEmpty() && m_title.lower()!="notitle";
472}
473
475{
476 m_title = title;
477}
478
479// --- Cast functions
480
482{
483 if (d==nullptr) return nullptr;
484 if (d && typeid(*d)==typeid(PageDefImpl))
485 {
486 return static_cast<PageDef*>(d);
487 }
488 else
489 {
490 return nullptr;
491 }
492}
493
495{
496 if (d==nullptr) return nullptr;
497 if (d && typeid(*d)==typeid(PageDefImpl))
498 {
499 return static_cast<const PageDef*>(d);
500 }
501 else
502 {
503 return nullptr;
504 }
505}
506
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:315
void endTextBlock(bool paraBreak=FALSE)
Definition outputlist.h:672
void writeString(const QCString &text)
Definition outputlist.h:411
void endTitleHead(const QCString &fileName, const QCString &name)
Definition outputlist.h:405
void endSection(const QCString &lab, SectionType t)
Definition outputlist.h:588
void disable(OutputType o)
void startTitleHead(const QCString &fileName)
Definition outputlist.h:403
void enable(OutputType o)
void endContents()
Definition outputlist.h:620
void endHeaderSection()
Definition outputlist.h:467
void startHeaderSection()
Definition outputlist.h:465
void generateDoc(const QCString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const QCString &docStr, const DocOptions &options)
void endPageDoc()
Definition outputlist.h:624
void startTextBlock(bool dense=FALSE)
Definition outputlist.h:670
void disableAll()
void pushGeneratorState()
void disableAllBut(OutputType o)
void popGeneratorState()
void endQuickIndices()
Definition outputlist.h:604
void startPageDoc(const QCString &pageTitle)
Definition outputlist.h:622
void writePageOutline()
Definition outputlist.h:616
void startContents()
Definition outputlist.h:618
void writePageLink(const QCString &name, bool first)
Definition outputlist.h:389
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:469
void setNestingLevel(int l) override
Definition pagedef.cpp:449
void writeDocumentation(OutputList &ol) override
Definition pagedef.cpp:238
bool hasParentPage() const override
Definition pagedef.cpp:202
bool documentedPage() const override
Definition pagedef.cpp:436
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:464
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:422
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:474
void setShowLineNo(bool) override
Definition pagedef.cpp:459
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:427
void writePageDocumentation(OutputList &ol) const override
Definition pagedef.cpp:382
void addSectionsToIndex() override
Definition pagedef.cpp:148
QCString title() const override
Definition pagedef.cpp:48
void setLocalToc(const LocalToc &tl) override
Definition pagedef.cpp:454
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:444
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:163
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, bool isSource, 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:481
#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:5321
QCString parseCommentAsText(const Definition *scope, const MemberDef *md, const QCString &doc, const QCString &fileName, int lineNr)
Definition util.cpp:5265
QCString escapeCharsInString(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:3251
QCString convertNameToFile(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:3425
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:3833
void addHtmlExtensionIfMissing(QCString &fName)
Definition util.cpp:4823
A bunch of utility functions.