1 /******************************************************************************
3 * Copyright (C) 1997-2015 by Dimitri van Heesch.
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.
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
20 #include "docparser.h"
23 #include "outputlist.h"
26 #include "namespacedef.h"
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)
33 setDocumentation(d,f,l);
34 m_subPageDict = new PageSDict(7);
37 m_fileName = ::convertNameToFile(n,FALSE,TRUE);
46 void PageDef::findSectionsInDocumentation()
48 docFindSections(documentation(),this,0,docFile());
51 GroupDef *PageDef::getGroupDef() const
53 GroupList *groups = partOfGroups();
54 return groups!=0 ? groups->getFirst() : 0;
57 QCString PageDef::getOutputFileBase() const
60 return getGroupDef()->getOutputFileBase();
65 void PageDef::setFileName(const char *name)
70 void PageDef::addInnerCompound(Definition *def)
72 if (def->definitionType()==Definition::TypePage)
74 PageDef *pd = (PageDef*)def;
75 m_subPageDict->append(pd->name(),pd);
76 def->setOuterScope(this);
77 if (this==Doxygen::mainPage)
79 pd->setNestingLevel(m_nestingLevel);
83 pd->setNestingLevel(m_nestingLevel+1);
88 bool PageDef::hasParentPage() const
90 return getOuterScope() &&
91 getOuterScope()->definitionType()==Definition::TypePage;
94 void PageDef::writeTagFile(FTextStream &tagFile)
96 bool found = name()=="citelist";
97 QDictIterator<RefList> rli(*Doxygen::xrefLists);
99 for (rli.toFirst();(rl=rli.current()) && !found;++rli)
101 if (rl->listName()==name())
107 if (!found) // not one of the generated related pages
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;
118 void PageDef::writeDocumentation(OutputList &ol)
120 static bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
122 //outputList->disable(OutputGenerator::Man);
123 QCString pageName,manPageName;
124 pageName = escapeCharsInString(name(),FALSE,TRUE);
125 manPageName = escapeCharsInString(name(),TRUE,TRUE);
127 //printf("PageDef::writeDocumentation: %s\n",getOutputFileBase().data());
129 ol.pushGeneratorState();
134 //(Doxygen::mainPage==0 || getOuterScope()!=Doxygen::mainPage) // and not a subpage of the mainpage
137 // do not generate sub page output for RTF and LaTeX, as these are
138 // part of their parent page
140 ol.enable(OutputGenerator::Man);
141 ol.enable(OutputGenerator::Html);
144 ol.pushGeneratorState();
146 ol.disableAllBut(OutputGenerator::Man);
147 startFile(ol,getOutputFileBase(),manPageName,title(),HLI_Pages,!generateTreeView);
149 ol.disable(OutputGenerator::Man);
150 startFile(ol,getOutputFileBase(),pageName,title(),HLI_Pages,!generateTreeView);
151 ol.popGeneratorState();
154 if (!generateTreeView)
156 if (getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
158 getOuterScope()->writeNavigationPath(ol);
160 ol.endQuickIndices();
162 SectionInfo *si=Doxygen::sectionDict->find(name());
164 // save old generator state and write title only to Man generator
165 ol.pushGeneratorState();
167 ol.disableAllBut(OutputGenerator::Man);
168 ol.startTitleHead(manPageName);
169 ol.endTitleHead(manPageName, manPageName);
172 ol.pushGeneratorState();
173 ol.disableAllBut(OutputGenerator::Man);
174 ol.writeString(" - ");
175 ol.popGeneratorState();
177 if (si->title != manPageName)
179 ol.generateDoc(docFile(),docLine(),this,0,si->title,TRUE,FALSE,0,TRUE,FALSE);
180 ol.endSection(si->label,si->type);
183 ol.popGeneratorState();
186 // for Latex the section is already generated as a chapter in the index!
187 ol.pushGeneratorState();
189 ol.disable(OutputGenerator::Latex);
190 ol.disable(OutputGenerator::Docbook);
191 ol.disable(OutputGenerator::RTF);
192 ol.disable(OutputGenerator::Man);
193 if (!title().isEmpty() && !name().isEmpty() && si!=0)
195 ol.startPageDoc(si->title);
196 //ol.startSection(si->label,si->title,si->type);
197 startTitle(ol,getOutputFileBase(),this);
198 ol.generateDoc(docFile(),docLine(),this,0,si->title,TRUE,FALSE,0,TRUE,FALSE);
199 //stringToSearchIndex(getOutputFileBase(),
200 // theTranslator->trPage(TRUE,TRUE)+" "+si->title,
202 //ol.endSection(si->label,si->type);
203 endTitle(ol,getOutputFileBase(),name());
208 ol.popGeneratorState();
211 if ((m_localToc.isHtmlEnabled() || m_localToc.isLatexEnabled() || m_localToc.isDocbookEnabled()) && hasSections())
213 writeToc(ol, m_localToc);
216 writePageDocumentation(ol);
219 if (generateTreeView && getOuterScope()!=Doxygen::globalScope && !Config_getBool(DISABLE_INDEX))
222 endFileWithNavPath(getOuterScope(),ol);
229 ol.popGeneratorState();
232 Doxygen::indexList->addIndexItem(this,0,0,filterTitle(title()));
235 void PageDef::writePageDocumentation(OutputList &ol)
238 bool markdownEnabled = Doxygen::markdownSupport;
239 if (getLanguage()==SrcLangExt_Markdown)
241 Doxygen::markdownSupport = TRUE;
245 QCString docStr = documentation()+inbodyDocumentation();
246 if (hasBriefDescription() && !Doxygen::sectionDict->find(name()))
248 ol.pushGeneratorState();
249 ol.disableAllBut(OutputGenerator::Man);
250 ol.writeString(" - ");
251 ol.popGeneratorState();
254 docFile(), // fileName
255 docLine(), // startLine
260 FALSE // not an example
264 Doxygen::markdownSupport = markdownEnabled;
268 // for printed documentation we write subpages as section's of the
270 ol.pushGeneratorState();
272 ol.enable(OutputGenerator::Latex);
273 ol.enable(OutputGenerator::Docbook);
274 ol.enable(OutputGenerator::RTF);
276 PageSDict::Iterator pdi(*m_subPageDict);
277 PageDef *subPage=pdi.toFirst();
278 for (pdi.toFirst();(subPage=pdi.current());++pdi)
280 SectionInfo::SectionType sectionType = SectionInfo::Paragraph;
281 switch (m_nestingLevel)
283 case 0: sectionType = SectionInfo::Page; break;
284 case 1: sectionType = SectionInfo::Section; break;
285 case 2: sectionType = SectionInfo::Subsection; break;
286 case 3: sectionType = SectionInfo::Subsubsection; break;
287 default: sectionType = SectionInfo::Paragraph; break;
289 QCString title = subPage->title();
290 if (title.isEmpty()) title = subPage->name();
291 ol.startSection(subPage->name(),title,sectionType);
293 ol.endSection(subPage->name(),sectionType);
294 Doxygen::subpageNestingLevel++;
295 subPage->writePageDocumentation(ol);
296 Doxygen::subpageNestingLevel--;
299 ol.popGeneratorState();
303 bool PageDef::visibleInIndex() const
305 static bool externalPages = Config_getBool(EXTERNAL_PAGES);
306 return // not part of a group
308 // not an externally defined page
309 (!isReference() || externalPages)
313 bool PageDef::documentedPage() const
315 return // not part of a group
317 // not an externally defined page
321 bool PageDef::hasSubPages() const
323 return m_subPageDict->count()>0;
326 void PageDef::setNestingLevel(int l)
331 void PageDef::setLocalToc(const LocalToc <)
336 void PageDef::setShowLineNo(bool b)
341 bool PageDef::showLineNo() const