From 12cce7eac519786066003173ab072505f2ad8bb0 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 13 Apr 2012 13:48:32 +0200 Subject: Documentation. --- client/docgen/doc.h | 3 ++ client/docgen/docgen.cc | 87 ++++++++++++++++++++++++++++++++++------ client/docgen/generate.cc | 40 +++++++++++++------ client/docgen/parse.cc | 18 +++++++++ client/docgen/style.css | 5 +++ client/luadb.cc | 8 ++-- client/luadb.h | 53 +++++++++++++++++++++++++ client/widgets/altcombobox.h | 1 + client/widgets/button.h | 1 + client/widgets/checkbox.h | 1 + client/widgets/checkgroupbox.h | 1 + client/widgets/combobox.h | 1 + client/widgets/datetime.h | 1 + client/widgets/groupbox.h | 1 + client/widgets/label.h | 1 + client/widgets/lineedit.h | 1 + client/widgets/listbox.h | 1 + client/widgets/metawidget.h | 1 + client/widgets/multilist.h | 1 + client/widgets/radiobuttons.h | 1 + client/widgets/textedit.h | 1 + client/widgets/widget.h | 1 + client/widgets/window.h | 1 + server/src/luapraxisd.cc | 14 +++---- server/src/luapraxisd.h | 90 ++++++++++++++++++++++++++++++++++++++++++ 25 files changed, 299 insertions(+), 35 deletions(-) diff --git a/client/docgen/doc.h b/client/docgen/doc.h index ae693f5..5678476 100644 --- a/client/docgen/doc.h +++ b/client/docgen/doc.h @@ -69,6 +69,9 @@ public: QString title; QString name; QString tag; + bool serverside; + bool clientside; + QString classname; QString extends; bool container; QString description; diff --git a/client/docgen/docgen.cc b/client/docgen/docgen.cc index e4af0a3..4eb2e08 100644 --- a/client/docgen/docgen.cc +++ b/client/docgen/docgen.cc @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -39,7 +40,9 @@ #include "parse.h" #include "generate.h" -#define INPUT "../widgets" +#define WIDGETS_DIR "../widgets" +#define SERVER_DIR "../../server/src" +#define CLIENT_DIR ".." #define OUTPUT "html" QString output; @@ -94,16 +97,46 @@ void writeIndex(QMap &docs) out += "

Pracro "VERSION" Documentation

\n"; out += "

Overview

\n"; + out += "

Clientside

\n"; + out += "

Widgets

\n"; out += "
    \n"; QMap::iterator i = docs.begin(); while(i != docs.end()) { Doc &doc = *i; - out += "
  • ["+doc.name+"] - "+ - doc.title+"
  • \n"; + if(doc.tag != "") { + out += "
  • ["+doc.name+"] - "+ + doc.title+"
  • \n"; + } + i++; + } + out += "
\n"; + out += "

Classes

\n"; + out += "
    \n"; + i = docs.begin(); + while(i != docs.end()) { + Doc &doc = *i; + if(doc.classname != "" && doc.clientside) { + out += "
  • ["+doc.name+"] - "+ + doc.title+"
  • \n"; + } i++; } out += "
\n"; + out += "

Serverside

\n"; + out += "
    \n"; + i = docs.begin(); + while(i != docs.end()) { + Doc &doc = *i; + if(doc.classname != "" && doc.serverside) { + out += "
  • ["+doc.name+"] - "+ + doc.title+"
  • \n"; + } + i++; + } + out += "
