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 // determine if there is a next level inside this item, but be aware of the anchor and table section references.
180 auto it_next = std::next(it);
181 bool isDir = (it_next!=sectionRefs.end()) ? ((*it_next)->type().isSection() && (*it_next)->type().level() > nextLevel) : false;
182 Doxygen::indexList->addContentsItem(isDir,title,
183 getReference(),
185 si->label(),
186 false,
187 true);
188 level = nextLevel;
189 }
190 }
191 while (level>1)
192 {
193 Doxygen::indexList->decContentsDepth();
194 level--;
195 }
196}
197
203
205{
206 bool found = name()=="citelist";
208 {
209 if (rl->listName()==name())
210 {
211 found=TRUE;
212 break;
213 }
214 }
215 if (!found) // not one of the generated related pages
216 {
219 tagFile << " <compound kind=\"page\">\n";
220 tagFile << " <name>" << name() << "</name>\n";
221 tagFile << " <title>" << convertToXML(title()) << "</title>\n";
222 tagFile << " <filename>" << fn << "</filename>\n";
223 for (const auto &subPage : m_subPages)
224 {
225 QCString sfn = subPage->getOutputFileBase();
227 tagFile << " <subpage>" << sfn << "</subpage>\n";
228 }
230 tagFile << " </compound>\n";
231 }
232}
233
235{
236 bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
237 int hierarchyLevel = -1; // Pages start at the root
238 PageDef *pd = this;
239 while (pd->hasParentPage())
240 {
241 pd = (PageDef *)pd->getOuterScope();
242 ++hierarchyLevel;
243 }
244
245 //outputList->disable(OutputType::Man);
246 QCString pageName,manPageName;
247 pageName = escapeCharsInString(name(),FALSE,TRUE);
248 manPageName = escapeCharsInString(name(),TRUE,TRUE);
249
250 //printf("PageDefImpl::writeDocumentation: %s\n",getOutputFileBase().data());
251
253 //1.{
254
256 //2.{
258 startFile(ol,getOutputFileBase(),manPageName,title(),HighlightedItem::Pages,!generateTreeView,
259 QCString() /* altSidebarName */, hierarchyLevel);
260 ol.enableAll();
262 startFile(ol,getOutputFileBase(),pageName,title(),HighlightedItem::Pages,!generateTreeView,
263 QCString() /* altSidebarName */, hierarchyLevel);
265 //2.}
266
267 if (!generateTreeView)
268 {
269 if (getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
270 {
272 if (outerScope)
273 {
274 outerScope->writeNavigationPath(ol);
275 }
276 }
277 ol.endQuickIndices();
278 }
280
281 // save old generator state and write title only to Man generator
283 //2.{
285 ol.startTitleHead(manPageName);
286 ol.endTitleHead(manPageName, manPageName);
287 if (si)
288 {
289 ol.writeString(" - ");
290
291 if (si->title() != manPageName)
292 {
293 ol.generateDoc(docFile(),getStartBodyLine(),this,nullptr,si->title(),TRUE,FALSE,
294 QCString(),TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT));
295 ol.endSection(si->label(),si->type());
296 }
297 }
299 //2.}
300
302 //2.{
305 if (this == Doxygen::mainPage.get() && !hasTitle())
306 title = theTranslator->trMainPage();
307 else
308 title = m_title;
309
310 if (!title.isEmpty() && !name().isEmpty() && si!=nullptr)
311 {
312 ol.startPageDoc(si->title());
313 //ol.startSection(si->label,si->title,si->type);
316 ol.parseText(title);
318 ol.endHeaderSection();
319
320 /*ol.generateDoc(docFile(),getStartBodyLine(),this,nullptr,si->title(),TRUE,FALSE,
321 QCString(),TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT));*/
322 }
323 else
324 ol.startPageDoc("");
326 //2.}
327
328 bool pageWithSections = hasSections();
329 ol.startContents();
330 if ((m_localToc.isHtmlEnabled() || m_localToc.isLatexEnabled() || m_localToc.isDocbookEnabled())
331 && pageWithSections)
332 {
333 writeToc(ol, m_localToc);
334 }
335
337 ol.endContents();
338 ol.endPageDoc();
339
340 if (generateTreeView && getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
341 {
343 }
344 else
345 {
346 if (generateTreeView && Config_getBool(PAGE_OUTLINE_PANEL) && pageWithSections)
347 {
350 ol.writeString("</div><!-- doc-content -->\n");
352 ol.writeString("</div><!-- container -->\n");
354 endFile(ol,true);
355 }
356 else
357 {
358 endFile(ol,false,true);
359 }
360 }
361
363 //1.}
364}
365
367{
368 ol.startTextBlock();
371 {
374 ol.writeString(" - ");
376 }
378 ol.generateDoc(
379 docFile(), // fileName
380 docLine(), // startLine
381 this, // context
382 nullptr, // memberdef
383 docStr, // docStr
384 true, // index words
385 false, // not an example
386 QCString(), // exampleName
387 false, // singleLine
388 false, // linkFromIndex
389 TRUE // markdown support
390 );
391 ol.enableAll();
393 ol.generateDoc(
394 docFile(), // fileName
395 docLine(), // startLine
396 this, // context
397 nullptr, // memberdef
398 docStr, // docStr
399 false, // index words
400 false, // not an example
401 QCString(), // exampleName
402 false, // singleLine
403 false, // linkFromIndex
404 TRUE // markdown support
405 );
407 ol.endTextBlock();
408
409 if (hasSubPages())
410 {
411 // for printed documentation we write subpages as section's of the
412 // parent page.
414 ol.disableAll();
418
419 for (const auto &subPage : m_subPages)
420 {
421 ol.writePageLink(subPage->getOutputFileBase(), FALSE);
422 }
423
425 }
426}
427
432
434{
435 bool externalPages = Config_getBool(EXTERNAL_PAGES);
436 return // not part of a group
437 !getGroupDef() &&
438 // not an externally defined page
439 (!isReference() || externalPages);
440}
441
443{
444 return // not part of a group
445 !getGroupDef() &&
446 // not an externally defined page
447 !isReference();
448}
449
451{
452 return !m_subPages.empty();
453}
454
456{
457 m_nestingLevel = l;
458}
459
461{
462 m_localToc = lt;
463}
464
466{
467 m_showLineNo = b;
468}
469
471{
472 return m_showLineNo;
473}
474
476{
477 return !m_title.isEmpty() && m_title.lower()!="notitle";
478}
479
481{
482 m_title = title;
483}
484
485// --- Cast functions
486
488{
489 if (d==nullptr) return nullptr;
490 if (d && typeid(*d)==typeid(PageDefImpl))
491 {
492 return static_cast<PageDef*>(d);
493 }
494 else
495 {
496 return nullptr;
497 }
498}
499
501{
502 if (d==nullptr) return nullptr;
503 if (d && typeid(*d)==typeid(PageDefImpl))
504 {
505 return static_cast<const PageDef*>(d);
506 }
507 else
508 {
509 return nullptr;
510 }
511}
512
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:673
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:621
void endHeaderSection()
Definition outputlist.h:468
void startHeaderSection()
Definition outputlist.h:466
void endPageDoc()
Definition outputlist.h:625
void startTextBlock(bool dense=FALSE)
Definition outputlist.h:671
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:623
void writePageOutline()
Definition outputlist.h:617
void startContents()
Definition outputlist.h:619
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:475
void setNestingLevel(int l) override
Definition pagedef.cpp:455
void writeDocumentation(OutputList &ol) override
Definition pagedef.cpp:234
bool hasParentPage() const override
Definition pagedef.cpp:198
bool documentedPage() const override
Definition pagedef.cpp:442
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:204
bool showLineNo() const override
Definition pagedef.cpp:470
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:428
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:480
void setShowLineNo(bool) override
Definition pagedef.cpp:465
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:433
void writePageDocumentation(OutputList &ol) const override
Definition pagedef.cpp:366
void addSectionsToIndex() override
Definition pagedef.cpp:148
QCString title() const override
Definition pagedef.cpp:48
void setLocalToc(const LocalToc &tl) override
Definition pagedef.cpp:460
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:450
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:175
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:487
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34
CodeSymbolType
Definition types.h:481
QCString parseCommentAsText(const Definition *scope, const MemberDef *md, const QCString &doc, const QCString &fileName, int lineNr)
Definition util.cpp:5879
QCString escapeCharsInString(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:3846
bool found
Definition util.cpp:984
QCString convertNameToFile(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:4020
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:4428
void addHtmlExtensionIfMissing(QCString &fName)
Definition util.cpp:5415
A bunch of utility functions.