Doxygen
Loading...
Searching...
No Matches
Qhp Class Referencefinal

#include <src/qhp.h>

Inheritance diagram for Qhp:
Collaboration diagram for Qhp:

Classes

class  Private

Public Member Functions

 Qhp ()
 ~Qhp ()
void initialize ()
void finalize ()
void incContentsDepth ()
void decContentsDepth ()
void addContentsItem (bool isDir, const DString &name, const DString &ref, const DString &file, const DString &anchor, bool separateIndex, bool addToNavIndex, const Definition *def, const DString &)
void addIndexItem (const Definition *context, const MemberDef *md, const DString &sectionAnchor, const DString &title)
void addIndexFile (const DString &name)
void addImageFile (const DString &name)
void addStyleSheetFile (const DString &name)

Static Public Member Functions

static DString getQchFileName ()

Static Public Attributes

static const DString qhpFileName = "index.qhp"

Private Member Functions

void addFile (const DString &)

Private Attributes

std::unique_ptr< Privatep

Detailed Description

Definition at line 28 of file qhp.h.

Constructor & Destructor Documentation

◆ Qhp()

Qhp::Qhp ( )

Definition at line 197 of file qhp.cpp.

197: p(std::make_unique<Private>()) {}
std::unique_ptr< Private > p
Definition qhp.h:55

References p.

Referenced by ~Qhp().

◆ ~Qhp()

Qhp::~Qhp ( )
default

References Qhp().

Member Function Documentation

◆ addContentsItem()

void Qhp::addContentsItem ( bool isDir,
const DString & name,
const DString & ref,
const DString & file,
const DString & anchor,
bool separateIndex,
bool addToNavIndex,
const Definition * def,
const DString &  )
virtual

Implements IndexIntf.

Definition at line 315 of file qhp.cpp.

318{
319 /*
320 <toc>
321 <section title="My Application Manual" ref="index.html">
322 <section title="Chapter 1" ref="doc.html#chapter1"/>
323 <section title="Chapter 2" ref="doc.html#chapter2"/>
324 <section title="Chapter 3" ref="doc.html#chapter3"/>
325 </section>
326 </toc>
327 */
328
329 DString f = file;
330 if (!f.empty() && f.at(0)=='^') return; // absolute URL not supported
331
332 if (f.empty())
333 {
334 f = "doxygen_blank";
336 std::call_once(g_blankWritten,[this,&f]()
337 {
338 DString fileName = Config_getString(HTML_OUTPUT) + "/" + f;
339 std::ofstream blankFile = Portable::openOutputStream(fileName); // we just need an empty file
340 if (!blankFile.is_open())
341 {
342 term("Could not open file {} for writing\n",fileName);
343 }
344 TextStream blank;
345 blank.setStream(&blankFile);
346 blank << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
347 blank << "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"" + theTranslator->trISOLang() + "\">\n";
348 blank << "<head>\n";
349 blank << "<title>Validator / crawler helper</title>\n";
350 blank << "<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>\n";
351 blank << "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=11\"/>\n";
352
353 blank << "<meta name=\"generator\" content=\"Doxygen " + getDoxygenVersion() + "\"/>\n";
354 blank << "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n";
355 blank << "</head>\n";
356 blank << "<body>\n";
357 blank << "</body>\n";
358 blank << "</html>\n";
359 blank.flush();
360 blankFile.close();
361 addFile(f);
362 });
363 }
364 DString finalRef = makeRef(f, anchor);
365 p->sectionTree.addSection(name,finalRef);
366}
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:152
char & at(size_t i)
Returns a reference to the character at index i.
Definition dstring.h:690
void addFile(const DString &)
Definition qhp.cpp:407
void setStream(std::ostream *s)
Sets or changes the std::ostream to write to.
Definition textstream.h:67
void flush()
Flushes the buffer.
Definition textstream.h:212
virtual DString trISOLang()=0
#define Config_getString(name)
Definition config.h:32
Translator * theTranslator
Definition language.cpp:71
#define term(fmt,...)
Definition message.h:137
std::ofstream openOutputStream(const DString &name, bool append=false)
Definition portable.cpp:665
static DString makeRef(const DString &withoutExtension, const DString &anchor)
Definition qhp.cpp:188
static std::once_flag g_blankWritten
Definition qhp.cpp:35
void addHtmlExtensionIfMissing(DString &fName)
Definition util.cpp:3933

References addFile(), addHtmlExtensionIfMissing(), DString::at(), Config_getString, DString::empty(), TextStream::flush(), g_blankWritten, makeRef(), Portable::openOutputStream(), p, TextStream::setStream(), term, theTranslator, and Translator::trISOLang().

◆ addFile()

void Qhp::addFile ( const DString & fileName)
private

Definition at line 407 of file qhp.cpp.

