summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/docgen/doc.h67
-rw-r--r--client/docgen/docgen.cc162
-rw-r--r--client/docgen/docgen.pro104
-rw-r--r--client/docgen/generate.cc212
-rw-r--r--client/docgen/generate.h39
-rw-r--r--client/docgen/genimage.cc163
-rw-r--r--client/docgen/genimage.h35
-rw-r--r--client/docgen/parse.cc198
-rw-r--r--client/docgen/parse.h37
-rw-r--r--client/docgen/style.css108
10 files changed, 1125 insertions, 0 deletions
diff --git a/client/docgen/doc.h b/client/docgen/doc.h
new file mode 100644
index 0000000..fc400fc
--- /dev/null
+++ b/client/docgen/doc.h
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * doc.h
+ *
+ * Thu Mar 24 12:07:27 CET 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __PRACRO_DOC_H__
+#define __PRACRO_DOC_H__
+
+#include <QVector>
+#include <QString>
+
+class Parameter {
+public:
+ QString name;
+ QString description;
+};
+
+class Method {
+public:
+ QString name;
+ QString description;
+ QString returns;
+ QVector<Parameter> parameters;
+};
+
+class Attribute {
+public:
+ QString name;
+ QString description;
+};
+
+class Doc {
+public:
+ QString title;
+ QString name;
+ QString tag;
+ QString extends;
+ bool screenshot;
+ bool container;
+ QString description;
+ QVector<Attribute> attributes;
+ QVector<Method> methods;
+};
+
+#endif/*__PRACRO_DOC_H__*/
diff --git a/client/docgen/docgen.cc b/client/docgen/docgen.cc
new file mode 100644
index 0000000..e5a8bff
--- /dev/null
+++ b/client/docgen/docgen.cc
@@ -0,0 +1,162 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * docgen.cc
+ *
+ * Tue Mar 15 11:20:09 CET 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include <QApplication>
+#include <QDomNode>
+#include <QFont>
+#include <QFile>
+#include <QDir>
+#include <QMap>
+#include <QDate>
+
+#include <stdio.h>
+
+#include "doc.h"
+#include "parse.h"
+#include "generate.h"
+
+#define INPUT "../widgets"
+#define OUTPUT "html"
+
+QString output;
+
+QString header =
+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\""
+ " \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
+ "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
+ " <head>\n"
+ " <title>Pracro Widget Documentation</title>\n"
+ " <meta http-equiv=\"Content-Type\" content=\"text/html\"/>\n"
+ " <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/>\n"
+ " </head> \n"
+ " <body>\n";
+
+QString footer =
+ " </body>\n"
+ "</html>\n";
+
+void getInheritedAttributes(QMap<QString, QVector<Attribute> > &atts,
+ QMap<QString, Doc> &docs,
+ QString name)
+{
+ if(name == "" || atts.contains(name)) return;
+ atts[name] = docs[name].attributes;
+ getInheritedAttributes(atts, docs, docs[name].extends);
+}
+
+void getInheritedMethods(QMap<QString, QVector<Method> > &meths,
+ QMap<QString, Doc> &docs,
+ QString name)
+{
+ if(name == "" || meths.contains(name)) return;
+ meths[name] = docs[name].methods;
+ getInheritedMethods(meths, docs, docs[name].extends);
+}
+
+
+void writeDoc(QMap<QString, Doc> &docs, QString name)
+{
+ Doc doc = docs[name];
+
+ QMap<QString, QVector<Attribute> > atts;
+ getInheritedAttributes(atts, docs, doc.extends);
+
+ QMap<QString, QVector<Method> > meths;
+ getInheritedMethods(meths, docs, doc.extends);
+
+ QString out = generate(doc, meths, atts);
+
+ QFile::remove(output + "/" + name + ".html");
+ QFile ofile(output + "/" + name + ".html");
+ ofile.open(QIODevice::ReadWrite | QIODevice::Text);
+ ofile.write(header.toStdString().c_str(), header.length());
+ ofile.write(out.toStdString().c_str()), out.length();
+ ofile.write(footer.toStdString().c_str(), footer.length());
+ ofile.close();
+}
+
+void writeIndex(QMap<QString, Doc> &docs)
+{
+ QString out;
+
+ out += "<h1>Pracro "VERSION" Documentation</h1>\n";
+ out += "<h2>Overview</h2>\n";
+
+ out += "<ul>\n";
+ QMap<QString, Doc>::iterator i = docs.begin();
+ while(i != docs.end()) {
+ Doc &doc = *i;
+ out += "<li><a href=\""+doc.name+".html\">["+doc.name+"]</a> - "+
+ doc.title+"</li>\n";
+ i++;
+ }
+ out += "</ul>\n";
+
+ QFile::remove(output + "/index.html");
+ QFile ofile(output + "/index.html");
+ ofile.open(QIODevice::ReadWrite | QIODevice::Text);
+ ofile.write(header.toStdString().c_str());
+ ofile.write(out.toStdString().c_str());
+ ofile.write(footer.toStdString().c_str());
+ ofile.close();
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ output = OUTPUT;
+
+ QMap<QString, Doc> docs;
+
+ QDir d; d.mkdir(output);
+ QFile::remove(output + "/style.css");
+ QFile::copy("style.css", output + "/style.css");
+
+ QDir dir(INPUT);
+ QStringList filter; filter << "*.h";
+ dir.setNameFilters(filter);
+
+ if(!dir.exists()) return 1;
+ QStringList l = dir.entryList(QDir::Files);
+ foreach(QString file, l) {
+ Doc doc = parse(QString(INPUT) + "/" + file);
+ docs[doc.name] = doc;
+ }
+
+ writeIndex(docs);
+
+ QMap<QString, Doc>::iterator i = docs.begin();
+ while(i != docs.end()) {
+ QString name = i.key();
+ writeDoc(docs, name);
+ i++;
+ }
+
+ // return app.exec();
+ return 0;
+}
diff --git a/client/docgen/docgen.pro b/client/docgen/docgen.pro
new file mode 100644
index 0000000..d495439
--- /dev/null
+++ b/client/docgen/docgen.pro
@@ -0,0 +1,104 @@
+# -*- Makefile -*-
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += . .. ../widgets
+QT += core gui xml svg network sql
+RESOURCES += ../client.qrc
+
+include(../../VERSION)
+DEFINES+=VERSION=\\\"$$VERSION\\\"
+
+win32 {
+ LIBPATH += lua/lib
+ INCLUDEPATH += lua/include
+ LIBS += -llua51
+ DEFINES += HOST_WIN32
+}
+
+unix {
+ LIBS += -llua
+ LIBS += -lqjson
+}
+
+# Input
+SOURCES += \
+ docgen.cc \
+ genimage.cc \
+ generate.cc \
+ parse.cc \
+ ../debug.cc \
+ ../lua.cc \
+ ../luawidget.cc \
+ ../luadb.cc \
+ ../messagebox.cc \
+ ../macrowindow.cc \
+ ../collapser.cc \
+ ../netcom.cc \
+ ../resumewidget.cc \
+ ../mainwindow.cc \
+ ../macro.cc \
+ ../header.cc \
+ ../viewer.cc \
+ ../macrodrawer.cc \
+ ../widgets/common.cc \
+ ../widgets/widget.cc \
+ ../widgets/label.cc \
+ ../widgets/lineedit.cc \
+ ../widgets/multilist.cc \
+ ../widgets/textedit.cc \
+ ../widgets/button.cc \
+ ../widgets/combobox.cc \
+ ../widgets/datetime.cc \
+ ../widgets/listbox.cc \
+ ../widgets/frame.cc \
+ ../widgets/groupbox.cc \
+ ../widgets/radiobutton.cc \
+ ../widgets/radiobuttons.cc \
+ ../widgets/checkbox.cc \
+ ../widgets/checkgroupbox.cc \
+ ../widgets/window.cc \
+ ../widgets/altcombobox.cc \
+ ../widgets/metawidget.cc
+
+HEADERS += \
+ genimage.h \
+ generate.h \
+ parse.h \
+ doc.h \
+ ../debug.h \
+ ../lua.h \
+ ../luawidget.h \
+ ../luadb.h \
+ ../messagebox.h \
+ ../macrowindow.h \
+ ../collapser.h \
+ ../netcom.h \
+ ../resumewidget.h \
+ ../mainwindow.h \
+ ../entity.h \
+ ../macro.h \
+ ../header.h \
+ ../viewer.h \
+ ../macrodrawer.h \
+ ../widgets.h \
+ ../widgets/common.h \
+ ../widgets/widget.h \
+ ../widgets/label.h \
+ ../widgets/lineedit.h \
+ ../widgets/multilist.h \
+ ../widgets/textedit.h \
+ ../widgets/button.h \
+ ../widgets/datetime.h \
+ ../widgets/combobox.h \
+ ../widgets/listbox.h \
+ ../widgets/frame.h \
+ ../widgets/groupbox.h \
+ ../widgets/radiobutton.h \
+ ../widgets/radiobuttons.h \
+ ../widgets/checkbox.h \
+ ../widgets/checkgroupbox.h \
+ ../widgets/window.h \
+ ../widgets/altcombobox.h \
+ ../widgets/metawidget.h
diff --git a/client/docgen/generate.cc b/client/docgen/generate.cc
new file mode 100644
index 0000000..73734a5
--- /dev/null
+++ b/client/docgen/generate.cc
@@ -0,0 +1,212 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * generate.cc
+ *
+ * Thu Mar 24 12:09:33 CET 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "generate.h"
+
+#include <QTextStream>
+#include <QDate>
+
+#include "genimage.h"
+
+static QString generateMethods(QVector<Method> meths)
+{
+ QString out;
+
+ foreach(Method meth, meths) {
+ out += " <div class=\"method\">\n";
+ out += " <a name=\"" + meth.name +
+ "\"></a><div class=\"name\">" + meth.name + "</div>\n";
+ out += " <div class=\"description\">" + meth.description +
+ "</div>\n";
+
+ if(meth.parameters.size()) {
+ out += " <div class=\"parameters\">\n";
+ foreach(Parameter parm, meth.parameters) {
+ out += " <div class=\"parameter\">\n";
+ out += " <div class=\"name\">" + parm.name + "</div>\n";
+ out += " <div class=\"description\">" +
+ parm.description + "</div>\n";
+ out += " </div>\n";
+ }
+ out += " </div>\n";
+ }
+
+ if(meth.returns != "") {
+ out += " <div class=\"returns\"><strong>Returns</strong> " +
+ meth.returns + "</div>\n";
+ }
+
+ out += " </div>\n";
+ }
+
+ return out;
+}
+
+static QString generateAttributes(QVector<Attribute> attrs)
+{
+ QString out;
+
+ foreach(Attribute attr, attrs) {
+ out += " <div class=\"attribute\">\n";
+ out += " <div class=\"name\">" + attr.name + "</div>\n";
+ out += " <div class=\"description\">" + attr.description +
+ "</div>\n";
+ out += " </div>\n";
+ }
+
+ return out;
+}
+
+static QString generateMethodOverview(Doc &doc,
+ QMap<QString, QVector<Method> > &imeths)
+
+{
+ QString out;
+
+ out += "<h2>Method overview</h2>\n";
+
+ QVector<Method> meths;
+
+ meths += doc.methods;
+
+ QMap<QString, QVector<Method> >::iterator j = imeths.begin();
+ while(j != imeths.end()) {
+ meths += j.value();
+ j++;
+ }
+
+ // sort
+ for(int i = 0; i < meths.size(); i++) {
+ for(int j = 0; j < meths.size(); j++) {
+ if(meths[i].name < meths[j].name) {
+ Method tmp = meths[i];
+ meths[i] = meths[j];
+ meths[j] = tmp;
+ }
+ }
+ }
+
+ out += "<ul>\n";
+ foreach(Method meth, meths) {
+ out += "<li><a href=\"#"+meth.name+"\">"+meth.name+"</a> " +
+ meth.description.left(meth.description.indexOf(".") + 1) + "</li>\n";
+ }
+ out += "</ul>\n";
+
+ return out;
+}
+
+QString generate(Doc &doc, QMap<QString, QVector<Method> > &meths,
+ QMap<QString, QVector<Attribute> > &atts)
+{
+ QString out;
+
+ out += " <div class=\"header\"><a href=\"index.html\">Overview</a>"
+ "</div>\n";
+
+ out += " <div class=\"doc\">\n";
+ out += " <h1>" + doc.title + "</h1>\n";
+ if(doc.tag != "" ){
+ out += " <div class=\"tagname\">&lt;" + doc.tag + " /&gt;</div>\n";
+ }
+
+ if(doc.container) {
+ out += " <div class=\"container\">Widget is a container.</div>\n";
+ }
+
+ if(doc.extends != "") {
+ out += " <div class=\"extends\">Extends: <a href=\""+doc.extends+
+ ".html\">" + doc.extends + "</a></div>\n";
+ }
+
+ if(doc.screenshot) {
+ genImage(doc.tag);
+ out += " <div class=\"screenshot\">\n";
+ out += " <img src=\"gfx/" + doc.tag + ".png\"/>\n";
+ out += " </div>\n";
+ }
+
+ out += " <div class=\"description\">\n";
+ out += doc.description;
+ out += " </div>\n";
+
+ out += " <h2>Attributes</h2>\n";
+ out += " <div class=\"attributes\">\n";
+ if(doc.attributes.size()) {
+ out += generateAttributes(doc.attributes);
+ }
+
+ QMap<QString, QVector<Attribute> >::iterator i = atts.begin();
+ while(i != atts.end()) {
+ out += " <h3>Attributes inherited from <a href=\"" + i.key() +
+ ".html\">"+i.key()+"</a>:</h3>\n";
+ out += generateAttributes(i.value());
+ i++;
+ }
+ out += " </div>\n";
+
+ out += generateMethodOverview(doc, meths);
+
+ out += " <h2>Methods</h2>\n";
+ out += " <div class=\"methods\">\n";
+ if(doc.methods.size()) {
+ out += generateMethods(doc.methods);
+ }
+
+ QMap<QString, QVector<Method> >::iterator j = meths.begin();
+ while(j != meths.end()) {
+ out += " <h3>Methods inherited from <a href=\"" + j.key() +
+ ".html\">"+j.key()+"</a>:</h3>\n";
+ out += generateMethods(j.value());
+ j++;
+ }
+ out += " </div>\n";
+
+ out += " </div>\n";
+
+ out += " <div class=\"footer\">This documentation is generated for"
+ " Pracro version "VERSION" at "+QDate::currentDate().toString()+"</div>\n";
+ return out;
+}
+
+#ifdef TEST_GENERATE
+//Additional dependency files
+//deps:
+//Required cflags (autoconf vars may be used)
+//cflags:
+//Required link options (autoconf vars may be used)
+//libs:
+#include "test.h"
+
+TEST_BEGIN;
+
+// TODO: Put some testcode here (see test.h for usable macros).
+TEST_TRUE(false, "No tests yet!");
+
+TEST_END;
+
+#endif/*TEST_GENERATE*/
diff --git a/client/docgen/generate.h b/client/docgen/generate.h
new file mode 100644
index 0000000..24a3191
--- /dev/null
+++ b/client/docgen/generate.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * generate.h
+ *
+ * Thu Mar 24 12:09:33 CET 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __PRACRO_GENERATE_H__
+#define __PRACRO_GENERATE_H__
+
+#include <QString>
+#include <QMap>
+
+#include "doc.h"
+
+QString generate(Doc &doc, QMap<QString, QVector<Method> > &meths,
+ QMap<QString, QVector<Attribute> > &atts);
+
+#endif/*__PRACRO_GENERATE_H__*/
diff --git a/client/docgen/genimage.cc b/client/docgen/genimage.cc
new file mode 100644
index 0000000..332887c
--- /dev/null
+++ b/client/docgen/genimage.cc
@@ -0,0 +1,163 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * genimage.cc
+ *
+ * Wed Mar 16 11:56:22 CET 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "genimage.h"
+
+#include <QImage>
+#include <QPixmap>
+
+#include <QDir>
+#include <QDomDocument>
+
+#include <viewer.h>
+#include <widgets.h>
+
+QString cpr;
+QString user;
+QFont fixedfont;
+
+Viewer *viewer = NULL;
+
+extern QString output;
+
+void genImage(QString widget)
+{
+ QDomDocument node;
+
+ QDomElement elem = node.createElement(widget);
+ elem.setAttribute("name", widget);
+ elem.setAttribute("caption", "Caption");
+ elem.setAttribute("layout", "vbox");
+
+ if(widget == "lineedit" || widget == "textedit") {
+ elem.setAttribute("value", "Some text");
+ }
+
+ if(widget == "checkbox" || widget == "checkgroupbox") {
+ elem.setAttribute("truevalue", "true");
+ elem.setAttribute("falsevalue", "false");
+ elem.setAttribute("value", "true");
+ }
+
+ if(widget == "combobox" || widget == "listbox") {
+ {
+ QDomElement e = node.createElement("item");
+ e.setAttribute("caption", "List item 1");
+ e.setAttribute("value", "item1");
+ elem.appendChild(e);
+ }
+ {
+ QDomElement e = node.createElement("item");
+ e.setAttribute("caption", "List item 2");
+ e.setAttribute("value", "item2");
+ elem.appendChild(e);
+ }
+
+ {
+ QDomElement e = node.createElement("item");
+ e.setAttribute("caption", "List item 3");
+ e.setAttribute("value", "item3");
+ elem.appendChild(e);
+ }
+
+ elem.setAttribute("value", "item1");
+ }
+
+ if(widget == "altcombobox") {
+ QDomElement e = node.createElement("altitem");
+ e.setAttribute("caption", "Alt item");
+ e.setAttribute("value", "altitem");
+ e.setAttribute("innerwidget", "altitem");
+ elem.appendChild(e);
+
+ QDomElement a = node.createElement("lineedit");
+ a.setAttribute("name", "altitem");
+ a.setAttribute("value", "Some alt text");
+ e.appendChild(a);
+
+ elem.setAttribute("value", "altitem");
+ }
+
+ if(widget == "multilist") {
+ QDomElement a = node.createElement("lineedit");
+ a.setAttribute("name", "altitem");
+ a.setAttribute("value", "Value ready to be added");
+ elem.appendChild(a);
+ elem.setAttribute("value", "Some value\nAnother value");
+ }
+
+ if(widget == "frame" || widget == "checkgroupbox") {
+ QDomElement e = node.createElement("label");
+ e.setAttribute("caption", "Contained widgets.");
+ elem.appendChild(e);
+ }
+
+ if(widget == "radiobuttons") {
+ QDomElement e1 = node.createElement("radiobutton");
+ e1.setAttribute("caption", "Radio Button 1");
+ elem.appendChild(e1);
+
+ QDomElement e2 = node.createElement("radiobutton");
+ e2.setAttribute("caption", "Radio Button 2");
+ elem.appendChild(e2);
+ }
+
+ node.appendChild(elem);
+
+ Window w(node, NULL);
+ w.setValues();
+ w.qwidget()->show();
+ QPixmap pix = QPixmap::grabWidget(w.qwidget(), 0, 0);
+ QImage img = pix.toImage();
+ QRgb bg = img.pixel(img.width() - 1, img.height() - 1);
+
+ int cropvert = img.height();
+ int crophorz = img.width();
+ for(int y = img.height() - 1; y > 0; y--) {
+ for(int x = 0; x < img.width(); x++) {
+ if(img.pixel(x, y) != bg) {
+ cropvert = y;
+ y = -1; // break out of y for-loop
+ break;
+ }
+ }
+ }
+
+ for(int x = img.width() - 1; x > 0; x--) {
+ for(int y = 0; y < img.height(); y++) {
+ if(img.pixel(x, y) != bg) {
+ crophorz = x;
+ x = -1; // break out of x for-loop
+ break;
+ }
+ }
+ }
+
+ img = img.copy(0,0, crophorz + 12, cropvert + 12);
+ QDir d;d.mkdir(output + "/gfx/");
+ img.save(output + "/gfx/" + widget + ".png");
+}
diff --git a/client/docgen/genimage.h b/client/docgen/genimage.h
new file mode 100644
index 0000000..079ae91
--- /dev/null
+++ b/client/docgen/genimage.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * genimage.h
+ *
+ * Wed Mar 16 11:56:22 CET 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __PRACRO_GENIMAGE_H__
+#define __PRACRO_GENIMAGE_H__
+
+#include <QString>
+
+void genImage(QString widget);
+
+#endif/*__PRACRO_GENIMAGE_H__*/
diff --git a/client/docgen/parse.cc b/client/docgen/parse.cc
new file mode 100644
index 0000000..bcf137b
--- /dev/null
+++ b/client/docgen/parse.cc
@@ -0,0 +1,198 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * parse.cc
+ *
+ * Thu Mar 24 12:07:16 CET 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#include "parse.h"
+
+#include <QFileInfo>
+#include <QRegExp>
+
+typedef enum {
+ none,
+ indesc,
+ inatt,
+ inmeth,
+ inpar,
+ inret,
+} state_t;
+
+Doc parse(QString filename)
+{
+ Doc doc;
+ doc.screenshot = false;
+ doc.container = false;
+
+ QFileInfo fi(filename);
+ QString name = fi.fileName();
+ doc.name = name.left(name.length() - 2); // Strip ".h"
+
+ state_t state = none;
+
+ fprintf(stderr, "Processing file: %s\n", filename.toStdString().c_str());
+ QFile file(filename);
+ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ fprintf(stderr, "Could not open %s for reading.\n",
+ filename.toStdString().c_str());
+ return doc;
+ }
+
+ bool running = false;
+ QByteArray data;
+ while(!file.atEnd()) {
+ QString line = file.readLine();
+ if(line.right(1) == "\n") line = line.left(line.length() - 1);
+
+ if(line.contains("*/")) running = false;
+
+ if(running) {
+ line.remove(QRegExp("^[ \t*]*"));
+ printf("line [%s]\n", line.toStdString().c_str());
+
+ if(state == indesc && line.left(1) == "@") state = none;
+ if(state == inatt && line.left(1) == "@") state = none;
+ if(state == inpar && line.left(1) == "@") state = inmeth;
+ if(state == inret && line.left(1) == "@") state = inmeth;
+
+ if(state == none && doc.title == "") {
+ doc.title = line;
+ continue;
+ }
+
+ if(state == none && line.left(4) == "@tag") {
+ doc.tag = line.right(line.length() - line.indexOf(" ") - 1);
+ continue;
+ }
+
+ if(state == none && line.left(8) == "@extends") {
+ doc.extends = line.right(line.length() - line.indexOf(" ") - 1);
+ continue;
+ }
+
+ if(state == none && line.left(11) == "@screenshot") {
+ doc.screenshot = true;
+ continue;
+ }
+
+ if(state == none && line.left(10) == "@container") {
+ doc.container = true;
+ continue;
+ }
+
+ if(state == none && line.left(1) != "@" && doc.description == "") {
+ state = indesc;
+ }
+
+
+ if(state == indesc) {
+ doc.description += line + "\n";
+ continue;
+ }
+
+ if(state == none && line.left(4) == "@att") {
+ Attribute att;
+ att.name = line.mid(5, line.indexOf(" ", 5) - 5);
+ att.description =
+ line.right(line.length() - line.indexOf(" ", 6) - 1) + "\n";
+ doc.attributes.push_back(att);
+ state = inatt;
+ continue;
+ }
+
+ if(state == inatt) {
+ Attribute &a = doc.attributes[doc.attributes.size() - 1];
+ a.description += line + "\n";
+ continue;
+ }
+
+ if((state == none || state == inmeth) && line.left(7) == "@method") {
+ Method meth;
+ meth.name = line.right(line.length() - 7 - 1);
+ doc.methods.push_back(meth);
+ state = inmeth;
+ continue;
+ }
+
+ if(state == inmeth && line.left(1) != "@") {
+ Method &m = doc.methods[doc.methods.size() - 1];
+ m.description += line + "\n";
+ continue;
+ }
+
+ if(state == inmeth && line.left(6) == "@param") {
+ Method &m = doc.methods[doc.methods.size() - 1];
+ Parameter par;
+ par.name = line.mid(7, line.indexOf(" ", 7) - 7);
+ par.description =
+ line.right(line.length() - line.indexOf(" ", 7) - 1) + "\n";
+ m.parameters.push_back(par);
+ state = inpar;
+ continue;
+ }
+
+ if(state == inpar) {
+ Method &m = doc.methods[doc.methods.size() - 1];
+ Parameter &p = m.parameters[m.parameters.size() - 1];
+ p.description += line + "\n";
+ continue;
+ }
+
+ if(state == inmeth && line.left(7) == "@return") {
+ Method &m = doc.methods[doc.methods.size() - 1];
+ m.returns = line.right(line.length() - line.indexOf(" ", 7) - 1) + "\n";
+ state = inret;
+ continue;
+ }
+
+ if(state == inret) {
+ Method &m = doc.methods[doc.methods.size() - 1];
+ m.returns += line + "\n";
+ continue;
+ }
+ }
+
+ if(line == "/***") running = true;
+ }
+
+ return doc;
+}
+
+#ifdef TEST_PARSE
+//Additional dependency files
+//deps:
+//Required cflags (autoconf vars may be used)
+//cflags:
+//Required link options (autoconf vars may be used)
+//libs:
+#include "test.h"
+
+TEST_BEGIN;
+
+// TODO: Put some testcode here (see test.h for usable macros).
+TEST_TRUE(false, "No tests yet!");
+
+TEST_END;
+
+#endif/*TEST_PARSE*/
diff --git a/client/docgen/parse.h b/client/docgen/parse.h
new file mode 100644
index 0000000..3f1f73e
--- /dev/null
+++ b/client/docgen/parse.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set et sw=2 ts=2: */
+/***************************************************************************
+ * parse.h
+ *
+ * Thu Mar 24 12:07:16 CET 2011
+ * Copyright 2011 Bent Bisballe Nyeng
+ * deva@aasimon.org
+ ****************************************************************************/
+
+/*
+ * This file is part of Pracro.
+ *
+ * Pracro is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Pracro is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Pracro; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+#ifndef __PRACRO_PARSE_H__
+#define __PRACRO_PARSE_H__
+
+#include <QString>
+
+#include "doc.h"
+
+Doc parse(QString filename);
+
+#endif/*__PRACRO_PARSE_H__*/
diff --git a/client/docgen/style.css b/client/docgen/style.css
new file mode 100644
index 0000000..778c69d
--- /dev/null
+++ b/client/docgen/style.css
@@ -0,0 +1,108 @@
+body {
+ font-family: Verdana;
+ font-size: 12px;
+}
+
+a {
+ color: #5c7b8b;
+}
+
+a:visited {
+ color: #465d69;
+}
+
+a:hover {
+ color: #000;
+}
+
+.doc {
+ padding: 10px;
+}
+
+.doc .title {
+ font-weight: bold;
+ font-size: 1.5em;
+ text-align: center;
+}
+
+.doc .tagname {
+ text-align: center;
+ font-family: courier;
+}
+
+.doc .extends {}
+.doc .container {}
+.doc .screenshot {
+ text-align: center;
+}
+.doc .description {
+ padding-top: 4px;
+ padding-bottom: 4px;
+}
+
+.attributes {}
+.attribute {}
+.attribute .name {
+ font-weight: normal;
+ font-style: italic;
+ border: 0px;
+ border-radius: 0px 0px 0px 0px;
+ background-color: transparent;
+ display: inline;
+ color: green;
+ font-family: courier;
+ padding-right: 4px;
+ padding-left: 4px;
+ font-size: 1.2em;
+}
+.attribute .name:before {
+ content:"- ";
+}
+.attribute .description {
+ display: inline;
+}
+
+.attributes,
+.parameters {
+ margin-top: 8px;
+ border-top: solid #DEDEEE 1px;
+ padding-top: 8px;
+
+ margin-bottom: 8px;
+ border-bottom: solid #DEDEEE 1px;
+ padding-bottom: 8px;
+}
+
+.method {
+ background-color: #EEF3F5;
+ border: solid #DEDEEE 1px;
+ padding: 4px;
+ border-radius: 8px 8px 8px 8px;
+ margin-bottom: 8px;
+}
+
+.method .name {
+ background-color: #D5E1E8;
+ width: *;
+ border: solid #84B0C7 1px;
+ font-weight: bold;
+ padding: 4px;
+ border-radius: 8px 8px 8px 8px;
+}
+
+
+.method .description {}
+.method .returns {}
+
+.parameter {}
+.parameter .name {
+ font-weight: normal;
+ font-style: italic;
+ border: 0px;
+ border-radius: 0px 0px 0px 0px;
+ background-color: transparent;
+ display: inline;
+}
+.parameter .description {
+ display: inline;
+}