diff options
author | Martin Smith <martin.smith@nokia.com> | 2010-08-05 09:51:23 (GMT) |
---|---|---|
committer | Martin Smith <martin.smith@nokia.com> | 2010-08-05 09:51:23 (GMT) |
commit | d4dceca5dcd9252e09a421b65b318a7178049cd1 (patch) | |
tree | c267ad8f78c98bd24834d3cd7b2788f08d55add2 /tools | |
parent | 3d0b7905b18ada0e22e77b9c6670069dfd454adc (diff) | |
download | Qt-d4dceca5dcd9252e09a421b65b318a7178049cd1.zip Qt-d4dceca5dcd9252e09a421b65b318a7178049cd1.tar.gz Qt-d4dceca5dcd9252e09a421b65b318a7178049cd1.tar.bz2 |
qdoc: Cleaned up the application option specification and use.
The flags allowed on the command line are now:
-online (default), -base, -assistant (same as -base),
and -creator. If you don't specify one of these, you
see a warning in the error output telling you that it
didn't find an application flag and that it generated
online docs by defualt.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qdoc3/config.h | 4 | ||||
-rw-r--r-- | tools/qdoc3/ditaxmlgenerator.cpp | 1 | ||||
-rw-r--r-- | tools/qdoc3/htmlgenerator.cpp | 127 | ||||
-rw-r--r-- | tools/qdoc3/htmlgenerator.h | 9 | ||||
-rw-r--r-- | tools/qdoc3/main.cpp | 70 |
5 files changed, 95 insertions, 116 deletions
diff --git a/tools/qdoc3/config.h b/tools/qdoc3/config.h index 7665f1a..335a0d6 100644 --- a/tools/qdoc3/config.h +++ b/tools/qdoc3/config.h @@ -143,9 +143,7 @@ class Config #define CONFIG_MACRO "macro" #define CONFIG_NATURALLANGUAGE "naturallanguage" #define CONFIG_OBSOLETELINKS "obsoletelinks" -#define CONFIG_ONLINE "online" -#define CONFIG_OFFLINE "offline" -#define CONFIG_CREATOR "creator" +#define CONFIG_APPLICATION "application" #define CONFIG_OUTPUTDIR "outputdir" #define CONFIG_OUTPUTENCODING "outputencoding" #define CONFIG_OUTPUTLANGUAGE "outputlanguage" diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp index 4789c67..816ab9f 100644 --- a/tools/qdoc3/ditaxmlgenerator.cpp +++ b/tools/qdoc3/ditaxmlgenerator.cpp @@ -440,7 +440,6 @@ void DitaXmlGenerator::initializeGenerator(const Config &config) DITAXMLGENERATOR_GENERATEMACREFS); project = config.getString(CONFIG_PROJECT); - offlineDocs = !config.getBool(CONFIG_ONLINE); projectDescription = config.getString(CONFIG_DESCRIPTION); if (projectDescription.isEmpty() && !project.isEmpty()) projectDescription = project + " Reference Documentation"; diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp index 723f516..b1a8336 100644 --- a/tools/qdoc3/htmlgenerator.cpp +++ b/tools/qdoc3/htmlgenerator.cpp @@ -219,9 +219,7 @@ HtmlGenerator::HtmlGenerator() inTableHeader(false), numTableRows(0), threeColumnEnumValueTable(true), - offlineDocs(false), - onlineDocs(false), - creatorDocs(true), + application(Online), funcLeftParen("\\S(\\()"), myTree(0), slow(false), @@ -290,11 +288,17 @@ void HtmlGenerator::initializeGenerator(const Config &config) project = config.getString(CONFIG_PROJECT); - onlineDocs = config.getBool(CONFIG_ONLINE); - - offlineDocs = config.getBool(CONFIG_OFFLINE); - - creatorDocs = config.getBool(CONFIG_CREATOR); + QString app = config.getString(CONFIG_APPLICATION); + if (app == "online") + application = Online; + else if (app == "creator") + application = Creator; + else if (app == "assistant") + application = Assistant; + else if (app == "base") + application = Assistant; + else + application = Online; projectDescription = config.getString(CONFIG_DESCRIPTION); if (projectDescription.isEmpty() && !project.isEmpty()) @@ -1811,9 +1815,8 @@ void HtmlGenerator::generateHeader(const QString& title, // Setting some additional style sheet related details depending on configuration (e.g. online/offline) - - if(onlineDocs==true) // onlineDocs is for the web - { + switch (application) { + case Online: // Browser spec styles out() << " <!--[if IE]>\n"; out() << "<meta name=\"MSSmartTagsPreventParsing\" content=\"true\">\n"; @@ -1832,22 +1835,19 @@ void HtmlGenerator::generateHeader(const QString& title, out() << "</head>\n"; // CheckEmptyAndLoadList activating search out() << "<body class=\"\" onload=\"CheckEmptyAndLoadList();\">\n"; - } - else if (offlineDocs == true) // offlineDocs is for ??? - { + break; + case Assistant: out() << "</head>\n"; - out() << "<body class=\"offline \">\n"; // offline - } - else if (creatorDocs == true) // creatorDocs is for Assistant/Creator - { + out() << "<body class=\"offline \">\n"; + break; + case Creator: out() << "</head>\n"; out() << "<body class=\"offline narrow creator\">\n"; // offline narrow - } - // default -- not used except if one forgets to set any of the above settings to true - else - { + break; + default: out() << "</head>\n"; - out() << "<body>\n"; + out() << "<body>\n"; + break; } #ifdef GENERATE_MAC_REFS @@ -1855,31 +1855,27 @@ void HtmlGenerator::generateHeader(const QString& title, generateMacRef(node, marker); #endif - - if(onlineDocs==true) // onlineDocs is for the web - { + switch (application) { + case Online: out() << QString(postHeader).replace("\\" + COMMAND_VERSION, myTree->version()); generateBreadCrumbs(title,node,marker); out() << QString(postPostHeader).replace("\\" + COMMAND_VERSION, myTree->version()); - } - else if (offlineDocs == true) // offlineDocs is for ??? - { + break; + case Assistant: out() << QString(creatorPostHeader).replace("\\" + COMMAND_VERSION, myTree->version()); generateBreadCrumbs(title,node,marker); - out() << QString(creatorPostPostHeader).replace("\\" + COMMAND_VERSION, myTree->version()); - } - else if (creatorDocs == true) // creatorDocs is for Assistant/Creator - { + out() << QString(creatorPostPostHeader).replace("\\" + COMMAND_VERSION, myTree->version()); + break; + case Creator: out() << QString(creatorPostHeader).replace("\\" + COMMAND_VERSION, myTree->version()); generateBreadCrumbs(title,node,marker); out() << QString(creatorPostPostHeader).replace("\\" + COMMAND_VERSION, myTree->version()); - } - // default -- not used except if one forgets to set any of the above settings to true - else - { + break; + default: // default -- not used except if one forgets to set any of the above settings to true out() << QString(creatorPostHeader).replace("\\" + COMMAND_VERSION, myTree->version()); generateBreadCrumbs(title,node,marker); - out() << QString(creatorPostPostHeader).replace("\\" + COMMAND_VERSION, myTree->version()); + out() << QString(creatorPostPostHeader).replace("\\" + COMMAND_VERSION, myTree->version()); + break; } #if 0 // Removed for new doc format. MWS @@ -1914,34 +1910,33 @@ void HtmlGenerator::generateFooter(const Node *node) out() << QString(footer).replace("\\" + COMMAND_VERSION, myTree->version()) << QString(address).replace("\\" + COMMAND_VERSION, myTree->version()); - - if (onlineDocs == true) - { - out() << " <script src=\"scripts/functions.js\" type=\"text/javascript\"></script>\n"; - out() << " <!-- <script type=\"text/javascript\">\n"; - out() << " var _gaq = _gaq || [];\n"; - out() << " _gaq.push(['_setAccount', 'UA-4457116-5']);\n"; - out() << " _gaq.push(['_trackPageview']);\n"; - out() << " (function() {\n"; - out() << " var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n"; - out() << " ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n"; - out() << " var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n"; - out() << " })();\n"; - out() << " </script> -->\n"; - out() << "</body>\n"; - } - else if (offlineDocs == true) - { - out() << "</body>\n"; - } - else if (creatorDocs == true) - { - out() << "</body>\n"; - } - else - { - out() << "</body>\n"; - } + + switch (application) { + case Online: + out() << " <script src=\"scripts/functions.js\" type=\"text/javascript\"></script>\n"; + out() << " <!-- <script type=\"text/javascript\">\n"; + out() << " var _gaq = _gaq || [];\n"; + out() << " _gaq.push(['_setAccount', 'UA-4457116-5']);\n"; + out() << " _gaq.push(['_trackPageview']);\n"; + out() << " (function() {\n"; + out() << " var ga = document.createElement('script'); "; + out() << "ga.type = 'text/javascript'; ga.async = true;\n"; + out() << " ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + "; + out() << "'.google-analytics.com/ga.js';\n"; + out() << " var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n"; + out() << " })();\n"; + out() << " </script> -->\n"; + out() << "</body>\n"; + break; + case Assistant: + out() << "</body>\n"; + break; + case Creator: + out() << "</body>\n"; + break; + default: + out() << "</body>\n"; + } out() << "</html>\n"; } diff --git a/tools/qdoc3/htmlgenerator.h b/tools/qdoc3/htmlgenerator.h index d92c349..ec79896 100644 --- a/tools/qdoc3/htmlgenerator.h +++ b/tools/qdoc3/htmlgenerator.h @@ -95,6 +95,11 @@ class HtmlGenerator : public PageGenerator LastSinceType }; + enum Application { + Online, + Assistant, + Creator}; + public: HtmlGenerator(); ~HtmlGenerator(); @@ -294,9 +299,7 @@ class HtmlGenerator : public PageGenerator bool inTableHeader; int numTableRows; bool threeColumnEnumValueTable; - bool onlineDocs; - bool offlineDocs; - bool creatorDocs; + Application application; QString link; QStringList sectionNumber; QRegExp funcLeftParen; diff --git a/tools/qdoc3/main.cpp b/tools/qdoc3/main.cpp index 47a4b67..38b76a4 100644 --- a/tools/qdoc3/main.cpp +++ b/tools/qdoc3/main.cpp @@ -105,8 +105,7 @@ static bool showInternal = false; static bool obsoleteLinks = false; static QStringList defines; static QHash<QString, Tree *> trees; -static QString application = "base"; //application -static bool applicationArg = 0; //if 1, then the argument is provided and it will override the qdocconf file +static QString appArg; // application /*! Find the Tree for language \a lang and return a pointer to it. @@ -194,36 +193,25 @@ static void processQdocconfFile(const QString &fileName) config.load(fileName); /* - Set the application to which qdoc will create the output. - The three applications are: - base: simple, basic html output. Best suited for offline viewing - creator: additional formatting. - online: full-featured online version with search and links to Qt topics - - Note: This will override the offline, online, creator defines. + Set the application to which qdoc will create the output. + The three applications are: + + base or assistant: simple, basic html output + for offline viewing in the Assistant application. + + creator: additional formatting for viewing in + the Creator application. + + online: full-featured online version with search and + links to Qt topics */ - if(applicationArg == false){ - - QString appConfig = config.getString(CONFIG_APPLICATION); - if (!appConfig.isEmpty()){ - application = appConfig; - } - } - if(application == "online"){ - config.setStringList(CONFIG_ONLINE, QStringList("true")); - config.setStringList(CONFIG_OFFLINE, QStringList("false")); - config.setStringList(CONFIG_CREATOR, QStringList("false")); - } - else if(application == "creator"){ - config.setStringList(CONFIG_ONLINE, QStringList("false")); - config.setStringList(CONFIG_OFFLINE, QStringList("true")); - config.setStringList(CONFIG_CREATOR, QStringList("false")); - } - else if(application == "base"){ - config.setStringList(CONFIG_ONLINE, QStringList("false")); - config.setStringList(CONFIG_OFFLINE, QStringList("false")); - config.setStringList(CONFIG_CREATOR, QStringList("true")); + if (appArg.isEmpty()) { + qDebug() << "Warning: Application flag not specified on" + << "command line. Options are -assistant, -creator," + << "and -online (default)."; + appArg = "online"; } + config.setStringList(CONFIG_APPLICATION, QStringList(appArg)); /* Add the defines to the configuration variables. @@ -496,18 +484,14 @@ int main(int argc, char **argv) else if (opt == "-obsoletelinks") { obsoleteLinks = true; } - else if (opt == "-base") { - application = "base"; - applicationArg = true; - } - else if (opt == "-creator") { - application = "creator"; - applicationArg = true; - } - else if (opt == "-online") { - application = "online"; - applicationArg = true; - } + else if (opt == "-base") + appArg = "base"; + else if (opt == "-assistant") + appArg = "assistant"; + else if (opt == "-creator") + appArg = "creator"; + else if (opt == "-online") + appArg = "online"; else { qdocFiles.append(opt); } @@ -522,7 +506,7 @@ int main(int argc, char **argv) Main loop. */ foreach (QString qf, qdocFiles) { - qDebug() << "PROCESSING:" << qf; + //qDebug() << "PROCESSING:" << qf; processQdocconfFile(qf); } |