From c6ecedee1d37dbf3f7ef1d5b77b597febada8ac6 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Thu, 6 Jan 2011 19:31:39 -0200 Subject: Add support for extra documentation in module table of contents. This is needed to fix the bug bug#560 ("Lack of QtCore.Signal documentation") --- generators/qtdoc/qtdocgenerator.cpp | 24 +++++++++++++++++++++++- generators/qtdoc/qtdocgenerator.h | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/generators/qtdoc/qtdocgenerator.cpp b/generators/qtdoc/qtdocgenerator.cpp index f5f5626f3..ff88c5e38 100644 --- a/generators/qtdoc/qtdocgenerator.cpp +++ b/generators/qtdoc/qtdocgenerator.cpp @@ -1344,7 +1344,8 @@ void QtDocGenerator::finishGeneration() QMap::iterator it = m_packages.begin(); for (; it != m_packages.end(); ++it) { - FileOut output(outputDirectory() + '/' + QString(it.key()).replace(".", "/") + "/index.rst"); + QString outputDir = outputDirectory() + '/' + QString(it.key()).replace(".", "/"); + FileOut output(outputDir + "/index.rst"); QTextStream& s = output.stream; s << ".. module:: " << it.key() << endl << endl; @@ -1358,6 +1359,25 @@ void QtDocGenerator::finishGeneration() Indentation indentation(INDENT); s << INDENT << ":maxdepth: 1" << endl << endl; + // Search for extra-sections + if (!m_extraSectionDir.isEmpty()) { + QDir extraSectionDir(m_extraSectionDir); + QStringList fileList = extraSectionDir.entryList(QStringList() << (it.key() + "*.rst"), QDir::Files); + QStringList::iterator it2 = fileList.begin(); + for (; it2 != fileList.end(); ++it2) { + QString origFileName(*it2); + it2->remove(0, it.key().count() + 1); + QString newFilePath = outputDir + '/' + *it2; + if (QFile::exists(newFilePath)) + QFile::remove(newFilePath); + if (!QFile::copy(m_extraSectionDir + '/' + origFileName, newFilePath)) { + ReportHandler::warning("Error copying extra doc " + (m_extraSectionDir + '/' + origFileName) + + " to " + newFilePath); + } + } + it.value().append(fileList); + } + qSort(it.value()); foreach (QString className, it.value()) { s << INDENT << className << endl; @@ -1382,6 +1402,7 @@ bool QtDocGenerator::doSetup(const QMap& args) m_libSourceDir = args.value("library-source-dir"); m_docDataDir = args.value("documentation-data-dir"); m_codeSnippetDir = args.value("documentation-code-snippets-dir", m_libSourceDir); + m_extraSectionDir = args.value("documentation-extra-sections-dir"); if (m_libSourceDir.isEmpty() || m_docDataDir.isEmpty()) { ReportHandler::warning("Documentation data dir and/or Qt source dir not informed, " @@ -1401,6 +1422,7 @@ QMap QtDocGenerator::options() const options.insert("library-source-dir", "Directory where library source code is located"); options.insert("documentation-data-dir", "Directory with XML files generated by documentation tool (qdoc3 or Doxygen)"); options.insert("documentation-code-snippets-dir", "Directory used to search code snippets used by the documentation"); + options.insert("documentation-extra-sections-dir", "Directory used to search for extra documentation sections"); return options; } diff --git a/generators/qtdoc/qtdocgenerator.h b/generators/qtdoc/qtdocgenerator.h index 327e90561..672dd8551 100644 --- a/generators/qtdoc/qtdocgenerator.h +++ b/generators/qtdoc/qtdocgenerator.h @@ -213,6 +213,7 @@ private: QString m_docDataDir; QString m_libSourceDir; QString m_codeSnippetDir; + QString m_extraSectionDir; QStringList m_functionList; QMap m_packages; QtDocParser* m_docParser; -- cgit v1.2.3