tools/qdoc3/generator.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
child 37 758a864f9613
--- a/tools/qdoc3/generator.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/tools/qdoc3/generator.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -42,7 +42,6 @@
 /*
   generator.cpp
 */
-#include <QtCore>
 #include <qdir.h>
 #include <qdebug.h>
 #include "codemarker.h"
@@ -67,6 +66,10 @@
 QStringList Generator::imageDirs;
 QStringList Generator::exampleDirs;
 QStringList Generator::exampleImgExts;
+QStringList Generator::scriptFiles;
+QStringList Generator::scriptDirs;
+QStringList Generator::styleFiles;
+QStringList Generator::styleDirs;
 QString Generator::outDir;
 QString Generator::project;
 
@@ -125,10 +128,20 @@
         if (!dirInfo.mkdir(outDir + "/images/used-in-examples"))
             config.lastLocation().fatal(tr("Cannot create output directory '%1'")
                                         .arg(outDir + "/images/used-in-examples"));
+        if (!dirInfo.mkdir(outDir + "/scripts"))
+            config.lastLocation().fatal(tr("Cannot create output directory '%1'")
+                                        .arg(outDir + "/scripts"));
+        if (!dirInfo.mkdir(outDir + "/style"))
+            config.lastLocation().fatal(tr("Cannot create output directory '%1'")
+                                        .arg(outDir + "/style"));
     }
 
     imageFiles = config.getStringList(CONFIG_IMAGES);
     imageDirs = config.getStringList(CONFIG_IMAGEDIRS);
+    scriptFiles = config.getStringList(CONFIG_SCRIPTS);
+    scriptDirs = config.getStringList(CONFIG_SCRIPTDIRS);
+    styleFiles = config.getStringList(CONFIG_STYLES);
+    styleDirs = config.getStringList(CONFIG_STYLEDIRS);
     exampleDirs = config.getStringList(CONFIG_EXAMPLEDIRS);
     exampleImgExts = config.getStringList(CONFIG_EXAMPLES + Config::dot +
                                           CONFIG_IMAGEEXTENSIONS);
@@ -166,6 +179,47 @@
                                      "/images");
                 ++e;
             }
+
+            QStringList noExts;
+            QStringList scripts =
+                config.getStringList(CONFIG_SCRIPTS+Config::dot+(*g)->format());
+            e = scripts.begin();
+            while (e != scripts.end()) {
+                QString userFriendlyFilePath;
+                QString filePath = Config::findFile(config.lastLocation(),
+                                                    scriptFiles,
+                                                    scriptDirs,
+                                                    *e,
+                                                    noExts,
+                                                    userFriendlyFilePath);
+                if (!filePath.isEmpty())
+                    Config::copyFile(config.lastLocation(),
+                                     filePath,
+                                     userFriendlyFilePath,
+                                     (*g)->outputDir() +
+                                     "/scripts");
+                ++e;
+            }
+
+            QStringList styles =
+                config.getStringList(CONFIG_STYLES+Config::dot+(*g)->format());
+            e = styles.begin();
+            while (e != styles.end()) {
+                QString userFriendlyFilePath;
+                QString filePath = Config::findFile(config.lastLocation(),
+                                                    styleFiles,
+                                                    styleDirs,
+                                                    *e,
+                                                    noExts,
+                                                    userFriendlyFilePath);
+                if (!filePath.isEmpty())
+                    Config::copyFile(config.lastLocation(),
+                                     filePath,
+                                     userFriendlyFilePath,
+                                     (*g)->outputDir() +
+                                     "/style");
+                ++e;
+            }
         }
         ++g;
     }
@@ -227,6 +281,7 @@
     imageFiles.clear();
     imageDirs.clear();
     outDir = "";
+    QmlClassNode::clear();
 }
 
 Generator *Generator::generatorForFormat(const QString& format)
