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

#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 QCString &name, const QCString &ref, const QCString &file, const QCString &anchor, bool separateIndex, bool addToNavIndex, const Definition *def)
 
void addIndexItem (const Definition *context, const MemberDef *md, const QCString &sectionAnchor, const QCString &title)
 
void addIndexFile (const QCString &name)
 
void addImageFile (const QCString &name)
 
void addStyleSheetFile (const QCString &name)
 
- Public Member Functions inherited from IndexIntf

Static Public Member Functions

static QCString getQchFileName ()
 

Static Public Attributes

static const QCString qhpFileName = "index.qhp"
 

Private Member Functions

void addFile (const QCString &)
 

Private Attributes

std::unique_ptr< Privatep
 

Detailed Description

Definition at line 26 of file qhp.h.

Constructor & Destructor Documentation

◆ Qhp()

Qhp::Qhp ( )

Definition at line 196 of file qhp.cpp.

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

References p.

Referenced by ~Qhp().

◆ ~Qhp()

Qhp::~Qhp ( )
default

References Qhp().

Member Function Documentation

◆ addContentsItem()

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

Implements IndexIntf.

Definition at line 314 of file qhp.cpp.

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

References addFile(), addHtmlExtensionIfMissing(), QCString::at(), Config_getString, TextStream::flush(), g_blankWritten, QCString::isEmpty(), makeRef(), Portable::openOutputStream(), p, qPrint(), TextStream::setStream(), term, and theTranslator.

◆ addFile()

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

Definition at line 408 of file qhp.cpp.

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

References convertToXML(), and p.

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

◆ addImageFile()

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

Implements IndexIntf.

Definition at line 418 of file qhp.cpp.

419{
420 addFile(fileName);
421}

References addFile().

◆ addIndexFile()

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

Implements IndexIntf.

Definition at line 413 of file qhp.cpp.

414{
415 addFile(fileName);
416}

References addFile().

◆ addIndexItem()

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

Implements IndexIntf.

Definition at line 369 of file qhp.cpp.

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

References Definition::anchor(), MemberDef::argsString(), convertToXML(), Definition::getOutputFileBase(), QCString::isEmpty(), makeRef(), Definition::name(), p, word, and writeIndent().

◆ addStyleSheetFile()

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

Implements IndexIntf.

Definition at line 423 of file qhp.cpp.

424{
425 addFile(fileName);
426}

References addFile().

◆ decContentsDepth()

void Qhp::decContentsDepth ( )
virtual

Implements IndexIntf.

Definition at line 309 of file qhp.cpp.

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

References p.

◆ finalize()

void Qhp::finalize ( )
virtual

Implements IndexIntf.

Definition at line 272 of file qhp.cpp.

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

References p, and writeIndent().

◆ getQchFileName()

QCString Qhp::getQchFileName ( )
static

Definition at line 428 of file qhp.cpp.

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

References Config_getString, and QCString::isEmpty().

Referenced by runQHelpGenerator().

◆ incContentsDepth()

void Qhp::incContentsDepth ( )
virtual

Implements IndexIntf.

Definition at line 304 of file qhp.cpp.

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

References p.

◆ initialize()

void Qhp::initialize ( )
virtual

Implements IndexIntf.

Definition at line 199 of file qhp.cpp.

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

References Config_getString, convertToXML(), QCString::data(), getFullProjectName(), Doxygen::htmlFileExtension, QCString::isEmpty(), Portable::openOutputStream(), p, qhpFileName, split(), term, and writeIndent().

Member Data Documentation

◆ p

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

◆ qhpFileName

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

Definition at line 47 of file qhp.h.

Referenced by initialize(), and runQHelpGenerator().


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