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 void addListReferences() override;
70 void addRequirementReferences() override;
71
72 private:
75 PageLinkedRefMap m_subPages; // list of pages in the group
80};
81
82std::unique_ptr<PageDef> createPageDef(const QCString &f,int l,const QCString &n,const QCString &d,const QCString &t)
83{
84 return std::make_unique<PageDefImpl>(f,l,n,d,t);
85}
86
87//------------------------------------------------------------------------------------------
88
90 const QCString &d,const QCString &t)
91 : DefinitionMixin(f,l,1,n), m_title(!t.isEmpty() ? t : n)
92{
93 setDocumentation(d,f,l);
94 m_pageScope = nullptr;
98}
99
103
110
112{
113 return !partOfGroups().empty() ? partOfGroups().front() : nullptr;
114}
115
117{
118 if (getGroupDef())
119 return getGroupDef()->getOutputFileBase();
120 else
121 return m_fileName;
122}
123
128
130{
132 {
133 PageDef *pd = toPageDef(def);
134 if (pd)
135 {
136 m_subPages.add(pd->name(),pd);
137 pd->setOuterScope(this);
138 if (this==Doxygen::mainPage.get())
139 {
141 }
142 else
143 {
145 }
146 }
147 }
148}
149
151{
152 const SectionRefs &sectionRefs = getSectionRefs();
153 if (sectionRefs.empty()) return;
154 //printf("PageDefImpl::addSectionsToIndex()\n");
155 int level=1;
156 for (auto it = sectionRefs.begin(); it!=sectionRefs.end(); ++it)
157 {
158 const SectionInfo *si = *it;
159 SectionType type = si->type();
160 if (type.isSection())
161 {
162 //printf(" level=%d title=%s\n",level,qPrint(si->title));
163 int nextLevel = type.level();
164 if (nextLevel>level)
165 {
166 for (int i=level;i<nextLevel;i++)
167 {
168 Doxygen::indexList->incContentsDepth();
169 }
170 }
171 else if (nextLevel<level)
172 {
173 for (int i=nextLevel;i<level;i++)
174 {
175 Doxygen::indexList->decContentsDepth();
176 }
177 }
178 QCString title = si->title();
179 if (title.isEmpty()) title = si->label();
180 title = parseCommentAsText(this,nullptr,title,si->fileName(),si->lineNr());
181 QCString titleAsHtml = parseCommentAsHtml(this,nullptr,si->title(),si->fileName(),si->lineNr());
182 // determine if there is a next level inside this item, but be aware of the anchor and table section references.
183 auto it_next = std::next(it);
184 bool isDir = (it_next!=sectionRefs.end()) ? ((*it_next)->type().isSection() && (*it_next)->type().level() > nextLevel) : false;
185 Doxygen::indexList->addContentsItem(isDir, // isDir
186 title, // name
187 getReference(), // ref
188 getOutputFileBase(), // file
189 si->label(), // anchor
190 false, // separateIndex
191 true, // addToNavIndex
192 nullptr, // def
193 titleAsHtml); // nameAsHtml
194 level = nextLevel;
195 }
196 }
197 while (level>1)
198 {
199 Doxygen::indexList->decContentsDepth();
200 level--;
201 }
202}
203
205{
207 if (getGroupDef())
208 {
210 }
212 theTranslator->trPage(TRUE,TRUE),
213 name,title(),QCString(),nullptr);
214}
215
220
226
228{
229 bool found = name()=="citelist" || name()=="requirements";
231 {
232 if (rl->listName()==name())
233 {
234 found=TRUE;
235 break;
236 }
237 }
238 if (!found) // not one of the generated related pages
239 {
242 tagFile << " <compound kind=\"page\">\n";
243 tagFile << " <name>" << name() << "</name>\n";
244 tagFile << " <title>" << convertToXML(title()) << "</title>\n";
245 tagFile << " <filename>" << fn << "</filename>\n";
246 for (const auto &subPage : m_subPages)
247 {
248 QCString sfn = subPage->getOutputFileBase();
250 tagFile << " <subpage>" << sfn << "</subpage>\n";
251 }
253 tagFile << " </compound>\n";
254 }
255}
256
258{
259 bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
260 int hierarchyLevel = -1; // Pages start at the root
261 PageDef *pd = this;
262 while (pd && pd->hasParentPage())
263 {
264 pd = dynamic_cast<PageDef *>(pd->getOuterScope());
265 ++hierarchyLevel;
266 }
267
268 //outputList->disable(OutputType::Man);
269 QCString pageName,manPageName;
270 pageName = escapeCharsInString(name(),FALSE,TRUE);
271 manPageName = escapeCharsInString(name(),TRUE,TRUE);
272
273 //printf("PageDefImpl::writeDocumentation: %s\n",getOutputFileBase().data());
274
276 //1.{
277
279 //2.{
281 startFile(ol,getOutputFileBase(),false,manPageName,title(),HighlightedItem::Pages,!generateTreeView,
282 QCString() /* altSidebarName */, hierarchyLevel);
283 ol.enableAll();
285 startFile(ol,getOutputFileBase(),false,pageName,title(),HighlightedItem::Pages,!generateTreeView,
286 QCString() /* altSidebarName */, hierarchyLevel);
288 //2.}
289
290 if (!generateTreeView)
291 {
292 if (getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
293 {
295 if (outerScope)
296 {
297 outerScope->writeNavigationPath(ol);
298 }
299 }
300 ol.endQuickIndices();
301 }
303
304 // save old generator state and write title only to Man generator
306 //2.{
308 ol.startTitleHead(manPageName);
309 ol.endTitleHead(manPageName, manPageName);
310 if (si)
311 {
312 ol.writeString(" - ");
313
314 if (si->title() != manPageName)
315 {
316 ol.generateDoc(docFile(),
318 this,
319 nullptr,
320 si->title(),
321 DocOptions()
322 .setSingleLine(true)
323 .setAutolinkSupport(false));
324 ol.endSection(si->label(),si->type());
325 }
326 }
328 //2.}
329
331 //2.{
334 if (this == Doxygen::mainPage.get() && !hasTitle())
335 title = theTranslator->trMainPage();
336 else
337 title = m_title;
338
339 if (!title.isEmpty() && !name().isEmpty() && si!=nullptr)
340 {
341 ol.startPageDoc(si->title());
344 ol.generateDoc(docFile(),
346 this,
347 nullptr,
348 title,
349 DocOptions()
350 .setIndexWords(true)
351 .setSingleLine(true)
352 .setAutolinkSupport(false));
354 ol.endHeaderSection();
355 }
356 else
357 {
358 ol.startPageDoc("");
359 }
361 //2.}
362
363 bool pageWithSections = hasSections();
364 ol.startContents();
365 if ((m_localToc.isHtmlEnabled() || m_localToc.isLatexEnabled() || m_localToc.isDocbookEnabled())
366 && pageWithSections)
367 {
368 writeToc(ol, m_localToc);
369 }
370
372 ol.endContents();
373 ol.endPageDoc();
374
375 if (generateTreeView && getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
376 {
378 }
379 else
380 {
381 if (generateTreeView && Config_getBool(PAGE_OUTLINE_PANEL) && pageWithSections)
382 {
385 ol.writeString("</div><!-- doc-content -->\n");
387 ol.writeString("</div><!-- container -->\n");
389 endFile(ol,true);
390 }
391 else
392 {
393 endFile(ol,false,true);
394 }
395 }
396
398 //1.}
399}
400
402{
403 ol.startTextBlock();
406 {
409 ol.writeString(" - ");
411 }
412 ol.generateDoc(
413 docFile(), // fileName
414 docLine(), // startLine
415 this, // context
416 nullptr, // memberdef
417 docStr, // docStr
418 DocOptions()
419 .setIndexWords(true));
420 ol.endTextBlock();
421
422 if (hasSubPages())
423 {
424 // for printed documentation we write subpages as section's of the
425 // parent page.
427 ol.disableAll();
431
432 for (const auto &subPage : m_subPages)
433 {
434 ol.writePageLink(subPage->getOutputFileBase(), FALSE);
435 }
436
438 }
439
441}
442
447
449{
450 bool externalPages = Config_getBool(EXTERNAL_PAGES);
451 return // not part of a group
452 !getGroupDef() &&
453 // not an externally defined page
454 (!isReference() || externalPages);
455}
456
458{
459 return // not part of a group
460 !getGroupDef() &&
461 // not an externally defined page
462 !isReference();
463}
464
466{
467 return !m_subPages.empty();
468}
469
471{
472 m_nestingLevel = l;
473}
474
476{
477 m_localToc = lt;
478}
479
481{
482 m_showLineNo = b;
483}
484
486{
487 return m_showLineNo;
488}
489
491{
492 return !m_title.isEmpty() && m_title.lower()!="notitle";
493}
494
496{
497 m_title = title;
498}
499
500// --- Cast functions
501
503{
504 return (d && typeid(*d) == typeid(PageDefImpl)) ? static_cast<PageDef*>(d) : nullptr;
505}
506
508{
509 return (d && typeid(*d) == typeid(PageDefImpl)) ? static_cast<const PageDef*>(d) : nullptr;
510}
511
The common base class of all entity definitions found in the sources.
Definition definition.h:77
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
bool hasRequirementRefs() const override
void setDocumentation(const QCString &doc, const QCString &docFile, int docLine, bool stripWhiteSpace=TRUE) override
void writeRequirementRefs(OutputList &ol) const override
const RefItemVector & xrefListItems() const 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:100
static NamespaceDefMutable * globalScope
Definition doxygen.h:120
static IndexList * indexList
Definition doxygen.h:133
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:490
void setNestingLevel(int l) override
Definition pagedef.cpp:470
void writeDocumentation(OutputList &ol) override
Definition pagedef.cpp:257
bool hasParentPage() const override
Definition pagedef.cpp:221
bool documentedPage() const override
Definition pagedef.cpp:457
LocalToc localToc() const override
Definition pagedef.cpp:57
void addListReferences() override
Definition pagedef.cpp:204
PageDefImpl(const QCString &f, int l, const QCString &n, const QCString &d, const QCString &t)
Definition pagedef.cpp:89
void addInnerCompound(Definition *d) override
Definition pagedef.cpp:129
~PageDefImpl() override
Definition pagedef.cpp:100
bool m_showLineNo
Definition pagedef.cpp:79
Definition * m_pageScope
Definition pagedef.cpp:76
LocalToc m_localToc
Definition pagedef.cpp:78
void addRequirementReferences() override
Definition pagedef.cpp:216
QCString m_title
Definition pagedef.cpp:74
void writeTagFile(TextStream &) override
Definition pagedef.cpp:227
bool showLineNo() const override
Definition pagedef.cpp:485
void setFileName(const QCString &name) override
Definition pagedef.cpp:124
void findSectionsInDocumentation() override
Definition pagedef.cpp:104
void writePageNavigation(OutputList &ol) const override
Definition pagedef.cpp:443
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:495
void setShowLineNo(bool) override
Definition pagedef.cpp:480
QCString getOutputFileBase() const override
Definition pagedef.cpp:116
const PageLinkedRefMap & getSubPages() const override
Definition pagedef.cpp:50
int m_nestingLevel
Definition pagedef.cpp:77
CodeSymbolType codeSymbolType() const override
Definition pagedef.cpp:42
const GroupDef * getGroupDef() const override
Definition pagedef.cpp:111
bool visibleInIndex() const override
Definition pagedef.cpp:448
void writePageDocumentation(OutputList &ol) const override
Definition pagedef.cpp:401
void addSectionsToIndex() override
Definition pagedef.cpp:150
QCString title() const override
Definition pagedef.cpp:48
void setLocalToc(const LocalToc &tl) override
Definition pagedef.cpp:475
QCString m_fileName
Definition pagedef.cpp:73
void setPageScope(Definition *d) override
Definition pagedef.cpp:58
QCString anchor() const override
Definition pagedef.cpp:46
PageLinkedRefMap m_subPages
Definition pagedef.cpp:75
bool hasSubPages() const override
Definition pagedef.cpp:465
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
static RequirementManager & instance()
void addRequirementRefsForSymbol(const Definition *symbol)
class that provide information about a section.
Definition section.h:58
QCString label() const
Definition section.h:69
QCString fileName() const
Definition section.h:74
int lineNr() const
Definition section.h:73
QCString title() const
Definition section.h:70
SectionType type() const
Definition section.h:71
static SectionManager & instance()
returns a reference to the singleton
Definition section.h:179
class that represents a list of constant references to sections.
Definition section.h:103
bool empty() const
Definition section.h:125
const_iterator end() const
Definition section.h:124
const_iterator begin() const
Definition section.h:123
constexpr bool isSection() const
Definition section.h:47
constexpr int level() const
Definition section.h:46
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:82
PageDef * toPageDef(Definition *d)
Definition pagedef.cpp:502
#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:5405
QCString parseCommentAsText(const Definition *scope, const MemberDef *md, const QCString &doc, const QCString &fileName, int lineNr)
Definition util.cpp:5349
QCString escapeCharsInString(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:3310
void addRefItem(const RefItemVector &sli, const QCString &key, const QCString &prefix, const QCString &name, const QCString &title, const QCString &args, const Definition *scope)
Definition util.cpp:4805
QCString convertNameToFile(const QCString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:3485
QCString convertToXML(const QCString &s, bool keepEntities)
Definition util.cpp:3893
void addHtmlExtensionIfMissing(QCString &fName)
Definition util.cpp:4902
A bunch of utility functions.