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 <qregexp.h>
17 
18 #include "pagedef.h"
19 #include "groupdef.h"
20 #include "docparser.h"
21 #include "config.h"
22 #include "util.h"
23 #include "outputlist.h"
24 #include "doxygen.h"
25 #include "language.h"
26 #include "namespacedef.h"
27 #include "reflist.h"
28 
29 PageDef::PageDef(const char *f,int l,const char *n,
30  const char *d,const char *t)
31  : Definition(f,l,1,n), m_title(t)
32 {
33  setDocumentation(d,f,l);
34  m_subPageDict = new PageSDict(7);
35  m_pageScope = 0;
36  m_nestingLevel = 0;
37  static bool shortNames = Config_getBool("SHORT_NAMES");
38  m_fileName = shortNames ? convertNameToFile(n) : QCString(n);
39  m_showToc = FALSE;
40 }
41 
43 {
44  delete m_subPageDict;
45 }
46 
48 {
50 }
51 
53 {
54  GroupList *groups = partOfGroups();
55  return groups!=0 ? groups->getFirst() : 0;
56 }
57 
59 {
60  if (getGroupDef())
61  return getGroupDef()->getOutputFileBase();
62  else
63  return m_fileName;
64 }
65 
66 void PageDef::setFileName(const char *name)
67 {
68  m_fileName = name;
69 }
70 
72 {
74  {
75  PageDef *pd = (PageDef*)def;
76  m_subPageDict->append(pd->name(),pd);
77  def->setOuterScope(this);
78  if (this==Doxygen::mainPage)
79  {
81  }
82  else
83  {
85  }
86  }
87 }
88 
90 {
91  return getOuterScope() &&
93 }
94 
96 {
97  bool found = name()=="citelist";
98  QDictIterator<RefList> rli(*Doxygen::xrefLists);
99  RefList *rl;
100  for (rli.toFirst();(rl=rli.current()) && !found;++rli)
101  {
102  if (rl->listName()==name())
103  {
104  found=TRUE;
105  break;
106  }
107  }
108  if (!found) // not one of the generated related pages
109  {
110  tagFile << " <compound kind=\"page\">" << endl;
111  tagFile << " <name>" << name() << "</name>" << endl;
112  tagFile << " <title>" << convertToXML(title()) << "</title>" << endl;
113  tagFile << " <filename>" << convertToXML(getOutputFileBase()) << "</filename>" << endl;
114  writeDocAnchorsToTagFile(tagFile);
115  tagFile << " </compound>" << endl;
116  }
117 }
118 
120 {
121  static bool generateTreeView = Config_getBool("GENERATE_TREEVIEW");
122 
123  //outputList->disable(OutputGenerator::Man);
124  QCString pageName,manPageName;
125  pageName = escapeCharsInString(name(),FALSE,TRUE);
126  manPageName = escapeCharsInString(name(),TRUE,TRUE);
127 
128  //printf("PageDef::writeDocumentation: %s\n",getOutputFileBase().data());
129 
130  ol.pushGeneratorState();
131  //1.{
132 
133  if (m_nestingLevel>0
134  //&& // a sub page
135  //(Doxygen::mainPage==0 || getOuterScope()!=Doxygen::mainPage) // and not a subpage of the mainpage
136  )
137  {
138  // do not generate sub page output for RTF and LaTeX, as these are
139  // part of their parent page
140  ol.disableAll();
143  }
144 
145  ol.pushGeneratorState();
146  //2.{
148  startFile(ol,getOutputFileBase(),manPageName,title(),HLI_Pages,!generateTreeView);
149  ol.enableAll();
151  startFile(ol,getOutputFileBase(),pageName,title(),HLI_Pages,!generateTreeView);
152  ol.popGeneratorState();
153  //2.}
154 
155  if (!generateTreeView)
156  {
157  if (getOuterScope()!=Doxygen::globalScope && !Config_getBool("DISABLE_INDEX"))
158  {
160  }
161  ol.endQuickIndices();
162  }
164 
165  // save old generator state and write title only to Man generator
166  ol.pushGeneratorState();
167  //2.{
169  ol.startTitleHead(manPageName);
170  ol.endTitleHead(manPageName, manPageName);
171  if (si)
172  {
173  ol.generateDoc(docFile(),docLine(),this,0,si->title,TRUE,FALSE,0,TRUE,FALSE);
174  ol.endSection(si->label,si->type);
175  }
176  ol.popGeneratorState();
177  //2.}
178 
179  // for Latex the section is already generated as a chapter in the index!
180  ol.pushGeneratorState();
181  //2.{
185  if (!title().isEmpty() && !name().isEmpty() && si!=0)
186  {
187  //ol.startSection(si->label,si->title,si->type);
188  startTitle(ol,getOutputFileBase(),this);
189  ol.generateDoc(docFile(),docLine(),this,0,si->title,TRUE,FALSE,0,TRUE,FALSE);
190  //stringToSearchIndex(getOutputFileBase(),
191  // theTranslator->trPage(TRUE,TRUE)+" "+si->title,
192  // si->title);
193  //ol.endSection(si->label,si->type);
195  }
196  ol.startContents();
197  ol.popGeneratorState();
198  //2.}
199 
200  if (m_showToc && hasSections())
201  {
202  writeToc(ol);
203  }
204 
206 
207  if (generateTreeView && getOuterScope()!=Doxygen::globalScope && !Config_getBool("DISABLE_INDEX"))
208  {
209  ol.endContents();
211  }
212  else
213  {
214  endFile(ol);
215  }
216 
217  ol.popGeneratorState();
218  //1.}
219 
221 }
222 
224 {
225 
226  bool markdownEnabled = Doxygen::markdownSupport;
228  {
230  }
231 
232  ol.startTextBlock();
233  ol.generateDoc(
234  docFile(), // fileName
235  docLine(), // startLine
236  this, // context
237  0, // memberdef
238  documentation()+inbodyDocumentation(), // docStr
239  TRUE, // index words
240  FALSE // not an example
241  );
242  ol.endTextBlock();
243 
244  Doxygen::markdownSupport = markdownEnabled;
245 
246  if (hasSubPages())
247  {
248  // for printed documentation we write subpages as section's of the
249  // parent page.
250  ol.pushGeneratorState();
251  ol.disableAll();
254 
256  PageDef *subPage=pdi.toFirst();
257  for (pdi.toFirst();(subPage=pdi.current());++pdi)
258  {
260  switch (m_nestingLevel)
261  {
262  case 0: sectionType = SectionInfo::Page; break;
263  case 1: sectionType = SectionInfo::Section; break;
264  case 2: sectionType = SectionInfo::Subsection; break;
265  case 3: sectionType = SectionInfo::Subsubsection; break;
266  default: sectionType = SectionInfo::Paragraph; break;
267  }
268  QCString title = subPage->title();
269  if (title.isEmpty()) title = subPage->name();
270  ol.startSection(subPage->name(),title,sectionType);
271  ol.parseText(title);
272  ol.endSection(subPage->name(),sectionType);
274  subPage->writePageDocumentation(ol);
276  }
277 
278  ol.popGeneratorState();
279  }
280 }
281 
283 {
284  static bool externalPages = Config_getBool("EXTERNAL_PAGES");
285  return // not part of a group
286  !getGroupDef() &&
287  // not an externally defined page
288  (!isReference() || externalPages)
289  ;
290 }
291 
293 {
294  return // not part of a group
295  !getGroupDef() &&
296  // not an externally defined page
297  !isReference();
298 }
299 
301 {
302  return m_subPageDict->count()>0;
303 }
304 
306 {
307  m_nestingLevel = l;
308 }
309 
311 {
312  m_showToc = b;
313 }
314 
static QDict< RefList > * xrefLists
Definition: doxygen.h:129
static bool markdownSupport
Definition: doxygen.h:153
QCString convertToXML(const char *s)
Definition: util.cpp:5717
QCString docFile() const
void endFile(OutputList &ol, bool skipNavIndex, bool skipEndContents, const QCString &navPath)
Definition: index.cpp:263
void endFileWithNavPath(Definition *d, OutputList &ol)
Definition: index.cpp:282
bool isEmpty() const
Definition: qcstring.h:189
QCString escapeCharsInString(const char *name, bool allowDots, bool allowUnderscore)
Definition: util.cpp:5242
void writeToc(OutputList &ol)
void startFile(OutputList &ol, const char *name, const char *manName, const char *title, HighlightedItem hli, bool additionalIndices, const char *altSidebarName)
Definition: index.cpp:244
QCString convertNameToFile(const char *name, bool allowDots=FALSE) const
QCString title() const
Definition: pagedef.h:54
SectionType type
Definition: section.h:58
bool generateDoc(const char *fileName, int startLine, Definition *ctx, MemberDef *md, const QCString &docStr, bool indexWords, bool isExample, const char *exampleName=0, bool singleLine=FALSE, bool linkFromIndex=FALSE)
Definition: outputlist.cpp:131
QCString inbodyDocumentation() const
void disableAllBut(OutputGenerator::OutputType o)
Definition: outputlist.cpp:49
QCString listName() const
Definition: reflist.cpp:98
void endTitleHead(const char *fileName, const char *name)
Definition: outputlist.h:107
void writeNavigationPath(OutputList &ol) const
virtual void setOuterScope(Definition *d)
const bool FALSE
Definition: qglobal.h:370
QCString label
Definition: section.h:56
bool hasSections() const
Definition: definition.cpp:447
static int subpageNestingLevel
Definition: doxygen.h:150
virtual bool isReference() const
~PageDef()
Definition: pagedef.cpp:42
Simplified and optimized version of QTextStream.
Definition: ftextstream.h:11
int count() const
Definition: sortdict.h:284
void findSectionsInDocumentation()
Definition: pagedef.cpp:47
GroupList * partOfGroups() const
void append(const char *key, const T *d)
Definition: sortdict.h:135
static QStrList * l
Definition: config.cpp:1044
bool parseText(const QCString &textStr)
Definition: outputlist.cpp:175
void setFileName(const char *name)
Definition: pagedef.cpp:66
void writeDocAnchorsToTagFile(FTextStream &)
Definition: definition.cpp:520
static NamespaceDef * globalScope
Definition: doxygen.h:128
void popGeneratorState()
Definition: outputlist.cpp:121
virtual DefType definitionType() const =0
bool hasSubPages() const
Definition: pagedef.cpp:300
bool hasParentPage() const
Definition: pagedef.cpp:89
void addIndexItem(Definition *context, MemberDef *md, const char *sectionAnchor=0, const char *title=0)
Definition: index.h:142
int m_nestingLevel
Definition: pagedef.h:77
const QCString & name() const
Definition: definition.h:114
void pushGeneratorState()
Definition: outputlist.cpp:111
bool visibleInIndex() const
Definition: pagedef.cpp:282
SrcLangExt getLanguage() const
std::void_t< T > n
void writeTagFile(FTextStream &)
Definition: pagedef.cpp:95
QCString m_fileName
Definition: pagedef.h:73
Definition * m_pageScope
Definition: pagedef.h:76
PageDef(const char *f, int l, const char *n, const char *d, const char *t)
Definition: pagedef.cpp:29
void disable(OutputGenerator::OutputType o)
Definition: outputlist.cpp:79
static SectionDict * sectionDict
Definition: doxygen.h:117
A bunch of utility functions.
PageSDict * m_subPageDict
Definition: pagedef.h:75
void enable(OutputGenerator::OutputType o)
Definition: outputlist.cpp:89
#define Config_getBool(val)
Definition: config.cpp:664
QCString title
Definition: section.h:57
type * getFirst() const
Definition: qlist.h:95
void endQuickIndices()
Definition: outputlist.h:352
void endContents()
Definition: outputlist.h:366
void endSection(const char *lab, SectionInfo::SectionType t)
Definition: outputlist.h:336
virtual Definition * getOuterScope() const
void startTitle(OutputList &ol, const char *fileName, Definition *def)
Definition: index.cpp:228
void addInnerCompound(Definition *d)
Definition: pagedef.cpp:71
void startTextBlock(bool dense=FALSE)
Definition: outputlist.h:404
A model of a page symbol.
Definition: pagedef.h:29
bool m_showToc
Definition: pagedef.h:78
void writePageDocumentation(OutputList &ol)
Definition: pagedef.cpp:223
void enableAll()
Definition: outputlist.cpp:59
void setShowToc(bool b)
Definition: pagedef.cpp:310
void writeDocumentation(OutputList &ol)
Definition: pagedef.cpp:119
static bool * b
Definition: config.cpp:1043
virtual void setDocumentation(const char *d, const char *docFile, int docLine, bool stripWhiteSpace=TRUE)
Definition: definition.cpp:612
void endTextBlock(bool paraBreak=FALSE)
Definition: outputlist.h:406
void endTitle(OutputList &ol, const char *fileName, const char *name)
Definition: index.cpp:237
void startTitleHead(const char *fileName)
Definition: outputlist.h:105
friend class Iterator
Definition: sortdict.h:289
bool documentedPage() const
Definition: pagedef.cpp:292
int docLine() const
void docFindSections(const char *input, Definition *d, MemberGroup *mg, const char *fileName)
Definition: docparser.cpp:7434
QCString getOutputFileBase() const
Definition: groupdef.cpp:1512
T * find(const char *key)
Definition: sortdict.h:232
void startSection(const char *lab, const char *title, SectionInfo::SectionType t)
Definition: outputlist.h:334
virtual QCString documentation() const
QCString getOutputFileBase() const
Definition: pagedef.cpp:58
static PageDef * mainPage
Definition: doxygen.h:103
const bool TRUE
Definition: qglobal.h:371
static IndexList * indexList
Definition: doxygen.h:149
QTextStream & endl(QTextStream &s)
GroupDef * getGroupDef() const
Definition: pagedef.cpp:52
void startContents()
Definition: outputlist.h:364
void setNestingLevel(int l)
Definition: pagedef.cpp:305
QCString filterTitle(const QCString &title)
Definition: util.cpp:7765
void disableAll()
Definition: outputlist.cpp:69