summaryrefslogtreecommitdiff
path: root/client/docgen
diff options
context:
space:
mode:
Diffstat (limited to 'client/docgen')
-rw-r--r--client/docgen/doc.h8
-rw-r--r--client/docgen/docgen.pro5
-rw-r--r--client/docgen/generate.cc11
-rw-r--r--client/docgen/genimage.cc107
-rw-r--r--client/docgen/genimage.h2
-rw-r--r--client/docgen/parse.cc14
-rw-r--r--client/docgen/style.css1
7 files changed, 43 insertions, 105 deletions
diff --git a/client/docgen/doc.h b/client/docgen/doc.h
index 5a1d5dd..ae693f5 100644
--- a/client/docgen/doc.h
+++ b/client/docgen/doc.h
@@ -58,18 +58,24 @@ public:
QString description;
};
+class Screenshot {
+public:
+ QString caption;
+ QString xml;
+};
+
class Doc {
public:
QString title;
QString name;
QString tag;
QString extends;
- bool screenshot;
bool container;
QString description;
QVector<Example> examples;
QVector<Attribute> attributes;
QVector<Method> methods;
+ QVector<Screenshot> screenshots;
};
#endif/*__PRACRO_DOC_H__*/
diff --git a/client/docgen/docgen.pro b/client/docgen/docgen.pro
index 79308b8..a99c43a 100644
--- a/client/docgen/docgen.pro
+++ b/client/docgen/docgen.pro
@@ -15,11 +15,13 @@ win32 {
INCLUDEPATH += lua/include
LIBS += -llua51
DEFINES += HOST_WIN32
+ LIBS += -lcurl -lexpat
}
unix {
LIBS += -llua
LIBS += -lqjson
+ LIBS += -lcurl -lexpat
}
# Input
@@ -33,6 +35,9 @@ SOURCES += \
../lua.cc \
../luawidget.cc \
../luadb.cc \
+ ../luapraxisd.cc \
+ ../../server/src/praxisd.cc \
+ ../../server/src/saxparser.cc \
../messagebox.cc \
../macrowindow.cc \
../collapser.cc \
diff --git a/client/docgen/generate.cc b/client/docgen/generate.cc
index db7d0c9..b521f1f 100644
--- a/client/docgen/generate.cc
+++ b/client/docgen/generate.cc
@@ -230,11 +230,16 @@ QString generate(Doc &doc, QMap<QString, QVector<Method> > &meths,
out += extendedBy(doc.name, docs);
- if(doc.screenshot) {
- genImage(doc.tag);
+ int idx = 0;
+ QVector<Screenshot>::iterator si = doc.screenshots.begin();
+ while(si != doc.screenshots.end()) {
+ Screenshot &s = *si;
+ QString imgfile = genImage(s.xml, idx++);
out += " <div class=\"screenshot\">\n";
- out += " <img src=\"gfx/" + doc.tag + ".png\"/>\n";
+ out += " <img src=\"gfx/" + imgfile + "\"/><br/>\n";
+ out += " <span class=\"caption\">"+s.caption+"</span>\n";
out += " </div>\n";
+ si++;
}
out += " <div class=\"description\">\n";
diff --git a/client/docgen/genimage.cc b/client/docgen/genimage.cc
index f598553..02f1243 100644
--- a/client/docgen/genimage.cc
+++ b/client/docgen/genimage.cc
@@ -44,110 +44,19 @@ Viewer *viewer = NULL;
extern QString output;
-void genImage(QString widget)
+QString genImage(QString xml, int idx)
{
QDomDocument node;
+ node.setContent(xml);
- QDomElement elem = node.createElement(widget);
- elem.setAttribute("name", widget);
- elem.setAttribute("caption", "Caption");
- elem.setAttribute("layout", "vbox");
+ QDomElement e = node.documentElement();
- 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") {
-
- if(widget == "listbox") {
- QDomElement e = node.createElement("item");
- e.setAttribute("type", "header");
- e.setAttribute("caption", "Header 1");
- e.setAttribute("value", "Header 1");
- elem.appendChild(e);
- }
-
- {
- 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);
- }
-
- if(widget == "listbox") {
- QDomElement e = node.createElement("item");
- e.setAttribute("type", "separator");
- e.setAttribute("caption", "sep 1");
- e.setAttribute("value", "sep 1");
- 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);
+ QString imgfile = e.tagName() + QString::number(idx) + ".png";
Window w(node, NULL);
- w.setValues();
w.qwidget()->show();
+ w.setValues();
+
QPixmap pix = QPixmap::grabWidget(w.qwidget(), 0, 0);
QImage img = pix.toImage();
QRgb bg = img.pixel(img.width() - 1, img.height() - 1);
@@ -176,5 +85,7 @@ void genImage(QString widget)
img = img.copy(0,0, crophorz + 12, cropvert + 12);
QDir d;d.mkdir(output + "/gfx/");
- img.save(output + "/gfx/" + widget + ".png");
+ img.save(output + "/gfx/" + imgfile);
+
+ return imgfile;
}
diff --git a/client/docgen/genimage.h b/client/docgen/genimage.h
index 079ae91..d7bc9e7 100644
--- a/client/docgen/genimage.h
+++ b/client/docgen/genimage.h
@@ -30,6 +30,6 @@
#include <QString>
-void genImage(QString widget);
+QString genImage(QString xml, int idx);
#endif/*__PRACRO_GENIMAGE_H__*/
diff --git a/client/docgen/parse.cc b/client/docgen/parse.cc
index 6303eae..64c2aa7 100644
--- a/client/docgen/parse.cc
+++ b/client/docgen/parse.cc
@@ -40,6 +40,7 @@ typedef enum {
inmethex,
inpar,
inret,
+ inscrsht
} state_t;
static QString convert(QString in)
@@ -87,7 +88,6 @@ static QString convert(QString in)
Doc parse(QString filename)
{
Doc doc;
- doc.screenshot = false;
doc.container = false;
QFileInfo fi(filename);
@@ -116,6 +116,7 @@ Doc parse(QString filename)
line.remove(QRegExp("^[ \t]*[*][ \t]"));
if(state == indesc && line.left(1) == "@") state = none;
+ if(state == inscrsht && line.left(1) == "@") state = none;
if(state == indescex && line.left(1) == "@") state = none;
if(state == inatt && line.left(1) == "@") state = none;
if(state == inpar && line.left(1) == "@") state = inmeth;
@@ -139,7 +140,10 @@ Doc parse(QString filename)
}
if(state == none && line.left(11) == "@screenshot") {
- doc.screenshot = true;
+ Screenshot s;
+ s.caption = line.right(line.length() - 11);
+ doc.screenshots.push_back(s);
+ state = inscrsht;
continue;
}
@@ -157,6 +161,12 @@ Doc parse(QString filename)
continue;
}
+ if(state == inscrsht) {
+ Screenshot &s = doc.screenshots[doc.screenshots.size() - 1];
+ s.xml += line + "\n";
+ continue;
+ }
+
if((state == none || state == indesc || state == inmeth)
&& line.left(8) == "@example") {
diff --git a/client/docgen/style.css b/client/docgen/style.css
index c13b0e5..e938648 100644
--- a/client/docgen/style.css
+++ b/client/docgen/style.css
@@ -32,6 +32,7 @@ a:hover {
.doc .container {}
.doc .screenshot {
text-align: center;
+ padding: 8px 0px 8px 0px;
}
.doc .description {
padding-top: 4px;