My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  m_fileName = ::convertNameToFile(n,FALSE,TRUE);
38  m_showToc = FALSE;
39 }
40 
42 {
43  delete m_subPageDict;
44 }
45 
47 {
49 }
50 
52 {
53  GroupList *groups = partOfGroups();
54  return groups!=0 ? groups->getFirst() : 0;
55 }
56 
57 QCString PageDef::getOutputFileBase() const
58 {
59  if (getGroupDef())
60  return getGroupDef()->getOutputFileBase();
61  else
62  return m_fileName;
63 }
64 
65 void PageDef::setFileName(const char *name)
66 {
67  m_fileName = name;
68 }
69 
71 {
73  {
74  PageDef *pd = (PageDef*)def;
75  m_subPageDict->append(pd->name(),pd);
76  def->setOuterScope(this);
77  if (this==Doxygen::mainPage)
78  {
80  }
81  else
82  {
84  }
85  }
86 }
87 
89 {
90  return getOuterScope() &&
92 }
93 
95 {
96  bool found = name()=="citelist";
97  QDictIterator<RefList> rli(*Doxygen::xrefLists);
98  RefList *rl;
99  for (rli.toFirst();(rl=rli.current()) && !found;++rli)
100  {
101  if (rl->listName()==name())
102  {
103  found=TRUE;
104  break;
105  }
106  }
107  if (!found) // not one of the generated related pages
108  {
109  tagFile << " <compound kind=\"page\">" << endl;
110  tagFile << " <name>" << name() << "</name>" << endl;
111  tagFile << " <title>" << convertToXML(title()) << "</title>" << endl;
112  tagFile << " <filename>" << convertToXML(getOutputFileBase()) << "</filename>" << endl;
113  writeDocAnchorsToTagFile(tagFile);
114  tagFile << " </compound>" << endl;
115  }
116 }
117 
119 {
120  static bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
121 
122  //outputList->disable(OutputGenerator::Man);
123  QCString pageName,manPageName;
124  pageName = escapeCharsInString(name(),FALSE,TRUE);
125  manPageName = escapeCharsInString(name(),TRUE,TRUE);
126 
127  //printf("PageDef::writeDocumentation: %s\n",getOutputFileBase().data());
128 
129  ol.pushGeneratorState();
130  //1.{
131 
132  if (m_nestingLevel>0
133  //&& // a sub page
134  //(Doxygen::mainPage==0 || getOuterScope()!=Doxygen::mainPage) // and not a subpage of the mainpage
135  )
136  {
137  // do not generate sub page output for RTF and LaTeX, as these are
138  // part of their parent page
139  ol.disableAll();
142  }
143 
144  ol.pushGeneratorState();
145  //2.{
147  startFile(ol,getOutputFileBase(),manPageName,title(),HLI_Pages,!generateTreeView);
148  ol.enableAll();
150  startFile(ol,getOutputFileBase(),pageName,title(),HLI_Pages,!generateTreeView);
151  ol.popGeneratorState();
152  //2.}
153 
154  if (!generateTreeView)
155  {
156  if (getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
157  {
159  }
160  ol.endQuickIndices();
161  }
163 
164  // save old generator state and write title only to Man generator
165  ol.pushGeneratorState();
166  //2.{
168  ol.startTitleHead(manPageName);
169  ol.endTitleHead(manPageName, manPageName);
170  if (si)
171  {
172  ol.generateDoc(docFile(),docLine(),this,0,si->title,TRUE,FALSE,0,TRUE,FALSE);
173  ol.endSection(si->label,si->type);
174  }
175  ol.popGeneratorState();
176  //2.}
177 
178  // for Latex the section is already generated as a chapter in the index!
179  ol.pushGeneratorState();
180  //2.{
184  if (!title().isEmpty() && !name().isEmpty() && si!=0)
185  {
186  //ol.startSection(si->label,si->title,si->type);
187  startTitle(ol,getOutputFileBase(),this);
188  ol.generateDoc(docFile(),docLine(),this,0,si->title,TRUE,FALSE,0,TRUE,FALSE);
189  //stringToSearchIndex(getOutputFileBase(),
190  // theTranslator->trPage(TRUE,TRUE)+" "+si->title,
191  // si->title);
192  //ol.endSection(si->label,si->type);
194  }
195  ol.startContents();
196  ol.popGeneratorState();
197  //2.}
198 
199  if (m_showToc && hasSections())
200  {
201  writeToc(ol);
202  }
203 
205 
206  if (generateTreeView && getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
207  {
208  ol.endContents();
210  }
211  else
212  {
213  endFile(ol);
214  }
215 
216  ol.popGeneratorState();
217  //1.}
218 
220 }
221 
223 {
224 
225  bool markdownEnabled = Doxygen::markdownSupport;
227  {
229  }
230 
231  ol.startTextBlock();
232  ol.generateDoc(
233  docFile(), // fileName
234  docLine(), // startLine
235  this, // context
236  0, // memberdef
237  documentation()+inbodyDocumentation(), // docStr
238  TRUE, // index words
239  FALSE // not an example
240  );
241  ol.endTextBlock();
242 
243  Doxygen::markdownSupport = markdownEnabled;
244 
245  if (hasSubPages())
246  {
247  // for printed documentation we write subpages as section's of the
248  // parent page.
249  ol.pushGeneratorState();
250  ol.disableAll();
253 
255  PageDef *subPage=pdi.toFirst();
256  for (pdi.toFirst();(subPage=pdi.current());++pdi)
257  {
259  switch (m_nestingLevel)
260  {
261  case 0: sectionType = SectionInfo::Page; break;
262  case 1: sectionType = SectionInfo::Section; break;
263  case 2: sectionType = SectionInfo::Subsection; break;
264  case 3: sectionType = SectionInfo::Subsubsection; break;
265  default: sectionType = SectionInfo::Paragraph; break;
266  }
267  QCString title = subPage->title();
268  if (title.isEmpty()) title = subPage->name();
269  ol.startSection(subPage->name(),title,sectionType);
270  ol.parseText(title);
271  ol.endSection(subPage->name(),sectionType);
273  subPage->writePageDocumentation(ol);
275  }
276 
277  ol.popGeneratorState();
278  }
279 }
280 
282 {
283  static bool externalPages = Config_getBool(EXTERNAL_PAGES);
284  return // not part of a group
285  !getGroupDef() &&
286  // not an externally defined page
287  (!isReference() || externalPages)
288  ;
289 }
290 
292 {
293  return // not part of a group
294  !getGroupDef() &&
295  // not an externally defined page
296  !isReference();
297 }
298 
300 {
301  return m_subPageDict->count()>0;
302 }
303 
305 {
306  m_nestingLevel = l;
307 }
308 
310 {
311  m_showToc |= b;
312 }
313