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 200 of file qhp.cpp.

200: 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 318 of file qhp.cpp.

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

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 410 of file qhp.cpp.

411{
412 p->files.insert(("<file>" + convertToXML(fileName) + "</file>").str());
413}
DString convertToXML(const DString &s, bool keepEntities, const bool citeEntry)
Definition util.cpp:3232

References convertToXML(), and p.

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

◆ addImageFile()

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

Implements IndexIntf.

Definition at line 420 of file qhp.cpp.

421{
422 addFile(fileName);
423}

References addFile().

◆ addIndexFile()

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

Implements IndexIntf.

Definition at line 415 of file qhp.cpp.

416{
417 addFile(fileName);
418}

References addFile().

◆ addIndexItem()

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

Implements IndexIntf.

Definition at line 371 of file qhp.cpp.

373{
374 //printf("addIndexItem(%s %s %s\n",
375 // context?context->name().data():"<none>",
376 // md?md->name().data():"<none>",
377 // qPrint(word));
378
379 if (context && md) // member
380 {
381 if (sectionAnchor.empty() && !md->hasDocumentation()) return;
382 DString cfname = md->getOutputFileBase();
383 DString argStr = md->argsString();
384 DString level1 = context->name();
385 DString level2 = !word.empty() ? word : md->name();
386 DString anchor = !sectionAnchor.empty() ? sectionAnchor : md->anchor();
387 DString ref;
388
389 // <keyword name="foo" id="MyApplication::foo" ref="doc.html#foo"/>
390 ref = makeRef(cfname, anchor);
391 DString id = level1+"::"+level2;
392 writeIndent(p->index,3);
393 p->index << "<keyword name=\"" << convertToXML(level2 + argStr) << "\""
394 " id=\"" << convertToXML(id + "_" + anchor) << "\""
395 " ref=\"" << convertToXML(ref) << "\"/>\n";
396 }
397 else if (context) // container
398 {
399 // <keyword name="Foo" id="Foo" ref="doc.html#Foo"/>
400 DString contRef = context->getOutputFileBase();
401 DString level1 = !word.empty() ? word : context->name();
402 DString ref = makeRef(contRef,sectionAnchor);
403 writeIndent(p->index,3);
404 p->index << "<keyword name=\"" << convertToXML(level1) << "\""
405 << " id=\"" << convertToXML(level1 +"_" + sectionAnchor) << "\""
406 << " ref=\"" << convertToXML(ref) << "\"/>\n";
407 }
408}
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:41

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 425 of file qhp.cpp.

426{
427 addFile(fileName);
428}

References addFile().

◆ decContentsDepth()

void Qhp::decContentsDepth ( )
virtual

Implements IndexIntf.

Definition at line 313 of file qhp.cpp.

314{
315 p->sectionTree.decLevel();
316}

References p.

◆ finalize()

void Qhp::finalize ( )
virtual

Implements IndexIntf.

Definition at line 276 of file qhp.cpp.

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

References p, and writeIndent().

◆ getQchFileName()

DString Qhp::getQchFileName ( )
static

Definition at line 430 of file qhp.cpp.

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

References Config_getString, and DString::empty().

Referenced by runQHelpGenerator().

◆ incContentsDepth()

void Qhp::incContentsDepth ( )
virtual

Implements IndexIntf.

Definition at line 308 of file qhp.cpp.

309{
310 p->sectionTree.incLevel();
311}

References p.

◆ initialize()

void Qhp::initialize ( )
virtual

Implements IndexIntf.

Definition at line 203 of file qhp.cpp.

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