From 2e95910564bab2fb1b298dac253f790668a2cf0d Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 5 Aug 2010 11:51:23 +0200 Subject: 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. (cherry picked from commit d4dceca5dcd9252e09a421b65b318a7178049cd1) --- tools/qdoc3/config.h | 4 +- tools/qdoc3/ditaxmlgenerator.cpp | 1 - tools/qdoc3/htmlgenerator.cpp | 127 +++++++++++++++++++-------------------- tools/qdoc3/htmlgenerator.h | 9 ++- 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 34c2565..b0c3150 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() << " \n"; - out() << "\n"; - } - else if (offlineDocs == true) - { - out() << "\n"; - } - else if (creatorDocs == true) - { - out() << "\n"; - } - else - { - out() << "\n"; - } + + switch (application) { + case Online: + out() << " \n"; + out() << " \n"; + out() << "\n"; + break; + case Assistant: + out() << "\n"; + break; + case Creator: + out() << "\n"; + break; + default: + out() << "\n"; + } out() << "\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 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); } -- cgit v0.12