\n"; + + QFile::remove(output + "/index.html"); QFile ofile(output + "/index.html"); ofile.open(QIODevice::ReadWrite | QIODevice::Text); @@ -133,15 +166,47 @@ int main(int argc, char *argv[]) QFile::remove(output + "/style.css"); QFile::copy("style.css", output + "/style.css"); - QDir dir(INPUT); - QStringList filter; filter << "*.h"; - dir.setNameFilters(filter); + QStringList files; + + // Widgets + { + QDir dir(WIDGETS_DIR); + QStringList filter; filter << "*.h"; + dir.setNameFilters(filter); + if(!dir.exists()) return 1; + QFileInfoList inflst = dir.entryInfoList(QDir::Files); + foreach(QFileInfo inf, inflst) { + files.append(inf.absoluteFilePath()); + } + } + + // Client + { + QDir dir(CLIENT_DIR); + QStringList filter; filter << "*.h"; + dir.setNameFilters(filter); + if(!dir.exists()) return 1; + QFileInfoList inflst = dir.entryInfoList(QDir::Files); + foreach(QFileInfo inf, inflst) { + files.append(inf.absoluteFilePath()); + } + } + + // Server + { + QDir dir(SERVER_DIR); + QStringList filter; filter << "*.h"; + dir.setNameFilters(filter); + if(!dir.exists()) return 1; + QFileInfoList inflst = dir.entryInfoList(QDir::Files); + foreach(QFileInfo inf, inflst) { + files.append(inf.absoluteFilePath()); + } + } - if(!dir.exists()) return 1; - QStringList l = dir.entryList(QDir::Files); - foreach(QString file, l) { - Doc doc = parse(QString(INPUT) + "/" + file); - if(doc.title != "" || doc.tag != "") + foreach(QString file, files) { + Doc doc = parse(file); + if(doc.title != "" || doc.tag != "" || doc.classname != "") docs[doc.name] = doc; } diff --git a/client/docgen/generate.cc b/client/docgen/generate.cc index b521f1f..f418b24 100644 --- a/client/docgen/generate.cc +++ b/client/docgen/generate.cc @@ -219,6 +219,18 @@ QString generate(Doc &doc, QMap > &meths, highlight("<" + doc.tag + " />", xml) + "\n"; } + if(doc.serverside) + out += "
Available serverside.
\n"; + + if(doc.clientside) + out += "
Available clientside.
\n"; + + + if(doc.classname != "" ){ + out += "
Class
" +
+      doc.classname + "
\n"; + } + if(doc.container) { out += "
Widget is a container.
\n"; } @@ -248,21 +260,23 @@ QString generate(Doc &doc, QMap > &meths, out += generateExamples(doc.examples, xml); - out += "

Attributes

\n"; - out += "
\n"; - if(doc.attributes.size()) { - out += generateAttributes(doc.attributes); - } + if(doc.tag != "") { + out += "

Attributes

\n"; + out += "
\n"; + if(doc.attributes.size()) { + out += generateAttributes(doc.attributes); + } - QMap >::iterator i = atts.begin(); - while(i != atts.end()) { - out += "

Attributes inherited from "+i.key()+":

\n"; - out += generateAttributes(i.value()); - i++; + QMap >::iterator i = atts.begin(); + while(i != atts.end()) { + out += "

Attributes inherited from "+i.key()+":

\n"; + out += generateAttributes(i.value()); + i++; + } + out += "
\n"; } - out += "
\n"; - + out += generateMethodOverview(doc, meths); out += "

Methods

