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 final : public DefinitionMixin<PageDef>
32{
33 public:
34 PageDefImpl(const DString &f,int l,const DString &n,const DString &d,const DString &t);
35 ~PageDefImpl() override;
37
38 void setFileName(const DString &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 DString getOutputFileBase() const override;
46 DString anchor() const override { return DString(); }
47 void findSectionsInDocumentation() override;
48 DString title() const override { return m_title; }
49 DString titleAsText() const override;
50 const GroupDef * getGroupDef() const override;
51 const PageLinkedRefMap &getSubPages() const override { return m_subPages; }
52 void addInnerCompound(Definition *d) override;
53 bool visibleInIndex() const override;
54 bool documentedPage() const override;
55 bool hasSubPages() const override;
56 bool hasParentPage() const override;
57 bool hasTitle() const override;
58 LocalToc localToc() const override { return m_localToc; }
59 void setPageScope(Definition *d) override { m_pageScope = d; }
60 Definition *getPageScope() const override { return m_pageScope; }
61 DString displayName(bool=true) const override { return hasTitle() ? m_title : DefinitionMixin::name(); }
62 bool showLineNo() const override;
63 void setTitle(const DString &title) override;
64 void writeDocumentation(OutputList &ol) override;
65 void writeTagFile(TextStream &) override;
66 void setNestingLevel(int l) override;
67 void writePageDocumentation(OutputList &ol) const override;
68 void addSectionsToIndex() override;
69 void writePageNavigation(OutputList &ol) const override;
70 void addListReferences() override;
71 void addRequirementReferences() override;
72
73 private:
77 PageLinkedRefMap m_subPages; // list of pages in the group
82};
83
84std::unique_ptr<PageDef> createPageDef(const DString &f,int l,const DString &n,const DString &d,const DString &t)
85{
86 return std::make_unique<PageDefImpl>(f,l,n,d,t);
87}
88
89//------------------------------------------------------------------------------------------
90
92 const DString &d,const DString &t)
93 : DefinitionMixin(f,l,1,n)
94{
95 setDocumentation(d,f,l);
96 m_pageScope = nullptr;
98 m_fileName = ::convertNameToFile(n,false,true);
99 m_showLineNo = false;
100 setTitle(t);
101}
102
106
113
115{
116 return !partOfGroups().empty() ? partOfGroups().front() : nullptr;
117}
118
120{
121 if (getGroupDef())
122 return getGroupDef()->getOutputFileBase();
123 else
124 return m_fileName;
125}
126
131
133{
135 {
136 PageDef *pd = toPageDef(def);
137 if (pd)
138 {
139 m_subPages.add(pd->name(),pd);
140 pd->setOuterScope(this);
141 if (this==Doxygen::mainPage.get())
142 {
144 }
145 else
146 {
148 }
149 }
150 }
151}
152
154{
155 const SectionRefs &sectionRefs = getSectionRefs();
156 if (sectionRefs.empty()) return;
157 //printf("PageDefImpl::addSectionsToIndex()\n");
158 int level=1;
159 for (auto it = sectionRefs.begin(); it!=sectionRefs.end(); ++it)
160 {
161 const SectionInfo *si = *it;
162 SectionType type = si->type();
163 if (type.isSection())
164 {
165 //printf(" level=%d title=%s\n",level,qPrint(si->title));
166 int nextLevel = type.level();
167 if (nextLevel>level)
168 {
169 for (int i=level;i<nextLevel;i++)
170 {
172 }
173 }
174 else if (nextLevel<level)
175 {
176 for (int i=nextLevel;i<level;i++)
177 {
179 }
180 }
181 DString title = si->title();
182 if (title.empty()) title = si->label();
183 title = parseCommentAsText(this,nullptr,title,si->fileName(),si->lineNr());
184 DString titleAsHtml = parseCommentAsHtml(this,nullptr,si->title(),si->fileName(),si->lineNr());
185 // determine if there is a next level inside this item, but be aware of the anchor and table section references.
186 auto it_next = std::next(it);
187 bool isDir = (it_next!=sectionRefs.end()) ? ((*it_next)->type().isSection() && (*it_next)->type().level() > nextLevel) : false;
188 Doxygen::indexList->addContentsItem(isDir, // isDir
189 title, // name
190 getReference(), // ref
191 getOutputFileBase(), // file
192 si->label(), // anchor
193 false, // separateIndex
194 true, // addToNavIndex
195 nullptr, // def
196 titleAsHtml); // nameAsHtml
197 level = nextLevel;
198 }
199 }
200 while (level>1)
201 {
203 level--;
204 }
205}
206
208{
210 if (getGroupDef())
211 {
213 }
215 theTranslator->trPage(true,true),
216 name,title(),DString(),nullptr);
217}
218
223
229
231{
232 bool found = name()=="citelist" || name()=="requirements";
234 {
235 if (rl->listName()==name())
236 {
237 found=true;
238 break;
239 }
240 }
241 if (!found) // not one of the generated related pages
242 {
245 tagFile << " <compound kind=\"page\">\n";
246 tagFile << " <name>" << name() << "</name>\n";
247 tagFile << " <title>" << convertToXML(title()) << "</title>\n";
248 tagFile << " <filename>" << fn << "</filename>\n";
249 for (const auto &subPage : m_subPages)
250 {
251 DString sfn = subPage->getOutputFileBase();
253 tagFile << " <subpage>" << sfn << "</subpage>\n";
254 }
256 tagFile << " </compound>\n";
257 }
258}
259
261{
262 bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
263 int hierarchyLevel = -1; // Pages start at the root
264 PageDef *pd = this;
265 while (pd && pd->hasParentPage())
266 {
267 pd = dynamic_cast<PageDef *>(pd->getOuterScope());
268 ++hierarchyLevel;
269 }
270
271 //outputList->disable(OutputType::Man);
272 DString pageName,manPageName;
273 pageName = escapeCharsInString(name(),false,true);
274 manPageName = escapeCharsInString(name(),true,true);
275
276 //printf("PageDefImpl::writeDocumentation: %s\n",getOutputFileBase().data());
277
279 //1.{
280
282 //2.{
284 startFile(ol,getOutputFileBase(),false,manPageName,titleAsText(),HighlightedItem::Pages,!generateTreeView,
285 DString() /* altSidebarName */, hierarchyLevel);
286 ol.enableAll();
288 startFile(ol,getOutputFileBase(),false,pageName,titleAsText(),HighlightedItem::Pages,!generateTreeView,
289 DString() /* altSidebarName */, hierarchyLevel);
291 //2.}
292
293 if (!generateTreeView)
294 {
295 if (getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
296 {
298 if (outerScope)
299 {
300 outerScope->writeNavigationPath(ol);
301 }
302 }
303 ol.endQuickIndices();
304 }
306
307 // save old generator state and write title only to Man generator
309 //2.{
311 ol.startTitleHead(manPageName);
312 ol.endTitleHead(manPageName, manPageName);
313 if (si)
314 {
315 ol.writeString(" - ");
316
317 if (si->title() != manPageName)
318 {
319 ol.generateDoc(docFile(),
321 this,
322 nullptr,
323 si->title(),
324 DocOptions()
325 .setSingleLine(true)
326 .setAutolinkSupport(false));
327 ol.endSection(si->label(),si->type());
328 }
329 }
331 //2.}
332
334 //2.{
337 if (this == Doxygen::mainPage.get() && !hasTitle())
339 else
340 title = m_title;
341
342 if (!title.empty() && !name().empty() && si!=nullptr)
343 {
344 ol.startPageDoc(si->title());
347 ol.generateDoc(docFile(),
349 this,
350 nullptr,
351 title,
352 DocOptions()
353 .setIndexWords(true)
354 .setSingleLine(true)
355 .setAutolinkSupport(false));
357 ol.endHeaderSection();
358 }
359 else
360 {
361 ol.startPageDoc("");
362 }
364 //2.}
365
366 bool pageWithSections = hasSections();
367 ol.startContents();
369 && pageWithSections)
370 {
371 writeToc(ol, m_localToc);
372 }
373
375 ol.endContents();
376 ol.endPageDoc();
377
378 if (generateTreeView && getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
379 {
381 }
382 else
383 {
384 if (generateTreeView && Config_getBool(PAGE_OUTLINE_PANEL) && pageWithSections)
385 {
388 ol.writeString("</div><!-- doc-content -->\n");
390 ol.writeString("</div><!-- container -->\n");
392 endFile(ol,true);
393 }
394 else
395 {
396 endFile(ol,false,true);
397 }
398 }
399
401 //1.}
402}
403
405{
406 ol.startTextBlock();
409 {
412 ol.writeString(" - ");
414 }
415 ol.generateDoc(
416 docFile(), // fileName
417 docLine(), // startLine
418 this, // context
419 nullptr, // memberdef
420 docStr, // docStr
421 DocOptions()
422 .setIndexWords(true));
423 ol.endTextBlock();
424
425 if (hasSubPages())
426 {
427 // for printed documentation we write subpages as section's of the
428 // parent page.
430 ol.disableAll();
434
435 for (const auto &subPage : m_subPages)
436 {
437 ol.writePageLink(subPage->getOutputFileBase(), false);
438 }
439
441 }
442
444}
445
450
452{
453 bool externalPages = Config_getBool(EXTERNAL_PAGES);
454 return // not part of a group
455 !getGroupDef() &&
456 // not an externally defined page
457 (!isReference() || externalPages);
458}
459
461{
462 return // not part of a group
463 !getGroupDef() &&
464 // not an externally defined page
465 !isReference();
466}
467
469{
470 return !m_subPages.empty();
471}
472
474{
475 m_nestingLevel = l;
476}
477
479{
480 m_localToc = lt;
481}
482
484{
485 m_showLineNo = b;
486}
487
489{
490 return m_showLineNo;
491}
492
494{
495 return !m_title.empty() && m_title.lower()!="notitle";
496}
497
499{
500 if (!title.empty())
501 {
502 m_title = title;
504 }
505 else
506 {
507 m_title = name();
509 }
510}
511
513{
514 return m_titleAsText;
515}
516
517// --- Cast functions
518
520{
521 return (d && typeid(*d) == typeid(PageDefImpl)) ? static_cast<PageDef*>(d) : nullptr;
522}
523
525{
526 return (d && typeid(*d) == typeid(PageDefImpl)) ? static_cast<const PageDef*>(d) : nullptr;
527}
528
A String class for use with Doxygen wrapping std::string and adding some additional functionality off...
Definition dstring.h:89
DString()=default
DString lower() const
Definition dstring.h:331
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:153
The common base class of all entity definitions found in the sources.
Definition definition.h:77
virtual DefType definitionType() const =0
virtual const DString & name() const =0
virtual Definition * getOuterScope() const =0
virtual DString getOutputFileBase() const =0
friend DefinitionMutable * toDefinitionMutable(Definition *)
bool isReference() const override
DString docFile() const override
bool hasBriefDescription() const override
bool hasRequirementRefs() const override
DString briefDescription(bool abbreviate=false) const override
const DString & name() const override
DString getReference() const override
void writeRequirementRefs(OutputList &ol) const override
const RefItemVector & xrefListItems() const override
Definition * getOuterScope() const override
void setDocumentation(const DString &doc, const DString &docFile, int docLine, bool stripWhiteSpace=true) override
DString documentation() const override
const GroupList & partOfGroups() const override
DefinitionMixin(const DString &defFileName, int defLine, size_t defColumn, const DString &name, const char *b=nullptr, const char *d=nullptr, bool isSymbol=true)
DString inbodyDocumentation() const override
int getStartBodyLine() const override
void writeToc(OutputList &ol, const LocalToc &lt) const override
bool hasSections() const override
int docLine() const override
const SectionRefs & getSectionRefs() 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:121
static IndexList * indexList
Definition doxygen.h:132
A model of a group of symbols.
Definition groupdef.h:52
void decContentsDepth()
Definition indexlist.h:109
void addContentsItem(bool isDir, const DString &name, const DString &ref, const DString &file, const DString &anchor, bool separateIndex=false, bool addToNavIndex=false, const Definition *def=nullptr, const DString &nameAsHtml=DString())
Definition indexlist.h:112
void incContentsDepth()
Definition indexlist.h:106
std::unique_ptr< RefList > Ptr
Definition linkedmap.h:38
const T * find(const std::string &key) const
Definition linkedmap.h:47
bool add(const char *k, T *obj)
Definition linkedmap.h:284
bool empty() const
Definition linkedmap.h:374
constexpr bool isDocbookEnabled() const noexcept
Definition types.h:657
constexpr bool isLatexEnabled() const noexcept
Definition types.h:655
constexpr bool isHtmlEnabled() const noexcept
Definition types.h:654
Class representing a list of output generators that are written to in parallel.
Definition outputlist.h:315
void startTitleHead(const DString &fileName)
Definition outputlist.h:403
void endTitleHead(const DString &fileName, const DString &name)
Definition outputlist.h:405
void disable(OutputType o)
void writePageLink(const DString &name, bool first)
Definition outputlist.h:389
void enable(OutputType o)
void endContents()
Definition outputlist.h:620
void endHeaderSection()
Definition outputlist.h:467
void endTextBlock(bool paraBreak=false)
Definition outputlist.h:672
void startHeaderSection()
Definition outputlist.h:465
void endPageDoc()
Definition outputlist.h:624
void writeString(const DString &text)
Definition outputlist.h:411
void endSection(const DString &lab, SectionType t)
Definition outputlist.h:588
void disableAll()
void pushGeneratorState()
void disableAllBut(OutputType o)
void startTextBlock(bool dense=false)
Definition outputlist.h:670
void popGeneratorState()
void startPageDoc(const DString &pageTitle)
Definition outputlist.h:622
void endQuickIndices()
Definition outputlist.h:604
void writePageOutline()
Definition outputlist.h:616
void generateDoc(const DString &fileName, int startLine, const Definition *ctx, const MemberDef *md, const DString &docStr, const DocOptions &options)
void startContents()
Definition outputlist.h:618
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:493
void setNestingLevel(int l) override
Definition pagedef.cpp:473
void writeDocumentation(OutputList &ol) override
Definition pagedef.cpp:260
bool hasParentPage() const override
Definition pagedef.cpp:224
DString m_fileName
Definition pagedef.cpp:74
bool documentedPage() const override
Definition pagedef.cpp:460
LocalToc localToc() const override
Definition pagedef.cpp:58
DString getOutputFileBase() const override
Definition pagedef.cpp:119
void addListReferences() override
Definition pagedef.cpp:207
DString m_title
Definition pagedef.cpp:75
void addInnerCompound(Definition *d) override
Definition pagedef.cpp:132
void setFileName(const DString &name) override
Definition pagedef.cpp:127
DString displayName(bool=true) const override
Definition pagedef.cpp:61
~PageDefImpl() override
Definition pagedef.cpp:103
bool m_showLineNo
Definition pagedef.cpp:81
Definition * m_pageScope
Definition pagedef.cpp:78
LocalToc m_localToc
Definition pagedef.cpp:80
void addRequirementReferences() override
Definition pagedef.cpp:219
DString title() const override
Definition pagedef.cpp:48
void writeTagFile(TextStream &) override
Definition pagedef.cpp:230
void setTitle(const DString &title) override
Definition pagedef.cpp:498
PageDefImpl(const DString &f, int l, const DString &n, const DString &d, const DString &t)
Definition pagedef.cpp:91
bool showLineNo() const override
Definition pagedef.cpp:488
void findSectionsInDocumentation() override
Definition pagedef.cpp:107
void writePageNavigation(OutputList &ol) const override
Definition pagedef.cpp:446
DefType definitionType() const override
Definition pagedef.cpp:41
bool isLinkable() const override
Definition pagedef.cpp:44
bool isLinkableInProject() const override
Definition pagedef.cpp:43
void setShowLineNo(bool) override
Definition pagedef.cpp:483
const PageLinkedRefMap & getSubPages() const override
Definition pagedef.cpp:51
int m_nestingLevel
Definition pagedef.cpp:79
DString m_titleAsText
Definition pagedef.cpp:76
CodeSymbolType codeSymbolType() const override
Definition pagedef.cpp:42
DString titleAsText() const override
Definition pagedef.cpp:512
const GroupDef * getGroupDef() const override
Definition pagedef.cpp:114
bool visibleInIndex() const override
Definition pagedef.cpp:451
void writePageDocumentation(OutputList &ol) const override
Definition pagedef.cpp:404
void addSectionsToIndex() override
Definition pagedef.cpp:153
DString anchor() const override
Definition pagedef.cpp:46
void setLocalToc(const LocalToc &tl) override
Definition pagedef.cpp:478
void setPageScope(Definition *d) override
Definition pagedef.cpp:59
PageLinkedRefMap m_subPages
Definition pagedef.cpp:77
bool hasSubPages() const override
Definition pagedef.cpp:468
Definition * getPageScope() const override
Definition pagedef.cpp:60
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
DString fileName() const
Definition section.h:74
int lineNr() const
Definition section.h:73
SectionType type() const
Definition section.h:71
DString title() const
Definition section.h:70
DString label() const
Definition section.h:69
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
virtual DString trPage(bool first_capital, bool singular)=0
virtual DString 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 DString &input, const Definition *d, const DString &fileName)
void endFileWithNavPath(OutputList &ol, const DefinitionMutable *d, bool showPageNavigation)
Definition index.cpp:450
void endFile(OutputList &ol, bool skipNavIndex, bool skipEndContents, const DString &navPath)
Definition index.cpp:429
void startFile(OutputList &ol, const DString &name, bool isSource, const DString &manName, const DString &title, HighlightedItem hli, bool additionalIndices, const DString &altSidebarName, int hierarchyLevel, const DString &allMembersFile)
Definition index.cpp:403
Translator * theTranslator
Definition language.cpp:71
PageDef * toPageDef(Definition *d)
Definition pagedef.cpp:519
std::unique_ptr< PageDef > createPageDef(const DString &f, int l, const DString &n, const DString &d, const DString &t)
Definition pagedef.cpp:84
Helper class to pass options when calling OutputList::generateDoc().
Definition docoptions.h:24
CodeSymbolType
Definition types.h:481
DString parseCommentAsText(const Definition *scope, const MemberDef *md, const DString &doc, const DString &fileName, int lineNr)
Definition util.cpp:4693
void addRefItem(const RefItemVector &sli, const DString &key, const DString &prefix, const DString &name, const DString &title, const DString &args, const Definition *scope)
Definition util.cpp:4163
DString convertNameToFile(const DString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:2930
DString parseCommentAsHtml(const Definition *scope, const MemberDef *member, const DString &doc, const DString &fileName, int lineNr)
Definition util.cpp:4749
void addHtmlExtensionIfMissing(DString &fName)
Definition util.cpp:4260
DString convertToXML(const DString &s, bool keepEntities, const bool citeEntry)
Definition util.cpp:3299
DString escapeCharsInString(const DString &name, bool allowDots, bool allowUnderscore)
Definition util.cpp:2755
A bunch of utility functions.