408{
409 p->files.insert(("<file>" + convertToXML(fileName) + "</file>").str());
410}
DString convertToXML(const DString &s, bool keepEntities, const bool citeEntry)
Definition util.cpp:3234

References convertToXML(), and p.

Referenced by addContentsItem(), addImageFile(), addIndexFile(), and addStyleSheetFile().

◆ addImageFile()

void Qhp::addImageFile ( const DString & name)
virtual

Implements IndexIntf.

Definition at line 417 of file qhp.cpp.

418{
419 addFile(fileName);
420}

References addFile().

◆ addIndexFile()

void Qhp::addIndexFile ( const DString & name)
virtual

Implements IndexIntf.

Definition at line 412 of file qhp.cpp.

413{
414 addFile(fileName);
415}

References addFile().

◆ addIndexItem()

void Qhp::addIndexItem ( const Definition * context,
const MemberDef * md,
const DString & sectionAnchor,
const DString & title )
virtual

Implements IndexIntf.

Definition at line 368 of file qhp.cpp.

370{
371 //printf("addIndexItem(%s %s %s\n",
372 // context?context->name().data():"<none>",
373 // md?md->name().data():"<none>",
374 // qPrint(word));
375
376 if (context && md) // member
377 {
378 if (sectionAnchor.empty() && !md->hasDocumentation()) return;
379 DString cfname = md->getOutputFileBase();
380 DString argStr = md->argsString();
381 DString level1 = context->name();
382 DString level2 = !word.empty() ? word : md->name();
383 DString anchor = !sectionAnchor.empty() ? sectionAnchor : md->anchor();
384 DString ref;
385
386 // <keyword name="foo" id="MyApplication::foo" ref="doc.html#foo"/>
387 ref = makeRef(cfname, anchor);
388 DString id = level1+"::"+level2;
389 writeIndent(p->index,3);
390 p->index << "<keyword name=\"" << convertToXML(level2 + argStr) << "\""
391 " id=\"" << convertToXML(id + "_" + anchor) << "\""
392 " ref=\"" << convertToXML(ref) << "\"/>\n";
393 }
394 else if (context) // container
395 {
396 // <keyword name="Foo" id="Foo" ref="doc.html#Foo"/>
397 DString contRef = context->getOutputFileBase();
398 DString level1 = !word.empty() ? word : context->name();
399 DString ref = makeRef(contRef,sectionAnchor);
400 writeIndent(p->index,3);
401 p->index << "<keyword name=\"" << convertToXML(level1) << "\""
402 << " id=\"" << convertToXML(level1 +"_" + sectionAnchor) << "\""
403 << " ref=\"" << convertToXML(ref) << "\"/>\n";
404 }
405}
virtual const DString & name() const =0
virtual bool hasDocumentation() const =0
virtual DString anchor() const =0
virtual DString getOutputFileBase() const =0
virtual DString argsString() const =0
static void writeIndent(TextStream &t, int indent)
Definition qhp.cpp:38

References Definition::anchor(), MemberDef::argsString(), convertToXML(), DString::empty(), Definition::getOutputFileBase(), Definition::hasDocumentation(), makeRef(), Definition::name(), p, and writeIndent().

◆ addStyleSheetFile()

void Qhp::addStyleSheetFile ( const DString & name)
virtual

Implements IndexIntf.

Definition at line 422 of file qhp.cpp.

423{
424 addFile(fileName);
425}

References addFile().

◆ decContentsDepth()

void Qhp::decContentsDepth ( )
virtual

Implements IndexIntf.

Definition at line 310 of file qhp.cpp.

311{
312 p->sectionTree.decLevel();
313}

References p.

◆ finalize()

void Qhp::finalize ( )
virtual

Implements IndexIntf.

Definition at line 273 of file qhp.cpp.

274{
275 // close root node
276 p->sectionTree.decLevel();
277
278 // Finish TOC
279 p->sectionTree.writeToc(p->doc);
280
281 // Finish index
282 writeIndent(p->index,2);
283 p->index << "</keywords>\n";
284 p->doc << p->index.str();
285
286 // Finish files
287 writeIndent(p->doc,2);
288 p->doc << "<files>\n";
289 for (auto &s : p->files)
290 {
291 writeIndent(p->doc,3);
292 p->doc << s << "\n";
293 }
294 writeIndent(p->doc,2);
295 p->doc << "</files>\n";
296
297 writeIndent(p->doc,1);
298 p->doc << "</filterSection>\n";
299 p->doc << "</QtHelpProject>\n";
300
301 p->doc.flush();
302 p->docFile.close();
303}

References p, and writeIndent().

◆ getQchFileName()

DString Qhp::getQchFileName ( )
static

Definition at line 427 of file qhp.cpp.