\n"; diff --git a/client/docgen/parse.cc b/client/docgen/parse.cc index 64c2aa7..0354f57 100644 --- a/client/docgen/parse.cc +++ b/client/docgen/parse.cc @@ -89,6 +89,8 @@ Doc parse(QString filename) { Doc doc; doc.container = false; + doc.serverside = false; + doc.clientside = false; QFileInfo fi(filename); QString name = fi.fileName(); @@ -134,10 +136,26 @@ Doc parse(QString filename) continue; } + if(state == none && line.left(6) == "@class") { + doc.classname = line.right(line.length() - line.indexOf(" ") - 1); + doc.name = doc.classname; + continue; + } + if(state == none && line.left(8) == "@extends") { doc.extends = line.right(line.length() - line.indexOf(" ") - 1); continue; } + + if(state == none && line.left(11) == "@serverside") { + doc.serverside = true; + continue; + } + + if(state == none && line.left(11) == "@clientside") { + doc.clientside = true; + continue; + } if(state == none && line.left(11) == "@screenshot") { Screenshot s; diff --git a/client/docgen/style.css b/client/docgen/style.css index e938648..17f087e 100644 --- a/client/docgen/style.css +++ b/client/docgen/style.css @@ -26,6 +26,11 @@ a:hover { } .doc .tagname { + font-size: 1.5em; + text-align: center; +} +.doc .classname { + font-size: 1.5em; text-align: center; } .doc .extends {} diff --git a/client/luadb.cc b/client/luadb.cc index 317831f..a848f36 100644 --- a/client/luadb.cc +++ b/client/luadb.cc @@ -77,7 +77,7 @@ typedef struct db_userdata { DB *db; } db_userdata; -static int db_value(lua_State *L) +int db_value(lua_State *L) { db_userdata *dbu; @@ -91,7 +91,7 @@ static int db_value(lua_State *L) return 1; } -static int db_exec(lua_State *L) +int db_exec(lua_State *L) { db_userdata *dbu; @@ -105,7 +105,7 @@ static int db_exec(lua_State *L) return 0; } -static int db_next(lua_State *L) +int db_next(lua_State *L) { db_userdata *dbu; @@ -119,7 +119,7 @@ static int db_next(lua_State *L) return 1; } -static int db_new(lua_State *L) +int db_new(lua_State *L) { const char *driver = luaL_checkstring(L, 1); const char *host = luaL_checkstring(L, 2); diff --git a/client/luadb.h b/client/luadb.h index a87baf5..91c8777 100644 --- a/client/luadb.h +++ b/client/luadb.h @@ -30,6 +30,59 @@ #include +/*** + * Database Class + * @class DB + * @clientside + * The DB class connects and handles communication with the an SQL server using + * the QDatabase API. + */ + +/*** + * @method object DB.new(string driver, string host, string database, string user, string password, int port) + * Create a new DB connection object. + * @param driver A string containing the QT SQL driver name. QPSQL: postgresql + * driver. + * @param host The hostname to connect to. + * @param database The database to open. + * @param user The username to use for authentication. + * @param password The password to use for authentication. + * @param port The port to connect to. + * @return The newly created communication object. + * @example Create a new database object: + * px = DB.new('QPSQL', 'localhost', 'mydb', 'user01', 'verysecret', '5432') + */ +int db_new(lua_State *L); + +/*** + * @method nil exec(string query) + * Execute an SQL query. + * @param query A string containing the SQL query to execute. + */ +int db_exec(lua_State *L); + +/*** + * @method string value(int index) + * Get current value from the result of the last query. + * @param index The column index number to use for the value retrieval. + * @return A string containing the value in the result cell. + */ +int db_value(lua_State *L); + +/*** + * @method boolean next() + * Iterate to next row in result set. + * @return true if another row is availble, false if the end of the list has + * been reached. + * @example Iterate through a result list and print the value in column 0 in each row: + * while db:next() + * do + * local item = db:value(0) + * print(item) + * end + */ +int db_next(lua_State *L); + void register_db(lua_State *L); #endif/*__PRACRO_LUADB_H__*/ diff --git a/client/widgets/altcombobox.h b/client/widgets/altcombobox.h index b0fb61c..73dee10 100644 --- a/client/widgets/altcombobox.h +++ b/client/widgets/altcombobox.h @@ -43,6 +43,7 @@ /*** * ComboBox Widget with Alternate Value * @tag altcombobox + * @clientside * @extends combobox * @screenshot Example: altitem selected. * diff --git a/client/widgets/button.h b/client/widgets/button.h index 0bd7db9..d9053a6 100644 --- a/client/widgets/button.h +++ b/client/widgets/button.h @@ -34,6 +34,7 @@ /*** * PushButton Widget * @tag button + * @clientside * @screenshot Example button *