Root/
Source at commit 1322 created 12 years 8 months ago. By meklort, Add doxygen to utils folder | |
---|---|
1 | #include "pagedef.h"␊ |
2 | #include "groupdef.h"␊ |
3 | #include "docparser.h"␊ |
4 | #include "config.h"␊ |
5 | #include "util.h"␊ |
6 | #include "outputlist.h"␊ |
7 | #include "doxygen.h"␊ |
8 | #include "language.h"␊ |
9 | #include <qregexp.h>␊ |
10 | ␊ |
11 | ␊ |
12 | PageDef::PageDef(const char *f,int l,const char *n,␊ |
13 | const char *d,const char *t)␊ |
14 | : Definition(f,l,n), m_title(t)␊ |
15 | {␊ |
16 | setDocumentation(d,f,l);␊ |
17 | m_subPageDict = new PageSDict(7);␊ |
18 | m_pageScope = 0;␊ |
19 | m_nestingLevel = 0;␊ |
20 | }␊ |
21 | ␊ |
22 | PageDef::~PageDef()␊ |
23 | {␊ |
24 | delete m_subPageDict;␊ |
25 | }␊ |
26 | ␊ |
27 | void PageDef::findSectionsInDocumentation()␊ |
28 | {␊ |
29 | docFindSections(documentation(),this,0,docFile());␊ |
30 | }␊ |
31 | ␊ |
32 | GroupDef *PageDef::getGroupDef() const ␊ |
33 | { ␊ |
34 | LockingPtr<GroupList> groups = partOfGroups();␊ |
35 | return groups!=0 ? groups->getFirst() : 0; ␊ |
36 | }␊ |
37 | ␊ |
38 | QCString PageDef::getOutputFileBase() const ␊ |
39 | { ␊ |
40 | if (getGroupDef()) ␊ |
41 | return getGroupDef()->getOutputFileBase();␊ |
42 | else ␊ |
43 | return m_fileName; ␊ |
44 | }␊ |
45 | ␊ |
46 | void PageDef::addInnerCompound(Definition *def)␊ |
47 | {␊ |
48 | if (def->definitionType()==Definition::TypePage)␊ |
49 | {␊ |
50 | PageDef *pd = (PageDef*)def;␊ |
51 | m_subPageDict->append(pd->name(),pd);␊ |
52 | def->setOuterScope(this);␊ |
53 | if (this==Doxygen::mainPage)␊ |
54 | {␊ |
55 | pd->setNestingLevel(m_nestingLevel);␊ |
56 | }␊ |
57 | else␊ |
58 | {␊ |
59 | pd->setNestingLevel(m_nestingLevel+1);␊ |
60 | }␊ |
61 | }␊ |
62 | }␊ |
63 | ␊ |
64 | bool PageDef::hasParentPage() const␊ |
65 | {␊ |
66 | return getOuterScope() && ␊ |
67 | getOuterScope()->definitionType()==Definition::TypePage;␊ |
68 | }␊ |
69 | ␊ |
70 | void PageDef::writeDocumentation(OutputList &ol)␊ |
71 | {␊ |
72 | static bool generateTreeView = Config_getBool("GENERATE_TREEVIEW");␊ |
73 | ␊ |
74 | //outputList->disable(OutputGenerator::Man);␊ |
75 | QCString pageName;␊ |
76 | pageName=escapeCharsInString(name(),FALSE,TRUE);␊ |
77 | ␊ |
78 | //printf("PageDef::writeDocumentation: %s\n",getOutputFileBase().data());␊ |
79 | ␊ |
80 | startFile(ol,getOutputFileBase(),pageName,title(),HLI_Pages,!generateTreeView);␊ |
81 | ␊ |
82 | ol.pushGeneratorState();␊ |
83 | //1.{ ␊ |
84 | ␊ |
85 | if (m_nestingLevel>0 ␊ |
86 | //&& // a sub page␊ |
87 | //(Doxygen::mainPage==0 || getOuterScope()!=Doxygen::mainPage) // and not a subpage of the mainpage␊ |
88 | )␊ |
89 | {␊ |
90 | // do not generate sub page output for RTF and LaTeX, as these are␊ |
91 | // part of their parent page␊ |
92 | ol.disableAll();␊ |
93 | ol.enable(OutputGenerator::Man);␊ |
94 | ol.enable(OutputGenerator::Html);␊ |
95 | }␊ |
96 | ␊ |
97 | if (!generateTreeView)␊ |
98 | {␊ |
99 | if (getOuterScope()!=Doxygen::globalScope && !Config_getBool("DISABLE_INDEX"))␊ |
100 | {␊ |
101 | getOuterScope()->writeNavigationPath(ol);␊ |
102 | }␊ |
103 | ol.endQuickIndices();␊ |
104 | }␊ |
105 | SectionInfo *si=Doxygen::sectionDict.find(name());␊ |
106 | ␊ |
107 | // save old generator state and write title only to Man generator␊ |
108 | ol.pushGeneratorState();␊ |
109 | //2.{␊ |
110 | ol.disableAllBut(OutputGenerator::Man);␊ |
111 | ol.startTitleHead(pageName);␊ |
112 | ol.endTitleHead(pageName, pageName);␊ |
113 | if (si)␊ |
114 | {␊ |
115 | ol.parseDoc(docFile(),docLine(),this,0,si->title,TRUE,FALSE,0,TRUE,FALSE);␊ |
116 | ol.endSection(si->label,si->type);␊ |
117 | }␊ |
118 | ol.popGeneratorState();␊ |
119 | //2.}␊ |
120 | ␊ |
121 | // for Latex the section is already generated as a chapter in the index!␊ |
122 | ol.pushGeneratorState();␊ |
123 | //2.{␊ |
124 | ol.disable(OutputGenerator::Latex);␊ |
125 | ol.disable(OutputGenerator::RTF);␊ |
126 | ol.disable(OutputGenerator::Man);␊ |
127 | if (!title().isEmpty() && !name().isEmpty() && si!=0)␊ |
128 | {␊ |
129 | //ol.startSection(si->label,si->title,si->type);␊ |
130 | startTitle(ol,getOutputFileBase(),this);␊ |
131 | ol.parseDoc(docFile(),docLine(),this,0,si->title,TRUE,FALSE,0,TRUE,FALSE);␊ |
132 | //stringToSearchIndex(getOutputFileBase(),␊ |
133 | // theTranslator->trPage(TRUE,TRUE)+" "+si->title,␊ |
134 | // si->title);␊ |
135 | //ol.endSection(si->label,si->type);␊ |
136 | endTitle(ol,getOutputFileBase(),name());␊ |
137 | }␊ |
138 | ol.startContents();␊ |
139 | ol.popGeneratorState();␊ |
140 | //2.}␊ |
141 | ␊ |
142 | writePageDocumentation(ol);␊ |
143 | ␊ |
144 | ol.popGeneratorState();␊ |
145 | //1.}␊ |
146 | ␊ |
147 | if (generateTreeView && getOuterScope()!=Doxygen::globalScope && !Config_getBool("DISABLE_INDEX"))␊ |
148 | {␊ |
149 | ol.endContents();␊ |
150 | getOuterScope()->writeNavigationPath(ol);␊ |
151 | endFile(ol,TRUE);␊ |
152 | }␊ |
153 | else␊ |
154 | {␊ |
155 | endFile(ol);␊ |
156 | }␊ |
157 | ␊ |
158 | if (!Config_getString("GENERATE_TAGFILE").isEmpty())␊ |
159 | {␊ |
160 | bool found=FALSE;␊ |
161 | QDictIterator<RefList> rli(*Doxygen::xrefLists);␊ |
162 | RefList *rl;␊ |
163 | for (rli.toFirst();(rl=rli.current());++rli)␊ |
164 | {␊ |
165 | if (rl->listName()==name())␊ |
166 | {␊ |
167 | found=TRUE;␊ |
168 | break;␊ |
169 | }␊ |
170 | }␊ |
171 | if (!found) // not one of the generated related pages␊ |
172 | {␊ |
173 | Doxygen::tagFile << " <compound kind=\"page\">" << endl;␊ |
174 | Doxygen::tagFile << " <name>" << name() << "</name>" << endl;␊ |
175 | Doxygen::tagFile << " <title>" << convertToXML(title()) << "</title>" << endl;␊ |
176 | Doxygen::tagFile << " <filename>" << getOutputFileBase() << "</filename>" << endl;␊ |
177 | writeDocAnchorsToTagFile();␊ |
178 | Doxygen::tagFile << " </compound>" << endl;␊ |
179 | }␊ |
180 | }␊ |
181 | ␊ |
182 | Doxygen::indexList.addIndexItem(this,0,filterTitle(title()));␊ |
183 | }␊ |
184 | ␊ |
185 | void PageDef::writePageDocumentation(OutputList &ol)␊ |
186 | {␊ |
187 | ol.startTextBlock();␊ |
188 | ol.parseDoc(␊ |
189 | docFile(), // fileName␊ |
190 | docLine(), // startLine␊ |
191 | this, // context␊ |
192 | 0, // memberdef␊ |
193 | documentation()+inbodyDocumentation(), // docStr␊ |
194 | TRUE, // index words␊ |
195 | FALSE // not an example␊ |
196 | );␊ |
197 | ol.endTextBlock();␊ |
198 | ␊ |
199 | if (hasSubPages())␊ |
200 | {␊ |
201 | // for printed documentation we write subpages as section's of the␊ |
202 | // parent page.␊ |
203 | ol.pushGeneratorState();␊ |
204 | ol.disableAll();␊ |
205 | ol.enable(OutputGenerator::Latex);␊ |
206 | ol.enable(OutputGenerator::RTF);␊ |
207 | ␊ |
208 | PageSDict::Iterator pdi(*m_subPageDict);␊ |
209 | PageDef *subPage=pdi.toFirst();␊ |
210 | for (pdi.toFirst();(subPage=pdi.current());++pdi)␊ |
211 | {␊ |
212 | SectionInfo::SectionType sectionType = SectionInfo::Paragraph;␊ |
213 | switch (m_nestingLevel)␊ |
214 | {␊ |
215 | case 0: sectionType = SectionInfo::Page; break;␊ |
216 | case 1: sectionType = SectionInfo::Section; break;␊ |
217 | case 2: sectionType = SectionInfo::Subsection; break;␊ |
218 | case 3: sectionType = SectionInfo::Subsubsection; break;␊ |
219 | default: sectionType = SectionInfo::Paragraph; break;␊ |
220 | }␊ |
221 | QCString title = subPage->title();␊ |
222 | if (title.isEmpty()) title = subPage->name();␊ |
223 | ol.startSection(subPage->name(),title,sectionType);␊ |
224 | ol.parseText(title);␊ |
225 | ol.endSection(subPage->name(),sectionType);␊ |
226 | Doxygen::subpageNestingLevel++;␊ |
227 | subPage->writePageDocumentation(ol);␊ |
228 | Doxygen::subpageNestingLevel--;␊ |
229 | }␊ |
230 | ␊ |
231 | ol.popGeneratorState();␊ |
232 | }␊ |
233 | }␊ |
234 | ␊ |
235 | bool PageDef::visibleInIndex() const␊ |
236 | {␊ |
237 | return // not part of a group␊ |
238 | !getGroupDef() && ␊ |
239 | // not an externally defined page␊ |
240 | (!isReference() || Config_getBool("ALLEXTERNALS")) &&␊ |
241 | // not a subpage␊ |
242 | (getOuterScope()==0 || ␊ |
243 | getOuterScope()->definitionType()!=Definition::TypePage␊ |
244 | );␊ |
245 | }␊ |
246 | ␊ |
247 | bool PageDef::documentedPage() const␊ |
248 | {␊ |
249 | return // not part of a group␊ |
250 | !getGroupDef() && ␊ |
251 | // not an externally defined page␊ |
252 | !isReference();␊ |
253 | }␊ |
254 | ␊ |
255 | bool PageDef::hasSubPages() const␊ |
256 | {␊ |
257 | return m_subPageDict->count()>0;␊ |
258 | }␊ |
259 | ␊ |
260 | void PageDef::setNestingLevel(int l)␊ |
261 | {␊ |
262 | m_nestingLevel = l;␊ |
263 | }␊ |
264 | ␊ |
265 |