|
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 //outputList->disable(OutputGenerator::Man); |
|
73 QCString pageName; |
|
74 pageName=escapeCharsInString(name(),FALSE); |
|
75 |
|
76 startFile(ol,pageName,pageName,title(),HLI_Pages,TRUE); |
|
77 |
|
78 ol.pushGeneratorState(); |
|
79 //1.{ |
|
80 |
|
81 if (m_nestingLevel>0 |
|
82 //&& // a sub page |
|
83 //(Doxygen::mainPage==0 || getOuterScope()!=Doxygen::mainPage) // and not a subpage of the mainpage |
|
84 ) |
|
85 { |
|
86 // do not generate sub page output for RTF and LaTeX, as these are |
|
87 // part of their parent page |
|
88 ol.disableAll(); |
|
89 ol.enable(OutputGenerator::Man); |
|
90 ol.enable(OutputGenerator::Html); |
|
91 } |
|
92 |
|
93 if (getOuterScope()!=Doxygen::globalScope && !Config_getBool("DISABLE_INDEX")) |
|
94 { |
|
95 getOuterScope()->writeNavigationPath(ol); |
|
96 } |
|
97 |
|
98 ol.endQuickIndices(); |
|
99 ol.startContents(); |
|
100 |
|
101 // save old generator state and write title only to Man generator |
|
102 ol.pushGeneratorState(); |
|
103 //2.{ |
|
104 ol.disableAllBut(OutputGenerator::Man); |
|
105 ol.startTitleHead(pageName); |
|
106 ol.endTitleHead(pageName, pageName); |
|
107 ol.popGeneratorState(); |
|
108 //2.} |
|
109 |
|
110 // for Latex the section is already generated as a chapter in the index! |
|
111 ol.pushGeneratorState(); |
|
112 //2.{ |
|
113 ol.disable(OutputGenerator::Latex); |
|
114 ol.disable(OutputGenerator::RTF); |
|
115 SectionInfo *si=0; |
|
116 if (!title().isEmpty() && !name().isEmpty() && |
|
117 (si=Doxygen::sectionDict.find(pageName))!=0) |
|
118 { |
|
119 ol.startSection(si->label,si->title,si->type); |
|
120 ol.parseDoc(docFile(),docLine(),this,0,si->title,TRUE,FALSE,0,TRUE,FALSE); |
|
121 //stringToSearchIndex(getOutputFileBase(), |
|
122 // theTranslator->trPage(TRUE,TRUE)+" "+si->title, |
|
123 // si->title); |
|
124 ol.endSection(si->label,si->type); |
|
125 } |
|
126 ol.popGeneratorState(); |
|
127 //2.} |
|
128 |
|
129 writePageDocumentation(ol); |
|
130 |
|
131 ol.popGeneratorState(); |
|
132 //1.} |
|
133 |
|
134 endFile(ol); |
|
135 |
|
136 if (!Config_getString("GENERATE_TAGFILE").isEmpty()) |
|
137 { |
|
138 bool found=FALSE; |
|
139 QDictIterator<RefList> rli(*Doxygen::xrefLists); |
|
140 RefList *rl; |
|
141 for (rli.toFirst();(rl=rli.current());++rli) |
|
142 { |
|
143 if (rl->listName()==name()) |
|
144 { |
|
145 found=TRUE; |
|
146 break; |
|
147 } |
|
148 } |
|
149 if (!found) // not one of the generated related pages |
|
150 { |
|
151 Doxygen::tagFile << " <compound kind=\"page\">" << endl; |
|
152 Doxygen::tagFile << " <name>" << name() << "</name>" << endl; |
|
153 Doxygen::tagFile << " <title>" << convertToXML(title()) << "</title>" << endl; |
|
154 Doxygen::tagFile << " <filename>" << getOutputFileBase() << "</filename>" << endl; |
|
155 writeDocAnchorsToTagFile(); |
|
156 Doxygen::tagFile << " </compound>" << endl; |
|
157 } |
|
158 } |
|
159 |
|
160 Doxygen::indexList.addIndexItem(this,0,0,filterTitle(title())); |
|
161 } |
|
162 |
|
163 void PageDef::writePageDocumentation(OutputList &ol) |
|
164 { |
|
165 ol.startTextBlock(); |
|
166 ol.parseDoc( |
|
167 docFile(), // fileName |
|
168 docLine(), // startLine |
|
169 this, // context |
|
170 0, // memberdef |
|
171 documentation()+inbodyDocumentation(), // docStr |
|
172 TRUE, // index words |
|
173 FALSE // not an example |
|
174 ); |
|
175 ol.endTextBlock(); |
|
176 |
|
177 if (hasSubPages()) |
|
178 { |
|
179 // for printed documentation we write subpages as section's of the |
|
180 // parent page. |
|
181 ol.pushGeneratorState(); |
|
182 ol.disableAll(); |
|
183 ol.enable(OutputGenerator::Latex); |
|
184 ol.enable(OutputGenerator::RTF); |
|
185 |
|
186 PageSDict::Iterator pdi(*m_subPageDict); |
|
187 PageDef *subPage=pdi.toFirst(); |
|
188 for (pdi.toFirst();(subPage=pdi.current());++pdi) |
|
189 { |
|
190 SectionInfo::SectionType sectionType = SectionInfo::Paragraph; |
|
191 switch (m_nestingLevel) |
|
192 { |
|
193 case 0: sectionType = SectionInfo::Page; break; |
|
194 case 1: sectionType = SectionInfo::Section; break; |
|
195 case 2: sectionType = SectionInfo::Subsection; break; |
|
196 case 3: sectionType = SectionInfo::Subsubsection; break; |
|
197 default: sectionType = SectionInfo::Paragraph; break; |
|
198 } |
|
199 QCString title = subPage->title(); |
|
200 if (title.isEmpty()) title = subPage->name(); |
|
201 ol.startSection(subPage->name(),title,sectionType); |
|
202 ol.parseText(title); |
|
203 ol.endSection(subPage->name(),sectionType); |
|
204 Doxygen::subpageNestingLevel++; |
|
205 subPage->writePageDocumentation(ol); |
|
206 Doxygen::subpageNestingLevel--; |
|
207 } |
|
208 |
|
209 ol.popGeneratorState(); |
|
210 } |
|
211 } |
|
212 |
|
213 bool PageDef::visibleInIndex() const |
|
214 { |
|
215 return // not part of a group |
|
216 !getGroupDef() && |
|
217 // not an externally defined page |
|
218 (!isReference() || Config_getBool("ALLEXTERNALS")) && |
|
219 // not a subpage |
|
220 (getOuterScope()==0 || |
|
221 getOuterScope()->definitionType()!=Definition::TypePage |
|
222 ); |
|
223 } |
|
224 |
|
225 bool PageDef::documentedPage() const |
|
226 { |
|
227 return // not part of a group |
|
228 !getGroupDef() && |
|
229 // not an externally defined page |
|
230 !isReference(); |
|
231 } |
|
232 |
|
233 bool PageDef::hasSubPages() const |
|
234 { |
|
235 return m_subPageDict->count()>0; |
|
236 } |
|
237 |
|
238 void PageDef::setNestingLevel(int l) |
|
239 { |
|
240 m_nestingLevel = l; |
|
241 } |
|
242 |