428{
429 DString qchFile = Config_getString(QCH_FILE);
430 if (!qchFile.empty())
431 {
432 return qchFile;
433 }
434
435 DString projectName = Config_getString(PROJECT_NAME);
436 DString versionText = Config_getString(PROJECT_NUMBER);
437
438 return DString("../qch/")
439 + (projectName.empty() ? DString("index") : projectName)
440 + (versionText.empty() ? DString("") : DString("-") + versionText)
441 + DString(".qch");
442}

References Config_getString, and DString::empty().

Referenced by runQHelpGenerator().

◆ incContentsDepth()

void Qhp::incContentsDepth ( )
virtual

Implements IndexIntf.

Definition at line 305 of file qhp.cpp.

306{
307 p->sectionTree.incLevel();
308}

References p.

◆ initialize()

void Qhp::initialize ( )
virtual

Implements IndexIntf.

Definition at line 200 of file qhp.cpp.

201{
202 /*
203 <QtHelpProject version="1.0">
204 <namespace>mycompany.com.myapplication.1_0</namespace>
205 <virtualFolder>doc</virtualFolder>
206 <customFilter name="My Application 1.0">
207 <filterAttribute>myapp</filterAttribute>
208 <filterAttribute>1.0</filterAttribute>
209 </customFilter>
210 <filterSection>
211 <filterAttribute>myapp</filterAttribute>
212 <filterAttribute>1.0</filterAttribute>
213 ..
214 */
215 DString fileName = Config_getString(HTML_OUTPUT) + "/" + qhpFileName;
216 p->docFile = Portable::openOutputStream(fileName);
217 if (!p->docFile.is_open())
218 {
219 term("Could not open file {} for writing\n",fileName);
220 }
221 p->doc.setStream(&p->docFile);
222
223 p->doc << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
224 p->doc << "<QtHelpProject version=\"1.0\">\n";
225 writeIndent(p->doc,1);
226 p->doc << "<namespace>" << convertToXML(Config_getString(QHP_NAMESPACE)) << "</namespace>\n";
227 writeIndent(p->doc,1);
228 p->doc << "<virtualFolder>" << convertToXML(Config_getString(QHP_VIRTUAL_FOLDER)) << "</virtualFolder>\n";
229
230 // Add custom filter
231 DString filterName = Config_getString(QHP_CUST_FILTER_NAME);
232 if (!filterName.empty())
233 {
234 writeIndent(p->doc,1);
235 p->doc << "<customFilter name=\"" << convertToXML(filterName) << "\">\n";
236
237 StringVector customFilterAttributes =
238 split(Config_getString(QHP_CUST_FILTER_ATTRS).str(), " ");
239 for (const auto &attr : customFilterAttributes)
240 {
241 writeIndent(p->doc,2);
242 p->doc << "<filterAttribute>" << convertToXML(attr) << "</filterAttribute>\n";
243 }
244 writeIndent(p->doc,1);
245 p->doc << "</customFilter>\n";
246 }
247
248 writeIndent(p->doc,1);
249 p->doc << "<filterSection>\n";
250
251 // Add section attributes
252 StringVector sectionFilterAttributes = split(Config_getString(QHP_SECT_FILTER_ATTRS).str(), " ");
253 // always add doxygen as filter attribute
254 if (std::find(sectionFilterAttributes.begin(), sectionFilterAttributes.end(), "doxygen") ==
255 sectionFilterAttributes.end())
256 {
257 sectionFilterAttributes.emplace_back("doxygen");
258 }
259 for (const auto &attr : sectionFilterAttributes)
260 {
261 writeIndent(p->doc,2);
262 p->doc << "<filterAttribute>" << convertToXML(attr) << "</filterAttribute>\n";
263 }
264
265 // Add extra root node to the TOC
266 p->sectionTree.addSection(getFullProjectName(),"index"+Doxygen::htmlFileExtension);
267 p->sectionTree.incLevel();
268
269 writeIndent(p->index,2);
270 p->index << "<keywords>\n";
271}
static DString htmlFileExtension
Definition doxygen.h:115
static const DString qhpFileName
Definition qhp.h:49
std::vector< std::string > StringVector
Definition containers.h:33
static DString getFullProjectName()
Definition qhp.cpp:162
StringVector split(const std::string &s, const std::string &delimiter)
split input string s by string delimiter delimiter.
Definition stringutil.h:117

References Config_getString, convertToXML(), DString::empty(), getFullProjectName(), Doxygen::htmlFileExtension, Portable::openOutputStream(), p, qhpFileName, split(), term, and writeIndent().

Member Data Documentation

◆ p

std::unique_ptr<Private> Qhp::p
private

◆ qhpFileName

const DString Qhp::qhpFileName = "index.qhp"
inlinestatic

Definition at line 49 of file qhp.h.

Referenced by initialize(), and runQHelpGenerator().


The documentation for this class was generated from the following files: