diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-12-16 13:35:48 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-12-16 13:35:48 +0000 |
| commit | c938b3116bc2554c92ed61fce3ae31208d89f7d0 (patch) | |
| tree | 6727e777e33bf008571e1d879aeba492dbf379c8 /doc/doxyfilter.cpp | |
| parent | d6329ec2dff647a03cc956cf9daab9c949a61965 (diff) | |
| download | qxmpp-c938b3116bc2554c92ed61fce3ae31208d89f7d0.tar.gz | |
improve Doxyfile generation
Diffstat (limited to 'doc/doxyfilter.cpp')
| -rw-r--r-- | doc/doxyfilter.cpp | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/doc/doxyfilter.cpp b/doc/doxyfilter.cpp index aa2b3051..3dfbd333 100644 --- a/doc/doxyfilter.cpp +++ b/doc/doxyfilter.cpp @@ -22,9 +22,11 @@ */ #include <cstdlib> +#include <iostream> #include <QCoreApplication> #include <QFile> +#include <QProcess> #include <QRegExp> #include <QTextStream> @@ -37,25 +39,36 @@ static void setField(QString &code, const QString &name, const QString &value) QString("\\1 %1").arg(value)); } +static void usage() { + QTextStream output(stderr); + output << "Usage:" << endl; + output << " doxyfilter Generate documentation" << endl; + output << " doxyfilter -g Generate Doxyfile" << endl; + output << " doxyfilter <sourcefile> Filter the given file's code" << endl; +} + int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); - if (argc != 2) { - qWarning("Usage: doxyfilter <sourcefile>"); - return 1; - } - // read source code - QFile source(QString::fromLocal8Bit(argv[1])); - if (!source.open(QIODevice::ReadOnly)) { - qWarning("Could not open %s", qPrintable(source.fileName())); + if (argc == 1) + return QProcess::execute("doxygen"); + else if (argc != 2) { + usage(); return 1; } - QString code = QString::fromUtf8(source.readAll()); - source.close(); - if (source.fileName() == "Doxyfile") { - // adjust doxyfile + if (!strcmp(argv[1], "-g")) { + // generate default Doxyfile + QProcess process; + process.start("doxygen", QStringList() << "-g" << "-"); + if (!process.waitForFinished()) { + qWarning("Could not run doxygen"); + return 1; + } + QString code = QString::fromUtf8(process.readAll()); + + // adjust Doxyfile setField(code, "ALPHABETICAL_INDEX", "NO"); setField(code, "EXCLUDE_PATTERNS", "*/moc_*"); setField(code, "FULL_PATH_NAMES", "NO"); @@ -71,20 +84,34 @@ int main(int argc, char *argv[]) QString::number(QXMPP_VERSION & 0xff))); // write doxyfile - if (!source.open(QIODevice::WriteOnly)) { - qWarning("Could not write to %s", qPrintable(source.fileName())); + QFile output("Doxyfile"); + if (!output.open(QIODevice::WriteOnly)) { + qWarning("Could not write to %s", qPrintable(output.fileName())); return 1; } - source.write(code.toUtf8()); + output.write(code.toUtf8()); + output.close(); + + } else if (!strcmp(argv[1], "-h")) { + usage(); + return 0; + } else { + // read source code + QFile source(QString::fromLocal8Bit(argv[1])); + if (!source.open(QIODevice::ReadOnly)) { + qWarning("Could not open %s", qPrintable(source.fileName())); + return 1; + } + QString code = QString::fromUtf8(source.readAll()); source.close(); - } - else { + // add links for XEPs code.replace(QRegExp("(XEP-([0-9]{4}))"), "<a href=\"http://xmpp.org/extensions/xep-\\2.html\">\\1</a>"); QTextStream output(stdout); output << code; } + return 0; } |