@@ -322,11 +377,11 @@
     bool quiet = false;
 
     if (node->type() == Node::Function) {
-#if 0        
+#if 0
         const FunctionNode *func = (const FunctionNode *) node;
         if (func->isOverload() && func->metaness() != FunctionNode::Ctor)
             generateOverload(node, marker);
-#endif        
+#endif
     }
     else if (node->type() == Node::Fake) {
         const FakeNode *fake = static_cast<const FakeNode *>(node);
@@ -347,7 +402,7 @@
             if (func->reimplementedFrom() != 0)
                 generateReimplementedFrom(func, marker);
         }
-        
+
         if (!generateText(node->doc().body(), node, marker))
             if (node->isReimp())
                 return;
@@ -452,7 +507,7 @@
             // Now we put this at the top, before the other text.
             if (func->reimplementedFrom() != 0)
                 generateReimplementedFrom(func, marker);
-#endif            
+#endif
         }
     }
 
@@ -544,7 +599,7 @@
   example is being formatted. It outputs the list of source
   files comprising the example, and the list of images used
   by the example. The images are copied into a subtree of
-  \c{...doc/html/images/used-in-examples/...} 
+  \c{...doc/html/images/used-in-examples/...}
  */
 void Generator::generateFileList(const FakeNode* fake,
                                  CodeMarker* marker,
@@ -641,33 +696,6 @@
     }
 #endif
 
-void Generator::generateModuleWarning(const ClassNode *classe,
-                                      CodeMarker *marker)
-{
-    QString module = classe->moduleName();
-    if (!module.isEmpty()) {
-        Text text;
-        if (!editionModuleMap["DesktopLight"].contains(module)) {
-            text << Atom::ParaLeft
-                 << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
-                 << "This class is not part of the Qt GUI Framework Edition."
-                 << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD)
-                 << Atom::ParaRight;
-        }
-        else if (module == "Qt3Support") {
-            text << Atom::ParaLeft
-                 << Atom(Atom::FormattingLeft, ATOM_FORMATTING_BOLD)
-                 << "Note to Qt GUI Framework Edition users:"
-                 << Atom(Atom::FormattingRight, ATOM_FORMATTING_BOLD)
-                 << " This class is only available in the "
-                 << Atom(Atom::AutoLink, "Qt Full Framework Edition")
-                 << "." << Atom::ParaRight;
-        }
-
-        generateText(text, classe, marker);
-    }
-}
-
 QString Generator::indent(int level, const QString& markedCode)
 {
     if (level == 0)
@@ -973,7 +1001,7 @@
                 }
                 ++c;
             }
-            if (!exceptions) 
+            if (!exceptions)
                 text << ".";
             else if (threadSafeness == Node::Reentrant) {
                 if (nonreentrant.isEmpty()) {
@@ -1060,7 +1088,7 @@
     text << Atom::ParaLeft
          << "This function overloads ";
     QString t = node->name() + "()";
-    text << Atom::AutoLink << t 
+    text << Atom::AutoLink << t
          << Atom::ParaRight;
     generateText(text, node, marker);
 }
@@ -1213,6 +1241,35 @@
     }
 }
 
+void Generator::appendSortedQmlNames(Text& text,
+                                     const Node* base,
+                                     const NodeList& subs,
+                                     CodeMarker *marker)
+{
+    QMap<QString,Text> classMap;
+    int index = 0;
+
+#ifdef DEBUG_MULTIPLE_QDOCCONF_FILES
+    qDebug() << "Generator::appendSortedQmlNames():" << base->name() << "is inherited by...";
+#endif
+    for (int i = 0; i < subs.size(); ++i) {
+        Text t;
+#ifdef DEBUG_MULTIPLE_QDOCCONF_FILES
+        qDebug() << "    " << subs[i]->name();
+#endif
+        appendFullName(t, subs[i], base, marker);
+        classMap[t.toString().toLower()] = t;
+    }
+
+    QStringList names = classMap.keys();
+    names.sort();
+
+    foreach (const QString &name, names) {
+        text << classMap[name];
+        text << separator(index++, names.count());
+    }
+}
+
 int Generator::skipAtoms(const Atom *atom, Atom::Type type) const
 {
     int skipAhead = 0;