PageRenderTime 36ms CodeModel.GetById 5ms RepoModel.GetById 0ms app.codeStats 0ms

/src/qt/qtbase/src/tools/qdoc/qdocindexfiles.cpp

https://gitlab.com/x33n/phantomjs
C++ | 1335 lines | 1083 code | 90 blank | 162 comment | 404 complexity | 4fd8e75f1703ca8e754f9ef2fda1b9e7 MD5 | raw file
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
  4. ** Contact: http://www.qt-project.org/legal
  5. **
  6. ** This file is part of the tools applications of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and Digia. For licensing terms and
  14. ** conditions see http://qt.digia.com/licensing. For further information
  15. ** use the contact form at http://qt.digia.com/contact-us.
  16. **
  17. ** GNU Lesser General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU Lesser
  19. ** General Public License version 2.1 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPL included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 2.1 requirements
  23. ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  24. **
  25. ** In addition, as a special exception, Digia gives you certain additional
  26. ** rights. These rights are described in the Digia Qt LGPL Exception
  27. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  28. **
  29. ** GNU General Public License Usage
  30. ** Alternatively, this file may be used under the terms of the GNU
  31. ** General Public License version 3.0 as published by the Free Software
  32. ** Foundation and appearing in the file LICENSE.GPL included in the
  33. ** packaging of this file. Please review the following information to
  34. ** ensure the GNU General Public License version 3.0 requirements will be
  35. ** met: http://www.gnu.org/copyleft/gpl.html.
  36. **
  37. **
  38. ** $QT_END_LICENSE$
  39. **
  40. ****************************************************************************/
  41. #include "qdom.h"
  42. #include "qxmlstream.h"
  43. #include "qdocindexfiles.h"
  44. #include "qdoctagfiles.h"
  45. #include "config.h"
  46. #include "qdocdatabase.h"
  47. #include "location.h"
  48. #include "atom.h"
  49. #include "generator.h"
  50. #include <qdebug.h>
  51. #include <algorithm>
  52. QT_BEGIN_NAMESPACE
  53. /*!
  54. \class QDocIndexFiles
  55. This class handles qdoc index files.
  56. */
  57. QDocIndexFiles* QDocIndexFiles::qdocIndexFiles_ = NULL;
  58. /*!
  59. Constructs the singleton QDocIndexFiles.
  60. */
  61. QDocIndexFiles::QDocIndexFiles()
  62. : gen_( 0 )
  63. {
  64. qdb_ = QDocDatabase::qdocDB();
  65. }
  66. /*!
  67. Destroys the singleton QDocIndexFiles.
  68. */
  69. QDocIndexFiles::~QDocIndexFiles()
  70. {
  71. qdb_ = 0;
  72. }
  73. /*!
  74. Creates the singleton. Allows only one instance of the class
  75. to be created. Returns a pointer to the singleton.
  76. */
  77. QDocIndexFiles* QDocIndexFiles::qdocIndexFiles()
  78. {
  79. if (!qdocIndexFiles_)
  80. qdocIndexFiles_ = new QDocIndexFiles;
  81. return qdocIndexFiles_;
  82. }
  83. /*!
  84. Destroys the singleton.
  85. */
  86. void QDocIndexFiles::destroyQDocIndexFiles()
  87. {
  88. if (qdocIndexFiles_) {
  89. delete qdocIndexFiles_;
  90. qdocIndexFiles_ = 0;
  91. }
  92. }
  93. /*!
  94. Reads and parses the list of index files in \a indexFiles.
  95. */
  96. void QDocIndexFiles::readIndexes(const QStringList& indexFiles)
  97. {
  98. foreach (const QString& indexFile, indexFiles) {
  99. QString msg = "Loading index file: " + indexFile;
  100. Location::logToStdErr(msg);
  101. readIndexFile(indexFile);
  102. }
  103. }
  104. /*!
  105. Reads and parses the index file at \a path.
  106. */
  107. void QDocIndexFiles::readIndexFile(const QString& path)
  108. {
  109. QFile file(path);
  110. if (file.open(QFile::ReadOnly)) {
  111. QDomDocument document;
  112. document.setContent(&file);
  113. file.close();
  114. QDomElement indexElement = document.documentElement();
  115. // Generate a relative URL between the install dir and the index file
  116. // when the -installdir command line option is set.
  117. QString indexUrl;
  118. if (Config::installDir.isEmpty()) {
  119. indexUrl = indexElement.attribute("url", QString());
  120. }
  121. else {
  122. // Use a fake directory, since we will copy the output to a sub directory of
  123. // installDir when using "make install". This is just for a proper relative path.
  124. //QDir installDir(path.section('/', 0, -3) + "/outputdir");
  125. QDir installDir(path.section('/', 0, -3) + '/' + Generator::outputSubdir());
  126. indexUrl = installDir.relativeFilePath(path).section('/', 0, -2);
  127. }
  128. project_ = indexElement.attribute("project", QString());
  129. basesList_.clear();
  130. relatedList_.clear();
  131. // Scan all elements in the XML file, constructing a map that contains
  132. // base classes for each class found.
  133. QDomElement child = indexElement.firstChildElement();
  134. while (!child.isNull()) {
  135. readIndexSection(child, qdb_->treeRoot(), indexUrl);
  136. child = child.nextSiblingElement();
  137. }
  138. // Now that all the base classes have been found for this index,
  139. // arrange them into an inheritance hierarchy.
  140. resolveIndex();
  141. }
  142. }
  143. /*!
  144. Read a <section> element from the index file and create the
  145. appropriate node(s).
  146. */
  147. void QDocIndexFiles::readIndexSection(const QDomElement& element,
  148. InnerNode* parent,
  149. const QString& indexUrl)
  150. {
  151. QString name = element.attribute("name");
  152. QString href = element.attribute("href");
  153. Node* node;
  154. Location location;
  155. QString filePath;
  156. int lineNo = 0;
  157. if (element.hasAttribute("filepath")) {
  158. filePath = element.attribute("filepath", QString());
  159. lineNo = element.attribute("lineno", QString()).toInt();
  160. }
  161. if (element.nodeName() == "namespace") {
  162. node = new NamespaceNode(parent, name);
  163. if (!indexUrl.isEmpty())
  164. location = Location(indexUrl + QLatin1Char('/') + name.toLower() + ".html");
  165. else if (!indexUrl.isNull())
  166. location = Location(name.toLower() + ".html");
  167. }
  168. else if (element.nodeName() == "class") {
  169. node = new ClassNode(parent, name);
  170. basesList_.append(QPair<ClassNode*,QString>(static_cast<ClassNode*>(node),
  171. element.attribute("bases")));
  172. if (!indexUrl.isEmpty())
  173. location = Location(indexUrl + QLatin1Char('/') + name.toLower() + ".html");
  174. else if (!indexUrl.isNull())
  175. location = Location(name.toLower() + ".html");
  176. bool abstract = false;
  177. if (element.attribute("abstract") == "true")
  178. abstract = true;
  179. node->setAbstract(abstract);
  180. }
  181. else if ((element.nodeName() == "qmlclass") ||
  182. ((element.nodeName() == "page") && (element.attribute("subtype") == "qmlclass"))) {
  183. QmlClassNode* qcn = new QmlClassNode(parent, name);
  184. qcn->setTitle(element.attribute("title"));
  185. QString qmlModuleName = element.attribute("qml-module-name");
  186. if (!qmlModuleName.isEmpty())
  187. qdb_->addToQmlModule(qmlModuleName, qcn);
  188. bool abstract = false;
  189. if (element.attribute("abstract") == "true")
  190. abstract = true;
  191. qcn->setAbstract(abstract);
  192. QString qmlFullBaseName = element.attribute("qml-base-type");
  193. if (!qmlFullBaseName.isEmpty())
  194. qcn->setQmlBaseName(qmlFullBaseName);
  195. if (element.hasAttribute("location"))
  196. name = element.attribute("location", QString());
  197. if (!indexUrl.isEmpty())
  198. location = Location(indexUrl + QLatin1Char('/') + name);
  199. else if (!indexUrl.isNull())
  200. location = Location(name);
  201. node = qcn;
  202. }
  203. else if (element.nodeName() == "qmlbasictype") {
  204. QmlBasicTypeNode* qbtn = new QmlBasicTypeNode(parent, name);
  205. qbtn->setTitle(element.attribute("title"));
  206. if (element.hasAttribute("location"))
  207. name = element.attribute("location", QString());
  208. if (!indexUrl.isEmpty())
  209. location = Location(indexUrl + QLatin1Char('/') + name);
  210. else if (!indexUrl.isNull())
  211. location = Location(name);
  212. node = qbtn;
  213. }
  214. else if (element.nodeName() == "qmlpropertygroup") {
  215. QmlClassNode* qcn = static_cast<QmlClassNode*>(parent);
  216. QmlPropertyGroupNode* qpgn = new QmlPropertyGroupNode(qcn, name);
  217. if (element.hasAttribute("location"))
  218. name = element.attribute("location", QString());
  219. if (!indexUrl.isEmpty())
  220. location = Location(indexUrl + QLatin1Char('/') + name);
  221. else if (!indexUrl.isNull())
  222. location = Location(name);
  223. node = qpgn;
  224. }
  225. else if (element.nodeName() == "qmlproperty") {
  226. QString type = element.attribute("type");
  227. bool attached = false;
  228. if (element.attribute("attached") == "true")
  229. attached = true;
  230. bool readonly = false;
  231. if (element.attribute("writable") == "false")
  232. readonly = true;
  233. QmlPropertyNode* qpn = 0;
  234. if (parent->type() == Node::Document) {
  235. QmlClassNode* qcn = static_cast<QmlClassNode*>(parent);
  236. qpn = new QmlPropertyNode(qcn, name, type, attached);
  237. }
  238. else if (parent->type() == Node::QmlPropertyGroup) {
  239. QmlPropertyGroupNode* qpgn = static_cast<QmlPropertyGroupNode*>(parent);
  240. qpn = new QmlPropertyNode(qpgn, name, type, attached);
  241. }
  242. qpn->setReadOnly(readonly);
  243. node = qpn;
  244. }
  245. else if ((element.nodeName() == "qmlmethod") ||
  246. (element.nodeName() == "qmlsignal") ||
  247. (element.nodeName() == "qmlsignalhandler")) {
  248. Node::Type t = Node::QmlMethod;
  249. if (element.nodeName() == "qmlsignal")
  250. t = Node::QmlSignal;
  251. else if (element.nodeName() == "qmlsignalhandler")
  252. t = Node::QmlSignalHandler;
  253. bool attached = false;
  254. FunctionNode* fn = new FunctionNode(t, parent, name, attached);
  255. node = fn;
  256. }
  257. else if (element.nodeName() == "page") {
  258. Node::SubType subtype;
  259. Node::PageType ptype = Node::NoPageType;
  260. QString attr = element.attribute("subtype");
  261. if (attr == "example") {
  262. subtype = Node::Example;
  263. ptype = Node::ExamplePage;
  264. }
  265. else if (attr == "header") {
  266. subtype = Node::HeaderFile;
  267. ptype = Node::ApiPage;
  268. }
  269. else if (attr == "file") {
  270. subtype = Node::File;
  271. ptype = Node::NoPageType;
  272. }
  273. else if (attr == "group") {
  274. subtype = Node::Group;
  275. ptype = Node::OverviewPage;
  276. }
  277. else if (attr == "module") {
  278. subtype = Node::Module;
  279. ptype = Node::OverviewPage;
  280. }
  281. else if (attr == "qmlmodule") {
  282. subtype = Node::QmlModule;
  283. ptype = Node::OverviewPage;
  284. }
  285. else if (attr == "page") {
  286. subtype = Node::Page;
  287. ptype = Node::ArticlePage;
  288. }
  289. else if (attr == "externalpage") {
  290. subtype = Node::ExternalPage;
  291. ptype = Node::ArticlePage;
  292. }
  293. else if (attr == "qmlclass") {
  294. subtype = Node::QmlClass;
  295. ptype = Node::ApiPage;
  296. }
  297. else if (attr == "qmlbasictype") {
  298. subtype = Node::QmlBasicType;
  299. ptype = Node::ApiPage;
  300. }
  301. else
  302. return;
  303. DocNode* docNode = 0;
  304. if (subtype == Node::QmlModule) {
  305. QString t = element.attribute("qml-module-name") + " " +
  306. element.attribute("qml-module-version");
  307. docNode = qdb_->addQmlModule(t);
  308. }
  309. else
  310. docNode = new DocNode(parent, name, subtype, ptype);
  311. docNode->setTitle(element.attribute("title"));
  312. if (element.hasAttribute("location"))
  313. name = element.attribute("location", QString());
  314. if (!indexUrl.isEmpty())
  315. location = Location(indexUrl + QLatin1Char('/') + name);
  316. else if (!indexUrl.isNull())
  317. location = Location(name);
  318. node = docNode;
  319. }
  320. else if (element.nodeName() == "enum") {
  321. EnumNode* enumNode = new EnumNode(parent, name);
  322. if (!indexUrl.isEmpty())
  323. location = Location(indexUrl + QLatin1Char('/') + parent->name().toLower() + ".html");
  324. else if (!indexUrl.isNull())
  325. location = Location(parent->name().toLower() + ".html");
  326. QDomElement child = element.firstChildElement("value");
  327. while (!child.isNull()) {
  328. EnumItem item(child.attribute("name"), child.attribute("value"));
  329. enumNode->addItem(item);
  330. child = child.nextSiblingElement("value");
  331. }
  332. node = enumNode;
  333. }
  334. else if (element.nodeName() == "typedef") {
  335. node = new TypedefNode(parent, name);
  336. if (!indexUrl.isEmpty())
  337. location = Location(indexUrl + QLatin1Char('/') + parent->name().toLower() + ".html");
  338. else if (!indexUrl.isNull())
  339. location = Location(parent->name().toLower() + ".html");
  340. }
  341. else if (element.nodeName() == "property") {
  342. node = new PropertyNode(parent, name);
  343. if (!indexUrl.isEmpty())
  344. location = Location(indexUrl + QLatin1Char('/') + parent->name().toLower() + ".html");
  345. else if (!indexUrl.isNull())
  346. location = Location(parent->name().toLower() + ".html");
  347. }
  348. else if (element.nodeName() == "function") {
  349. FunctionNode::Virtualness virt;
  350. if (element.attribute("virtual") == "non")
  351. virt = FunctionNode::NonVirtual;
  352. else if (element.attribute("virtual") == "impure")
  353. virt = FunctionNode::ImpureVirtual;
  354. else if (element.attribute("virtual") == "pure")
  355. virt = FunctionNode::PureVirtual;
  356. else
  357. return;
  358. FunctionNode::Metaness meta;
  359. if (element.attribute("meta") == "plain")
  360. meta = FunctionNode::Plain;
  361. else if (element.attribute("meta") == "signal")
  362. meta = FunctionNode::Signal;
  363. else if (element.attribute("meta") == "slot")
  364. meta = FunctionNode::Slot;
  365. else if (element.attribute("meta") == "constructor")
  366. meta = FunctionNode::Ctor;
  367. else if (element.attribute("meta") == "destructor")
  368. meta = FunctionNode::Dtor;
  369. else if (element.attribute("meta") == "macro")
  370. meta = FunctionNode::MacroWithParams;
  371. else if (element.attribute("meta") == "macrowithparams")
  372. meta = FunctionNode::MacroWithParams;
  373. else if (element.attribute("meta") == "macrowithoutparams")
  374. meta = FunctionNode::MacroWithoutParams;
  375. else
  376. return;
  377. FunctionNode* functionNode = new FunctionNode(parent, name);
  378. functionNode->setReturnType(element.attribute("return"));
  379. functionNode->setVirtualness(virt);
  380. functionNode->setMetaness(meta);
  381. functionNode->setConst(element.attribute("const") == "true");
  382. functionNode->setStatic(element.attribute("static") == "true");
  383. functionNode->setOverload(element.attribute("overload") == "true");
  384. if (element.hasAttribute("relates")
  385. && element.attribute("relates") != parent->name()) {
  386. relatedList_.append(
  387. QPair<FunctionNode*,QString>(functionNode,
  388. element.attribute("relates")));
  389. }
  390. QDomElement child = element.firstChildElement("parameter");
  391. while (!child.isNull()) {
  392. // Do not use the default value for the parameter; it is not
  393. // required, and has been known to cause problems.
  394. Parameter parameter(child.attribute("left"),
  395. child.attribute("right"),
  396. child.attribute("name"),
  397. QString()); // child.attribute("default")
  398. functionNode->addParameter(parameter);
  399. child = child.nextSiblingElement("parameter");
  400. }
  401. node = functionNode;
  402. if (!indexUrl.isEmpty())
  403. location = Location(indexUrl + QLatin1Char('/') + parent->name().toLower() + ".html");
  404. else if (!indexUrl.isNull())
  405. location = Location(parent->name().toLower() + ".html");
  406. }
  407. else if (element.nodeName() == "variable") {
  408. node = new VariableNode(parent, name);
  409. if (!indexUrl.isEmpty())
  410. location = Location(indexUrl + QLatin1Char('/') + parent->name().toLower() + ".html");
  411. else if (!indexUrl.isNull())
  412. location = Location(parent->name().toLower() + ".html");
  413. }
  414. else if (element.nodeName() == "keyword") {
  415. qdb_->insertTarget(name, TargetRec::Keyword, parent, 1);
  416. return;
  417. }
  418. else if (element.nodeName() == "target") {
  419. qdb_->insertTarget(name, TargetRec::Target, parent, 2);
  420. return;
  421. }
  422. else if (element.nodeName() == "contents") {
  423. qdb_->insertTarget(name, TargetRec::Contents, parent, 3);
  424. return;
  425. }
  426. else
  427. return;
  428. QString access = element.attribute("access");
  429. if (access == "public")
  430. node->setAccess(Node::Public);
  431. else if (access == "protected")
  432. node->setAccess(Node::Protected);
  433. else if ((access == "private") || (access == "internal"))
  434. node->setAccess(Node::Private);
  435. else
  436. node->setAccess(Node::Public);
  437. if ((element.nodeName() != "page") &&
  438. (element.nodeName() != "qmlclass") &&
  439. (element.nodeName() != "qmlbasictype")) {
  440. QString threadSafety = element.attribute("threadsafety");
  441. if (threadSafety == "non-reentrant")
  442. node->setThreadSafeness(Node::NonReentrant);
  443. else if (threadSafety == "reentrant")
  444. node->setThreadSafeness(Node::Reentrant);
  445. else if (threadSafety == "thread safe")
  446. node->setThreadSafeness(Node::ThreadSafe);
  447. else
  448. node->setThreadSafeness(Node::UnspecifiedSafeness);
  449. }
  450. else
  451. node->setThreadSafeness(Node::UnspecifiedSafeness);
  452. QString status = element.attribute("status");
  453. if (status == "compat")
  454. node->setStatus(Node::Compat);
  455. else if (status == "obsolete")
  456. node->setStatus(Node::Obsolete);
  457. else if (status == "deprecated")
  458. node->setStatus(Node::Obsolete);
  459. else if (status == "preliminary")
  460. node->setStatus(Node::Preliminary);
  461. else if (status == "commendable")
  462. node->setStatus(Node::Commendable);
  463. else if (status == "internal")
  464. node->setStatus(Node::Internal);
  465. else if (status == "main")
  466. node->setStatus(Node::Main);
  467. else
  468. node->setStatus(Node::Commendable);
  469. QString moduleName = element.attribute("module");
  470. if (!moduleName.isEmpty())
  471. node->setModuleName(moduleName);
  472. if (!href.isEmpty()) {
  473. if (node->isExternalPage())
  474. node->setUrl(href);
  475. else if (!indexUrl.isEmpty())
  476. node->setUrl(indexUrl + QLatin1Char('/') + href);
  477. }
  478. QString since = element.attribute("since");
  479. if (!since.isEmpty()) {
  480. node->setSince(since);
  481. }
  482. QString groupsAttr = element.attribute("groups");
  483. if (!groupsAttr.isEmpty()) {
  484. QStringList groupNames = groupsAttr.split(",");
  485. for (int i=0; i<groupNames.size(); ++i) {
  486. DocNode* dn = qdb_->findGroup(groupNames[i]);
  487. if (dn) {
  488. dn->addMember(node);
  489. }
  490. else {
  491. qDebug() << "NODE:" << node->name() << "GROUPS:" << groupNames;
  492. qDebug() << "DID NOT FIND GROUP:" << dn->name() << "for:" << node->name();
  493. }
  494. }
  495. }
  496. // Create some content for the node.
  497. QSet<QString> emptySet;
  498. Location t(filePath);
  499. if (!filePath.isEmpty()) {
  500. t.setLineNo(lineNo);
  501. node->setLocation(t);
  502. location = t;
  503. }
  504. Doc doc(location, location, " ", emptySet, emptySet); // placeholder
  505. node->setDoc(doc);
  506. node->setIndexNodeFlag();
  507. node->setOutputSubdirectory(project_.toLower());
  508. QString briefAttr = element.attribute("brief");
  509. if (!briefAttr.isEmpty()) {
  510. node->setReconstitutedBrief(briefAttr);
  511. }
  512. if (node->isInnerNode()) {
  513. InnerNode* inner = static_cast<InnerNode*>(node);
  514. QDomElement child = element.firstChildElement();
  515. while (!child.isNull()) {
  516. if (element.nodeName() == "class") {
  517. readIndexSection(child, inner, indexUrl);
  518. }
  519. else if (element.nodeName() == "qmlclass") {
  520. readIndexSection(child, inner, indexUrl);
  521. }
  522. else if (element.nodeName() == "page") {
  523. readIndexSection(child, inner, indexUrl);
  524. }
  525. else if (element.nodeName() == "namespace" && !name.isEmpty()) {
  526. // The root node in the index is a namespace with an empty name.
  527. readIndexSection(child, inner, indexUrl);
  528. }
  529. else {
  530. readIndexSection(child, parent, indexUrl);
  531. }
  532. child = child.nextSiblingElement();
  533. }
  534. }
  535. }
  536. /*!
  537. */
  538. void QDocIndexFiles::resolveIndex()
  539. {
  540. QPair<ClassNode*,QString> pair;
  541. foreach (pair, basesList_) {
  542. foreach (const QString& base, pair.second.split(QLatin1Char(','))) {
  543. Node* n = qdb_->treeRoot()->findChildNodeByNameAndType(base, Node::Class);
  544. if (n) {
  545. pair.first->addBaseClass(Node::Public, static_cast<ClassNode*>(n));
  546. }
  547. }
  548. }
  549. QPair<FunctionNode*,QString> relatedPair;
  550. foreach (relatedPair, relatedList_) {
  551. Node* n = qdb_->treeRoot()->findChildNodeByNameAndType(relatedPair.second, Node::Class);
  552. if (n)
  553. relatedPair.first->setRelates(static_cast<ClassNode*>(n));
  554. }
  555. }
  556. /*!
  557. Normally this is used for writing the \e groups attribute,
  558. but it can be used for writing any attribute with a list
  559. value that comes from some subset of the members of \a n.
  560. \note The members of \a n are \e not the children of \a n.
  561. The names we want to include are the names of the members
  562. of \a n that have node type \a t and node subtype \a st.
  563. The attribute name is \a attr. The names are joined with
  564. the space character and written with \a writer.
  565. */
  566. void QDocIndexFiles::writeMembersAttribute(QXmlStreamWriter& writer,
  567. const InnerNode* n,
  568. Node::Type t,
  569. Node::SubType st,
  570. const QString& attr)
  571. {
  572. const NodeList& members = n->members();
  573. if (!members.isEmpty()) {
  574. QStringList names;
  575. NodeList::ConstIterator i = members.constBegin();
  576. while (i != members.constEnd()) {
  577. if ((*i)->type() == t && (*i)->subType() == st)
  578. names.append((*i)->name());
  579. ++i;
  580. }
  581. if (!names.isEmpty())
  582. writer.writeAttribute(attr, names.join(","));
  583. }
  584. }
  585. /*!
  586. Generate the index section with the given \a writer for the \a node
  587. specified, returning true if an element was written; otherwise returns
  588. false.
  589. */
  590. bool QDocIndexFiles::generateIndexSection(QXmlStreamWriter& writer,
  591. Node* node,
  592. bool generateInternalNodes)
  593. {
  594. /*
  595. Don't include index nodes in a new index file. Or DITA map nodes.
  596. */
  597. if (node->isIndexNode() || node->subType() == Node::DitaMap)
  598. return false;
  599. QString nodeName;
  600. QString qmlModuleName;
  601. QString qmlModuleVersion;
  602. QString qmlFullBaseName;
  603. switch (node->type()) {
  604. case Node::Namespace:
  605. nodeName = "namespace";
  606. break;
  607. case Node::Class:
  608. nodeName = "class";
  609. break;
  610. case Node::Document:
  611. nodeName = "page";
  612. if (node->subType() == Node::QmlClass) {
  613. nodeName = "qmlclass";
  614. QmlModuleNode* qmn = node->qmlModule();
  615. if (qmn)
  616. qmlModuleName = qmn->qmlModuleName();
  617. qmlFullBaseName = node->qmlFullBaseName();
  618. }
  619. else if (node->subType() == Node::QmlBasicType)
  620. nodeName = "qmlbasictype";
  621. break;
  622. case Node::Enum:
  623. nodeName = "enum";
  624. break;
  625. case Node::Typedef:
  626. nodeName = "typedef";
  627. break;
  628. case Node::Property:
  629. nodeName = "property";
  630. break;
  631. case Node::Function:
  632. nodeName = "function";
  633. break;
  634. case Node::Variable:
  635. nodeName = "variable";
  636. break;
  637. case Node::QmlProperty:
  638. nodeName = "qmlproperty";
  639. break;
  640. case Node::QmlPropertyGroup:
  641. nodeName = "qmlpropertygroup";
  642. break;
  643. case Node::QmlSignal:
  644. nodeName = "qmlsignal";
  645. break;
  646. case Node::QmlSignalHandler:
  647. nodeName = "qmlsignalhandler";
  648. break;
  649. case Node::QmlMethod:
  650. nodeName = "qmlmethod";
  651. break;
  652. default:
  653. return false;
  654. }
  655. QString access;
  656. switch (node->access()) {
  657. case Node::Public:
  658. access = "public";
  659. break;
  660. case Node::Protected:
  661. access = "protected";
  662. break;
  663. case Node::Private:
  664. #if 0
  665. // Do not include private non-internal nodes in the index.
  666. // (Internal public and protected nodes are marked as private
  667. // by qdoc. We can check their internal status to determine
  668. // whether they were really private to begin with.)
  669. if (node->status() == Node::Internal && generateInternalNodes)
  670. access = "internal";
  671. else
  672. return false;
  673. #endif
  674. {
  675. access = "private";
  676. bool b = generateInternalNodes;
  677. if (b)
  678. b = false;
  679. }
  680. break;
  681. default:
  682. return false;
  683. }
  684. QString objName = node->name();
  685. // Special case: only the root node should have an empty name.
  686. if (objName.isEmpty() && node != qdb_->treeRoot())
  687. return false;
  688. writer.writeStartElement(nodeName);
  689. QXmlStreamAttributes attributes;
  690. if (node->type() != Node::Document) {
  691. QString threadSafety;
  692. switch (node->threadSafeness()) {
  693. case Node::NonReentrant:
  694. threadSafety = "non-reentrant";
  695. break;
  696. case Node::Reentrant:
  697. threadSafety = "reentrant";
  698. break;
  699. case Node::ThreadSafe:
  700. threadSafety = "thread safe";
  701. break;
  702. case Node::UnspecifiedSafeness:
  703. default:
  704. threadSafety = "unspecified";
  705. break;
  706. }
  707. writer.writeAttribute("threadsafety", threadSafety);
  708. }
  709. QString status;
  710. switch (node->status()) {
  711. case Node::Compat:
  712. status = "compat";
  713. break;
  714. case Node::Obsolete:
  715. status = "obsolete";
  716. break;
  717. case Node::Deprecated:
  718. status = "obsolete";
  719. break;
  720. case Node::Preliminary:
  721. status = "preliminary";
  722. break;
  723. case Node::Commendable:
  724. status = "commendable";
  725. break;
  726. case Node::Internal:
  727. status = "internal";
  728. break;
  729. case Node::Main:
  730. default:
  731. status = "main";
  732. break;
  733. }
  734. writer.writeAttribute("name", objName);
  735. if (node->isQmlModule()) {
  736. qmlModuleName = node->qmlModuleName();
  737. qmlModuleVersion = node->qmlModuleVersion();
  738. }
  739. if (!qmlModuleName.isEmpty()) {
  740. writer.writeAttribute("qml-module-name", qmlModuleName);
  741. if (node->isQmlModule())
  742. writer.writeAttribute("qml-module-version", qmlModuleVersion);
  743. if (!qmlFullBaseName.isEmpty())
  744. writer.writeAttribute("qml-base-type", qmlFullBaseName);
  745. }
  746. QString href;
  747. if (!node->isExternalPage()) {
  748. QString fullName = node->fullDocumentName();
  749. if (fullName != objName)
  750. writer.writeAttribute("fullname", fullName);
  751. if (Generator::useOutputSubdirs())
  752. href = node->outputSubdirectory();
  753. if (!href.isEmpty())
  754. href.append(QLatin1Char('/'));
  755. href.append(gen_->fullDocumentLocation(node));
  756. }
  757. else
  758. href = node->name();
  759. if (node->isQmlNode()) {
  760. InnerNode* p = node->parent();
  761. if (p) {
  762. if (p->isQmlPropertyGroup())
  763. p = p->parent();
  764. if (p && p->isQmlType() && p->isAbstract())
  765. href.clear();
  766. }
  767. }
  768. if (!href.isEmpty())
  769. writer.writeAttribute("href", href);
  770. writer.writeAttribute("access", access);
  771. writer.writeAttribute("status", status);
  772. if (node->isAbstract())
  773. writer.writeAttribute("abstract", "true");
  774. if (!node->location().fileName().isEmpty())
  775. writer.writeAttribute("location", node->location().fileName());
  776. if (!node->location().filePath().isEmpty()) {
  777. writer.writeAttribute("filepath", node->location().filePath());
  778. writer.writeAttribute("lineno", QString("%1").arg(node->location().lineNo()));
  779. }
  780. if (!node->since().isEmpty()) {
  781. writer.writeAttribute("since", node->since());
  782. }
  783. QString brief = node->doc().briefText().toString();
  784. switch (node->type()) {
  785. case Node::Class:
  786. {
  787. // Classes contain information about their base classes.
  788. const ClassNode* classNode = static_cast<const ClassNode*>(node);
  789. QList<RelatedClass> bases = classNode->baseClasses();
  790. QSet<QString> baseStrings;
  791. foreach (const RelatedClass& related, bases) {
  792. ClassNode* baseClassNode = related.node;
  793. baseStrings.insert(baseClassNode->name());
  794. }
  795. writer.writeAttribute("bases", QStringList(baseStrings.toList()).join(","));
  796. if (!node->moduleName().isEmpty())
  797. writer.writeAttribute("module", node->moduleName());
  798. writeMembersAttribute(writer, classNode, Node::Document, Node::Group, "groups");
  799. if (!brief.isEmpty())
  800. writer.writeAttribute("brief", brief);
  801. }
  802. break;
  803. case Node::Namespace:
  804. {
  805. const NamespaceNode* namespaceNode = static_cast<const NamespaceNode*>(node);
  806. if (!namespaceNode->moduleName().isEmpty())
  807. writer.writeAttribute("module", namespaceNode->moduleName());
  808. writeMembersAttribute(writer, namespaceNode, Node::Document, Node::Group, "groups");
  809. if (!brief.isEmpty())
  810. writer.writeAttribute("brief", brief);
  811. }
  812. break;
  813. case Node::Document:
  814. {
  815. /*
  816. Document nodes (such as manual pages) contain subtypes,
  817. titles and other attributes.
  818. */
  819. bool writeModuleName = false;
  820. const DocNode* docNode = static_cast<const DocNode*>(node);
  821. switch (docNode->subType()) {
  822. case Node::Example:
  823. writer.writeAttribute("subtype", "example");
  824. writeModuleName = true;
  825. break;
  826. case Node::HeaderFile:
  827. writer.writeAttribute("subtype", "header");
  828. writeModuleName = true;
  829. break;
  830. case Node::File:
  831. writer.writeAttribute("subtype", "file");
  832. break;
  833. case Node::Group:
  834. {
  835. writer.writeAttribute("subtype", "group");
  836. writer.writeAttribute("seen", docNode->wasSeen() ? "true" : "false");
  837. // Groups contain information about their group members.
  838. const NodeList& members = docNode->members();
  839. QStringList names;
  840. foreach (const Node* member, members) {
  841. names.append(member->name());
  842. }
  843. writer.writeAttribute("members", names.join(","));
  844. writeModuleName = true;
  845. }
  846. break;
  847. case Node::Module:
  848. writer.writeAttribute("subtype", "module");
  849. break;
  850. case Node::QmlModule:
  851. writer.writeAttribute("subtype", "qmlmodule");
  852. break;
  853. case Node::Page:
  854. writer.writeAttribute("subtype", "page");
  855. writeModuleName = true;
  856. break;
  857. case Node::ExternalPage:
  858. writer.writeAttribute("subtype", "externalpage");
  859. break;
  860. case Node::QmlClass:
  861. //writer.writeAttribute("subtype", "qmlclass");
  862. break;
  863. case Node::QmlBasicType:
  864. //writer.writeAttribute("subtype", "qmlbasictype");
  865. break;
  866. default:
  867. break;
  868. }
  869. writer.writeAttribute("title", docNode->title());
  870. writer.writeAttribute("fulltitle", docNode->fullTitle());
  871. writer.writeAttribute("subtitle", docNode->subTitle());
  872. if (!node->moduleName().isEmpty() && writeModuleName) {
  873. writer.writeAttribute("module", node->moduleName());
  874. }
  875. writeMembersAttribute(writer, docNode, Node::Document, Node::Group, "groups");
  876. if (!brief.isEmpty())
  877. writer.writeAttribute("brief", brief);
  878. }
  879. break;
  880. case Node::Function:
  881. {
  882. /*
  883. Function nodes contain information about the type of
  884. function being described.
  885. */
  886. const FunctionNode* functionNode = static_cast<const FunctionNode*>(node);
  887. switch (functionNode->virtualness()) {
  888. case FunctionNode::NonVirtual:
  889. writer.writeAttribute("virtual", "non");
  890. break;
  891. case FunctionNode::ImpureVirtual:
  892. writer.writeAttribute("virtual", "impure");
  893. break;
  894. case FunctionNode::PureVirtual:
  895. writer.writeAttribute("virtual", "pure");
  896. break;
  897. default:
  898. break;
  899. }
  900. switch (functionNode->metaness()) {
  901. case FunctionNode::Plain:
  902. writer.writeAttribute("meta", "plain");
  903. break;
  904. case FunctionNode::Signal:
  905. writer.writeAttribute("meta", "signal");
  906. break;
  907. case FunctionNode::Slot:
  908. writer.writeAttribute("meta", "slot");
  909. break;
  910. case FunctionNode::Ctor:
  911. writer.writeAttribute("meta", "constructor");
  912. break;
  913. case FunctionNode::Dtor:
  914. writer.writeAttribute("meta", "destructor");
  915. break;
  916. case FunctionNode::MacroWithParams:
  917. writer.writeAttribute("meta", "macrowithparams");
  918. break;
  919. case FunctionNode::MacroWithoutParams:
  920. writer.writeAttribute("meta", "macrowithoutparams");
  921. break;
  922. default:
  923. break;
  924. }
  925. writer.writeAttribute("const", functionNode->isConst()?"true":"false");
  926. writer.writeAttribute("static", functionNode->isStatic()?"true":"false");
  927. writer.writeAttribute("overload", functionNode->isOverload()?"true":"false");
  928. if (functionNode->isOverload())
  929. writer.writeAttribute("overload-number", QString::number(functionNode->overloadNumber()));
  930. if (functionNode->relates())
  931. writer.writeAttribute("relates", functionNode->relates()->name());
  932. const PropertyNode* propertyNode = functionNode->associatedProperty();
  933. if (propertyNode)
  934. writer.writeAttribute("associated-property", propertyNode->name());
  935. writer.writeAttribute("type", functionNode->returnType());
  936. if (!brief.isEmpty())
  937. writer.writeAttribute("brief", brief);
  938. }
  939. break;
  940. case Node::QmlProperty:
  941. {
  942. QmlPropertyNode* qpn = static_cast<QmlPropertyNode*>(node);
  943. writer.writeAttribute("type", qpn->dataType());
  944. writer.writeAttribute("attached", qpn->isAttached() ? "true" : "false");
  945. writer.writeAttribute("writable", qpn->isWritable(qdb_) ? "true" : "false");
  946. if (!brief.isEmpty())
  947. writer.writeAttribute("brief", brief);
  948. }
  949. break;
  950. case Node::QmlPropertyGroup:
  951. {
  952. if (!brief.isEmpty())
  953. writer.writeAttribute("brief", brief);
  954. }
  955. break;
  956. case Node::Property:
  957. {
  958. const PropertyNode* propertyNode = static_cast<const PropertyNode*>(node);
  959. writer.writeAttribute("type", propertyNode->dataType());
  960. if (!brief.isEmpty())
  961. writer.writeAttribute("brief", brief);
  962. foreach (const Node* fnNode, propertyNode->getters()) {
  963. if (fnNode) {
  964. const FunctionNode* functionNode = static_cast<const FunctionNode*>(fnNode);
  965. writer.writeStartElement("getter");
  966. writer.writeAttribute("name", functionNode->name());
  967. writer.writeEndElement(); // getter
  968. }
  969. }
  970. foreach (const Node* fnNode, propertyNode->setters()) {
  971. if (fnNode) {
  972. const FunctionNode* functionNode = static_cast<const FunctionNode*>(fnNode);
  973. writer.writeStartElement("setter");
  974. writer.writeAttribute("name", functionNode->name());
  975. writer.writeEndElement(); // setter
  976. }
  977. }
  978. foreach (const Node* fnNode, propertyNode->resetters()) {
  979. if (fnNode) {
  980. const FunctionNode* functionNode = static_cast<const FunctionNode*>(fnNode);
  981. writer.writeStartElement("resetter");
  982. writer.writeAttribute("name", functionNode->name());
  983. writer.writeEndElement(); // resetter
  984. }
  985. }
  986. foreach (const Node* fnNode, propertyNode->notifiers()) {
  987. if (fnNode) {
  988. const FunctionNode* functionNode = static_cast<const FunctionNode*>(fnNode);
  989. writer.writeStartElement("notifier");
  990. writer.writeAttribute("name", functionNode->name());
  991. writer.writeEndElement(); // notifier
  992. }
  993. }
  994. }
  995. break;
  996. case Node::Variable:
  997. {
  998. const VariableNode* variableNode = static_cast<const VariableNode*>(node);
  999. writer.writeAttribute("type", variableNode->dataType());
  1000. writer.writeAttribute("static", variableNode->isStatic() ? "true" : "false");
  1001. if (!brief.isEmpty())
  1002. writer.writeAttribute("brief", brief);
  1003. }
  1004. break;
  1005. default:
  1006. break;
  1007. }
  1008. // Inner nodes and function nodes contain child nodes of some sort, either
  1009. // actual child nodes or function parameters. For these, we close the
  1010. // opening tag, create child elements, then add a closing tag for the
  1011. // element. Elements for all other nodes are closed in the opening tag.
  1012. if (node->isInnerNode()) {
  1013. const InnerNode* inner = static_cast<const InnerNode*>(node);
  1014. // For internal pages, we canonicalize the target, keyword and content
  1015. // item names so that they can be used by qdoc for other sets of
  1016. // documentation.
  1017. // The reason we do this here is that we don't want to ruin
  1018. // externally composed indexes, containing non-qdoc-style target names
  1019. // when reading in indexes.
  1020. if (inner->doc().hasTargets()) {
  1021. bool external = false;
  1022. if (inner->type() == Node::Document) {
  1023. const DocNode* docNode = static_cast<const DocNode*>(inner);
  1024. if (docNode->subType() == Node::ExternalPage)
  1025. external = true;
  1026. }
  1027. foreach (const Atom* target, inner->doc().targets()) {
  1028. QString targetName = target->string();
  1029. if (!external)
  1030. targetName = Doc::canonicalTitle(targetName);
  1031. writer.writeStartElement("target");
  1032. writer.writeAttribute("name", targetName);
  1033. writer.writeEndElement(); // target
  1034. }
  1035. }
  1036. if (inner->doc().hasKeywords()) {
  1037. foreach (const Atom* keyword, inner->doc().keywords()) {
  1038. writer.writeStartElement("keyword");
  1039. writer.writeAttribute("name", Doc::canonicalTitle(keyword->string()));
  1040. writer.writeEndElement(); // keyword
  1041. }
  1042. }
  1043. if (inner->doc().hasTableOfContents()) {
  1044. for (int i = 0; i < inner->doc().tableOfContents().size(); ++i) {
  1045. Atom* item = inner->doc().tableOfContents()[i];
  1046. int level = inner->doc().tableOfContentsLevels()[i];
  1047. QString title = Text::sectionHeading(item).toString();
  1048. writer.writeStartElement("contents");
  1049. writer.writeAttribute("name", Doc::canonicalTitle(title));
  1050. writer.writeAttribute("title", title);
  1051. writer.writeAttribute("level", QString::number(level));
  1052. writer.writeEndElement(); // contents
  1053. }
  1054. }
  1055. }
  1056. else if (node->type() == Node::Function) {
  1057. const FunctionNode* functionNode = static_cast<const FunctionNode*>(node);
  1058. // Write a signature attribute for convenience.
  1059. QStringList signatureList;
  1060. QStringList resolvedParameters;
  1061. foreach (const Parameter& parameter, functionNode->parameters()) {
  1062. QString leftType = parameter.leftType();
  1063. const Node* leftNode = qdb_->findNode(parameter.leftType().split("::"),
  1064. 0,
  1065. SearchBaseClasses|NonFunction);
  1066. if (!leftNode || leftNode->type() != Node::Typedef) {
  1067. leftNode = qdb_->findNode(parameter.leftType().split("::"),
  1068. node->parent(),
  1069. SearchBaseClasses|NonFunction);
  1070. }
  1071. if (leftNode && leftNode->type() == Node::Typedef) {
  1072. if (leftNode->type() == Node::Typedef) {
  1073. const TypedefNode* typedefNode = static_cast<const TypedefNode*>(leftNode);
  1074. if (typedefNode->associatedEnum()) {
  1075. leftType = "QFlags<" + typedefNode->associatedEnum()->fullDocumentName() +
  1076. QLatin1Char('>');
  1077. }
  1078. }
  1079. else
  1080. leftType = leftNode->fullDocumentName();
  1081. }
  1082. resolvedParameters.append(leftType);
  1083. signatureList.append(leftType + QLatin1Char(' ') + parameter.name());
  1084. }
  1085. QString signature = functionNode->name() + QLatin1Char('(') + signatureList.join(", ") +
  1086. QLatin1Char(')');
  1087. if (functionNode->isConst())
  1088. signature += " const";
  1089. writer.writeAttribute("signature", signature);
  1090. for (int i = 0; i < functionNode->parameters().size(); ++i) {
  1091. Parameter parameter = functionNode->parameters()[i];
  1092. writer.writeStartElement("parameter");
  1093. writer.writeAttribute("left", resolvedParameters[i]);
  1094. writer.writeAttribute("right", parameter.rightType());
  1095. writer.writeAttribute("name", parameter.name());
  1096. writer.writeAttribute("default", parameter.defaultValue());
  1097. writer.writeEndElement(); // parameter
  1098. }
  1099. }
  1100. else if (node->type() == Node::Enum) {
  1101. const EnumNode* enumNode = static_cast<const EnumNode*>(node);
  1102. if (enumNode->flagsType()) {
  1103. writer.writeAttribute("typedef",enumNode->flagsType()->fullDocumentName());
  1104. }
  1105. foreach (const EnumItem& item, enumNode->items()) {
  1106. writer.writeStartElement("value");
  1107. writer.writeAttribute("name", item.name());
  1108. writer.writeAttribute("value", item.value());
  1109. writer.writeEndElement(); // value
  1110. }
  1111. }
  1112. else if (node->type() == Node::Typedef) {
  1113. const TypedefNode* typedefNode = static_cast<const TypedefNode*>(node);
  1114. if (typedefNode->associatedEnum()) {
  1115. writer.writeAttribute("enum",typedefNode->associatedEnum()->fullDocumentName());
  1116. }
  1117. }
  1118. return true;
  1119. }
  1120. /*!
  1121. Returns \c true if the node \a n1 is less than node \a n2. The
  1122. comparison is performed by comparing properties of the nodes
  1123. in order of increasing complexity.
  1124. */
  1125. bool compareNodes(const Node* n1, const Node* n2)
  1126. {
  1127. // Private nodes can occur in any order since they won't normally be
  1128. // written to the index.
  1129. if (n1->access() == Node::Private && n2->access() == Node::Private)
  1130. return false;
  1131. if (n1->location().filePath() < n2->location().filePath())
  1132. return true;
  1133. else if (n1->location().filePath() > n2->location().filePath())
  1134. return false;
  1135. if (n1->type() < n2->type())
  1136. return true;
  1137. else if (n1->type() > n2->type())
  1138. return false;
  1139. if (n1->name() < n2->name())
  1140. return true;
  1141. else if (n1->name() > n2->name())
  1142. return false;
  1143. if (n1->access() < n2->access())
  1144. return true;
  1145. else if (n1->access() > n2->access())
  1146. return false;
  1147. if (n1->type() == Node::Function && n2->type() == Node::Function) {
  1148. const FunctionNode* f1 = static_cast<const FunctionNode*>(n1);
  1149. const FunctionNode* f2 = static_cast<const FunctionNode*>(n2);
  1150. if (f1->isConst() < f2->isConst())
  1151. return true;
  1152. else if (f1->isConst() > f2->isConst())
  1153. return false;
  1154. if (f1->signature() < f2->signature())
  1155. return true;
  1156. else if (f1->signature() > f2->signature())
  1157. return false;
  1158. }
  1159. if (n1->type() == Node::Document && n2->type() == Node::Document) {
  1160. const DocNode* f1 = static_cast<const DocNode*>(n1);
  1161. const DocNode* f2 = static_cast<const DocNode*>(n2);
  1162. if (f1->fullTitle() < f2->fullTitle())
  1163. return true;
  1164. else if (f1->fullTitle() > f2->fullTitle())
  1165. return false;
  1166. }
  1167. return false;
  1168. }
  1169. /*!
  1170. Generate index sections for the child nodes of the given \a node
  1171. using the \a writer specified. If \a generateInternalNodes is true,
  1172. nodes marked as internal will be included in the index; otherwise,
  1173. they will be omitted.
  1174. */
  1175. void QDocIndexFiles::generateIndexSections(QXmlStreamWriter& writer,
  1176. Node* node,
  1177. bool generateInternalNodes)
  1178. {
  1179. /*
  1180. Note that the groups are written after all the other nodes.
  1181. */
  1182. if (!node->isGroup() && generateIndexSection(writer, node, generateInternalNodes)) {
  1183. if (node->isInnerNode()) {
  1184. const InnerNode* inner = static_cast<const InnerNode*>(node);
  1185. NodeList cnodes = inner->childNodes();
  1186. std::sort(cnodes.begin(), cnodes.end(), compareNodes);
  1187. foreach (Node* child, cnodes) {
  1188. /*
  1189. Don't generate anything for a collision node. We want
  1190. children of collision nodes in the index, but leaving
  1191. out the parent collision page will make searching for
  1192. nodes easier.
  1193. */
  1194. if (child->subType() == Node::Collision) {
  1195. const InnerNode* pgn = static_cast<const InnerNode*>(child);
  1196. foreach (Node* c, pgn->childNodes()) {
  1197. generateIndexSections(writer, c, generateInternalNodes);
  1198. }
  1199. }
  1200. else
  1201. generateIndexSections(writer, child, generateInternalNodes);
  1202. }
  1203. }
  1204. writer.writeEndElement();
  1205. }
  1206. }
  1207. /*!
  1208. Outputs an index file.
  1209. */
  1210. void QDocIndexFiles::generateIndex(const QString& fileName,
  1211. const QString& url,
  1212. const QString& title,
  1213. Generator* g,
  1214. bool generateInternalNodes)
  1215. {
  1216. QFile file(fileName);
  1217. if (!file.open(QFile::WriteOnly | QFile::Text))
  1218. return;
  1219. QString msg = "Writing index file: " + fileName;
  1220. Location::logToStdErr(msg);
  1221. gen_ = g;
  1222. QXmlStreamWriter writer(&file);
  1223. writer.setAutoFormatting(true);
  1224. writer.writeStartDocument();
  1225. writer.writeDTD("<!DOCTYPE QDOCINDEX>");
  1226. writer.writeStartElement("INDEX");
  1227. writer.writeAttribute("url", url);
  1228. writer.writeAttribute("title", title);
  1229. writer.writeAttribute("version", qdb_->version());
  1230. writer.writeAttribute("project", g->config()->getString(CONFIG_PROJECT));
  1231. generateIndexSections(writer, qdb_->treeRoot(), generateInternalNodes);
  1232. /*
  1233. We wait until the end of the index file to output the group elements.
  1234. By waiting until the end, when we read each group element, its members
  1235. will have already been created. It is then only necessary to create
  1236. the group page and add each member to its member list.
  1237. */
  1238. const DocNodeMap& groups = qdb_->groups();
  1239. if (!groups.isEmpty()) {
  1240. DocNodeMap::ConstIterator g = groups.constBegin();
  1241. while (g != groups.constEnd()) {
  1242. i