[tracker] Autogenerate ontology documentation.



commit 8110061904d25e2f55c3afb09de09e84f5f822a4
Author: Carlos Garnacho <carlos lanedo com>
Date:   Wed Dec 16 17:45:45 2009 +0100

    Autogenerate ontology documentation.
    
    There is now a new gtk-doc reference for ontology, which is created
    from data/ontologies/*. docs/tools contains the programs to generate
    both docbook and graphs, these are dumped on docs/reference/ontology,
    which is compiled afterwards.
    
    Documentation generation happens on make, ontology graphs require
    graphviz and are only generated on distcheck, A base image is
    committed, so people don't need graphviz to have a peek.

 INSTALL                                            |   17 +-
 configure.ac                                       |    7 +
 data/ontologies/38-nmm.ontology                    |    2 +-
 docs/Makefile.am                                   |    2 +-
 docs/reference/Makefile.am                         |    3 +-
 docs/reference/ontology/Makefile.am                |   45 +++
 docs/reference/ontology/ontology-docs.sgml         |   71 ++++
 docs/reference/ontology/ontology.png               |  Bin 0 -> 1187428 bytes
 docs/reference/ontology/version.xml.in             |    1 +
 docs/tools/Makefile.am                             |   70 ++++
 docs/tools/gen-doc.sh                              |   33 ++
 .../ontology => docs/tools}/generate-ontology.sh   |    0
 {utils/ontology => docs/tools}/ontology-graph.c    |    0
 {utils/services => docs/tools}/qname.c             |    0
 {utils/services => docs/tools}/qname.h             |    0
 utils/services/ttl2html.c => docs/tools/ttl2sgml.c |    4 +-
 {utils/services => docs/tools}/ttl_loader.c        |    0
 {utils/services => docs/tools}/ttl_loader.h        |    0
 {utils/services => docs/tools}/ttl_model.c         |    0
 {utils/services => docs/tools}/ttl_model.h         |    0
 docs/tools/ttl_sgml.c                              |  363 ++++++++++++++++++++
 utils/services/ttl_html.h => docs/tools/ttl_sgml.h |    6 +-
 utils/Makefile.am                                  |    1 -
 utils/ontology/Makefile.am                         |   29 --
 utils/services/gen-doc.sh                          |   54 ---
 utils/services/ttl_html.c                          |  312 -----------------
 26 files changed, 613 insertions(+), 407 deletions(-)
---
diff --git a/INSTALL b/INSTALL
index 8b82ade..2550dab 100644
--- a/INSTALL
+++ b/INSTALL
@@ -2,7 +2,7 @@ Installation Instructions
 *************************
 
 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006, 2007, 2008 Free Software Foundation, Inc.
+2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This file is free documentation; the Free Software Foundation gives
 unlimited permission to copy, distribute and modify it.
@@ -159,7 +159,7 @@ Particular systems
 CC is not installed, it is recommended to use the following options in
 order to use an ANSI C compiler:
 
-     ./configure CC="cc -Ae"
+     ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
 
 and if that doesn't work, install pre-built binaries of GCC for HP-UX.
 
@@ -174,6 +174,16 @@ and if that doesn't work, try
 
      ./configure CC="cc -nodtk"
 
+   On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+   On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'.  It is recommended to use the following options:
+
+     ./configure --prefix=/boot/common
+
 Specifying the System Type
 ==========================
 
@@ -189,7 +199,8 @@ type, such as `sun4', or a canonical name which has the form:
 
 where SYSTEM can have one of these forms:
 
-     OS KERNEL-OS
+     OS
+     KERNEL-OS
 
    See the file `config.sub' for the possible values of each field.  If
 `config.sub' isn't included in this package, then this package doesn't
diff --git a/configure.ac b/configure.ac
index 2952f7a..2524f54 100644
--- a/configure.ac
+++ b/configure.ac
@@ -222,6 +222,10 @@ fi
 AC_PATH_PROG(VALAC, valac, valac)
 AC_SUBST(VALAC)
 
+AC_PATH_PROG(GRAPHVIZ_FDP, fdp)
+AC_SUBST(GRAPHVIZ_FDP)
+AM_CONDITIONAL(HAVE_GRAPHVIZ_FDP, test -n "$GRAPHVIZ_FDP")
+
 # Check we have the DBUS binding tool we need
 AC_PATH_PROG(DBUSBINDINGTOOL, dbus-binding-tool)
 if test -z $DBUSBINDINGTOOL; then
@@ -1590,6 +1594,9 @@ AC_CONFIG_FILES([
 	docs/reference/libtracker-common/version.xml
 	docs/reference/libtracker-miner/Makefile
 	docs/reference/libtracker-miner/version.xml
+	docs/reference/ontology/Makefile
+	docs/reference/ontology/version.xml
+        docs/tools/Makefile
 	Makefile
 	po/Makefile.in
 	src/libinotify/Makefile
diff --git a/data/ontologies/38-nmm.ontology b/data/ontologies/38-nmm.ontology
index 622f382..c38fdcb 100644
--- a/data/ontologies/38-nmm.ontology
+++ b/data/ontologies/38-nmm.ontology
@@ -131,7 +131,7 @@ nfo:isContentEncrypted a rdf:Property ;
 
 nmm:isForHearingImpaired a rdf:Property ;
 	rdfs:label "Is for hearing-impaired" ;
-	rdfs:comment "Does text stream contain helper tags for hearing-impaired such as <steps in hallway>" ;
+	rdfs:comment "Does text stream contain helper tags for hearing-impaired such as &lt;steps in hallway&gt;" ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:SynchronizedText ;
 	rdfs:range xsd:boolean .
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 922ed19..0508209 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -1,4 +1,4 @@
 include $(top_srcdir)/Makefile.decl
 
-SUBDIRS = manpages design reference
+SUBDIRS = manpages design tools reference
 	
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index 48b3c9a..7ad911f 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -3,5 +3,6 @@ include $(top_srcdir)/Makefile.decl
 SUBDIRS = 			\
 	libtracker-client	\
 	libtracker-common	\
-	libtracker-miner
+	libtracker-miner	\
+	ontology
 
diff --git a/docs/reference/ontology/Makefile.am b/docs/reference/ontology/Makefile.am
new file mode 100644
index 0000000..4fdc654
--- /dev/null
+++ b/docs/reference/ontology/Makefile.am
@@ -0,0 +1,45 @@
+include $(top_srcdir)/Makefile.decl
+
+AUTOMAKE_OPTIONS = 1.6
+
+# The name of the module.
+DOC_MODULE = ontology
+
+# The top-level SGML file.
+DOC_MAIN_SGML_FILE = ontology-docs.sgml
+
+# The directory containing the source code. Relative to $(srcdir)
+DOC_SOURCE_DIR = .
+
+# Extra options to supply to gtkdoc-mkdb
+MKDB_OPTIONS = --sgml-mode --output-format=xml
+
+# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE)
+content_files =						\
+	nie-ontology.xml				\
+	nco-ontology.xml				\
+	nmo-ontology.xml				\
+	nfo-ontology.xml				\
+	nao-ontology.xml				\
+	mto-ontology.xml				\
+	nmm-ontology.xml				\
+	mfo-ontology.xml				\
+	mlo-ontology.xml				\
+	tracker-ontology.xml				\
+	maemo-ontology.xml				\
+	ncal-ontology.xml				\
+	scal-ontology.xml				\
+	version.xml
+
+expand_content_files =
+
+# Images to copy into HTML directory
+HTML_IMAGES = ontology.png
+
+# Extra options to supply to gtkdoc-fixref
+FIXXREF_OPTIONS =
+
+include $(top_srcdir)/gtk-doc.make
+
+# Other files to distribute
+EXTRA_DIST += version.xml.in ontology.png
diff --git a/docs/reference/ontology/ontology-docs.sgml b/docs/reference/ontology/ontology-docs.sgml
new file mode 100644
index 0000000..e9a6d13
--- /dev/null
+++ b/docs/reference/ontology/ontology-docs.sgml
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
+               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
+<!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
+<!ENTITY version SYSTEM "version.xml">
+<!ENTITY nie-ontology SYSTEM "nie-ontology.xml">
+<!ENTITY nco-ontology SYSTEM "nco-ontology.xml">
+<!ENTITY nmo-ontology SYSTEM "nmo-ontology.xml">
+<!ENTITY nfo-ontology SYSTEM "nfo-ontology.xml">
+<!ENTITY nao-ontology SYSTEM "nao-ontology.xml">
+<!ENTITY mto-ontology SYSTEM "mto-ontology.xml">
+<!ENTITY nmm-ontology SYSTEM "nmm-ontology.xml">
+<!ENTITY mfo-ontology SYSTEM "mfo-ontology.xml">
+<!ENTITY mlo-ontology SYSTEM "mlo-ontology.xml">
+<!ENTITY tracker-ontology SYSTEM "tracker-ontology.xml">
+<!ENTITY maemo-ontology SYSTEM "maemo-ontology.xml">
+<!ENTITY ncal-ontology SYSTEM "ncal-ontology.xml">
+<!ENTITY scal-ontology SYSTEM "scal-ontology.xml">
+]>
+<book id="index">
+  <bookinfo>
+    <title>Tracker Ontology Reference Manual</title>
+    <releaseinfo>for Tracker &version;</releaseinfo>
+  </bookinfo>
+
+  <part id="ontology">
+    <title>Overview</title>
+    <partintro>
+      <para>
+        <ulink url="http://www.tracker-project.org";>Tracker</ulink> is a central repository of user information, that provides two big benefits for the desktop: <emphasis>Share</emphasis> data between applications (it doesn't matter the source once it is stored in the repository) and <emphasis>Link</emphasis> information from different sources (mixing contacts with files, location, activities and whatnot).
+      </para>
+      <para>
+        This central repository can work only with a very well defined data model, that applications can rely to store and recover their information. That data model is defined using a semantic web artifact called <emphasis>ontology</emphasis>. An ontology defines the concepts (classes) and properties (attributes) that the items in the repository can be/have.
+      </para>
+      <para>
+        There is an EU-funded project called <ulink url="http://nepomuk.semanticdesktop.org/";>Nepomuk</ulink>, where a core of ontologies to model the Desktop were defined. This set was a very good starting point for Tracker but new requirements and heavy development in collaboration with applications provided a very valuable feedback, in form of fixes and extensions. Some of this work is already submitted for approval in the upstream version, but the process is long and hard, so the Tracker ontologies are diverging slowly.
+      </para>
+      <para>
+        This documentation describes the Tracker flavour of Nepomuk ontologies. The big picture and basic concepts are the same as in the original Nepomuk, but "hell and heaven are in the details". All classes, properties and restrictions included in these pages should work in Tracker. Any error in this documentation can be reported in the Tracker <ulink url="http://mail.gnome.org/mailman/listinfo/tracker-list";>Mailing list</ulink> or <ulink url="https://bugzilla.gnome.org/enter_bug.cgi?product=tracker";>bugzilla</ulink>.
+      </para>
+      <para>
+        This is just documentation about the ontologies. For more information about Tracker technical details and implementation, please refer to the Tracker <ulink url="http://live.gnome.org/Tracker/Documentation/";>Documentation wiki</ulink> page in GNOME.
+      </para>
+    </partintro>
+
+    &nie-ontology;
+    &nco-ontology;
+    &nmo-ontology;
+    &nfo-ontology;
+    &nao-ontology;
+    &mto-ontology;
+    &nmm-ontology;
+    &mfo-ontology;
+    &mlo-ontology;
+    &tracker-ontology;
+    &maemo-ontology;
+    &ncal-ontology;
+    &scal-ontology;
+  </part>
+
+  <part id="ontology-graphs">
+    <title>The big picture</title>
+    <partintro>
+      This is a graph that shows how different classes in the ontology are related:
+    </partintro>
+    <figure id="ontology-graph">
+      <title>Ontology classes and their relations</title>
+      <graphic fileref="ontology.png" format="PNG"></graphic>
+    </figure>
+  </part>
+</book>
diff --git a/docs/reference/ontology/ontology.png b/docs/reference/ontology/ontology.png
new file mode 100644
index 0000000..37bfae4
Binary files /dev/null and b/docs/reference/ontology/ontology.png differ
diff --git a/docs/reference/ontology/version.xml.in b/docs/reference/ontology/version.xml.in
new file mode 100644
index 0000000..c7e1225
--- /dev/null
+++ b/docs/reference/ontology/version.xml.in
@@ -0,0 +1 @@
+ TRACKER_VERSION@
diff --git a/docs/tools/Makefile.am b/docs/tools/Makefile.am
new file mode 100644
index 0000000..80a4de4
--- /dev/null
+++ b/docs/tools/Makefile.am
@@ -0,0 +1,70 @@
+include $(top_srcdir)/Makefile.decl
+
+noinst_PROGRAMS = ontology-graph ttl2sgml
+
+INCLUDES = 								\
+	-DG_LOG_DOMAIN=\"Tracker\"					\
+	-DTRACKER_COMPILATION						\
+	-DTOP_SRCDIR=\"$(top_srcdir)\"					\
+	-I$(top_srcdir)/src						\
+	$(WARN_CFLAGS)							\
+	$(GLIB2_CFLAGS)							\
+	$(GIO_CFLAGS)							\
+	$(DBUS_CFLAGS)
+
+ontology_graph_SOURCES =						\
+	ontology-graph.c
+
+ontology_graph_LDADD =							\
+	$(top_builddir)/src/libtracker-data/libtracker-data.la		\
+	$(top_builddir)/src/libtracker-common/libtracker-common.la	\
+	$(DBUS_LIBS)							\
+	$(GIO_LIBS)							\
+	$(GLIB2_LIBS)
+
+ttl2sgml_SOURCES =							\
+	ttl2sgml.c							\
+	ttl_loader.h							\
+	ttl_loader.c							\
+	ttl_model.h 							\
+	ttl_model.c							\
+	qname.h								\
+	qname.c								\
+	ttl_sgml.h							\
+	ttl_sgml.c
+
+ttl2sgml_LDADD = 							\
+	$(top_builddir)/src/libtracker-data/libtracker-data.la		\
+	$(top_builddir)/src/libtracker-common/libtracker-common.la	\
+	$(DBUS_LIBS)							\
+	$(GLIB2_LIBS)							\
+	$(GIO_LIBS)
+
+gen-doc.stamp: ttl2sgml
+	./gen-doc.sh
+	$(AM_V_GEN) touch $@
+
+if HAVE_GRAPHVIZ_FDP
+dist-check-graphviz:
+else
+dist-check-graphviz:
+	@echo "*** Graphviz's fdp tool must be installed in order to make dist"
+	@false
+endif
+
+ontology.dot: ontology-graph
+	$(AM_V_GEN) ./ontology-graph -d $(top_srcdir)/data/ontologies -o ontology.dot
+
+ontology.png: ontology.dot
+	$(AM_V_GEN)$(GRAPHVIZ_FDP) -Tpng -o $(top_srcdir)/docs/reference/ontology/ontology.png ontology.dot
+
+BUILT_SOURCES = gen-doc.stamp
+
+EXTRA_DIST = 			\
+	gen-doc.sh		\
+	$(BUILT_SOURCES)
+
+DISTCLEANFILES = ontology.dot
+CLEANFILES = $(BUILT_SOURCES)
+
+dist-hook: dist-check-graphviz ontology.dot ontology.png
\ No newline at end of file
diff --git a/docs/tools/gen-doc.sh b/docs/tools/gen-doc.sh
new file mode 100755
index 0000000..436ec9d
--- /dev/null
+++ b/docs/tools/gen-doc.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+#
+# This script generates the SGML documentation from TTL description
+# for the tracker specific ontologies
+#
+BUILD_DIR="../reference/ontology/"
+
+echo "Generating list of classes-properties and files (file-class.cache)"
+if [ -e file-class.cache ]; then
+   rm -f file-class.cache ;
+fi
+
+for f in `find ../../data/ontologies -name "*.ontology"` ; do
+    TMPNAME=${f%.ontology}
+    PREFIX=${TMPNAME#*-}
+    grep "^[a-z]\{1,\}\:[a-zA-Z]" $f |awk -v pr=$PREFIX '{print pr " " $1}' >> file-class.cache
+done
+
+#echo "Converting all dia diagrams to png"
+#for image in `find ../../docs/ontologies -name "*.dia"` ; do
+#    dia -t png $image -e $BUILD_DIR/$(basename ${image/.dia/.png})
+#done
+
+for f in `find ../../data/ontologies -name "*.description"` ; do
+    # ../../data/ontologies/XX-aaa.description -> PREFIX=aaa
+    TMPNAME=${f%.description}
+    PREFIX=${TMPNAME#*-}
+    echo "Generating $PREFIX documentation"
+
+    ./ttl2sgml -d $f -o $BUILD_DIR/$PREFIX-ontology.xml -l file-class.cache \
+	-e ../../docs/ontologies/$PREFIX/explanation.html
+done
diff --git a/utils/ontology/generate-ontology.sh b/docs/tools/generate-ontology.sh
similarity index 100%
rename from utils/ontology/generate-ontology.sh
rename to docs/tools/generate-ontology.sh
diff --git a/utils/ontology/ontology-graph.c b/docs/tools/ontology-graph.c
similarity index 100%
rename from utils/ontology/ontology-graph.c
rename to docs/tools/ontology-graph.c
diff --git a/utils/services/qname.c b/docs/tools/qname.c
similarity index 100%
rename from utils/services/qname.c
rename to docs/tools/qname.c
diff --git a/utils/services/qname.h b/docs/tools/qname.h
similarity index 100%
rename from utils/services/qname.h
rename to docs/tools/qname.h
diff --git a/utils/services/ttl2html.c b/docs/tools/ttl2sgml.c
similarity index 96%
rename from utils/services/ttl2html.c
rename to docs/tools/ttl2sgml.c
index 6af1293..ec9982d 100644
--- a/utils/services/ttl2html.c
+++ b/docs/tools/ttl2sgml.c
@@ -4,7 +4,7 @@
 #include <stdio.h>
 #include "ttl_loader.h"
 #include "ttl_model.h"
-#include "ttl_html.h"
+#include "ttl_sgml.h"
 
 static gchar *desc_file = NULL;
 static gchar *output_file = NULL;
@@ -84,7 +84,7 @@ main (gint argc, gchar **argv)
 	g_free (ttl_file);
 	g_free (dirname);
 
-	ttl_html_print (description, ontology, f, class_location_file, explanation_file);
+	ttl_sgml_print (description, ontology, f, class_location_file, explanation_file);
 
 	ttl_loader_free_ontology (ontology);
 	ttl_loader_free_description (description);
diff --git a/utils/services/ttl_loader.c b/docs/tools/ttl_loader.c
similarity index 100%
rename from utils/services/ttl_loader.c
rename to docs/tools/ttl_loader.c
diff --git a/utils/services/ttl_loader.h b/docs/tools/ttl_loader.h
similarity index 100%
rename from utils/services/ttl_loader.h
rename to docs/tools/ttl_loader.h
diff --git a/utils/services/ttl_model.c b/docs/tools/ttl_model.c
similarity index 100%
rename from utils/services/ttl_model.c
rename to docs/tools/ttl_model.c
diff --git a/utils/services/ttl_model.h b/docs/tools/ttl_model.h
similarity index 100%
rename from utils/services/ttl_model.h
rename to docs/tools/ttl_model.h
diff --git a/docs/tools/ttl_sgml.c b/docs/tools/ttl_sgml.c
new file mode 100644
index 0000000..0fe0330
--- /dev/null
+++ b/docs/tools/ttl_sgml.c
@@ -0,0 +1,363 @@
+#include <glib/gprintf.h>
+#include <string.h>
+
+#include "ttl_sgml.h"
+#include "qname.h"
+
+#define DEFAULT_COPYRIGHT "Copyright &copy; 2009 <a href=\"http://www.nokia.com/\";>Nokia</a>"
+#define SIGNALS_DOC "http://live.gnome.org/Tracker/Documentation/SignalsOnChanges";
+
+typedef struct {
+	Ontology *ontology;
+	OntologyDescription *description;
+	FILE *output;
+} CallbackInfo;
+
+
+static void
+print_someone (FILE *f,
+               const gchar *role,
+               const gchar *who)
+{
+        gchar **details;
+
+        details = g_strsplit (who, ",", 3);
+
+        g_fprintf (f, "<%s>\n", role);
+        g_fprintf (f, "<firstname>%s</firstname>\n", g_strstrip (details[0]));
+
+        if (details[1] || details[2]) {
+                g_fprintf (f, "<affiliation>\n");
+
+                if (details[1]) {
+                        g_fprintf (f, "<orgname>%s</orgname>\n", g_strstrip (details[1]));
+                }
+
+                if (details[1] && details[2]) {
+                        g_fprintf (f, "<address><email>%s</email></address>\n", g_strstrip (details[2]));
+                }
+
+                g_fprintf (f, "</affiliation>\n");
+        }
+
+        g_fprintf (f, "</%s>\n", role);
+        g_strfreev (details);
+}
+
+static void
+print_author (gpointer item, gpointer user_data) {
+	FILE *f = (FILE *)user_data;
+        print_someone (f, "author", (gchar *) item);
+}
+
+static void
+print_editor (gpointer item, gpointer user_data) {
+	FILE *f = (FILE *)user_data;
+        print_someone (f, "editor", (gchar *) item);
+}
+
+static void
+print_collab (gpointer item, gpointer user_data) {
+	FILE *f = (FILE *)user_data;
+        print_someone (f, "collab", (gchar *) item);
+}
+
+static gchar *
+shortname_to_id (const gchar *name)
+{
+        gchar *id, *p;
+
+        id = g_strdup (name);
+        p = strchr (id, ':');
+
+        if (p) {
+                *p = '-';
+        }
+
+        return id;
+}
+
+static void
+print_reference (gpointer item, gpointer user_data)
+{
+	gchar *shortname, *id;
+	FILE *f = (FILE *)user_data;
+
+	shortname = qname_to_shortname ((gchar *) item);
+        id = shortname_to_id (shortname);
+
+	g_fprintf (f,"<link linkend='%s'>%s</link>, ", id , shortname);
+
+	g_free (shortname);
+	g_free (id);
+}
+
+static void
+print_variablelist_entry (FILE        *f,
+                          const gchar *param,
+                          const gchar *value)
+{
+        g_fprintf (f, "<varlistentry>\n");
+        g_fprintf (f, "<term><parameter>%s</parameter>&#160;:</term>\n", param);
+        g_fprintf (f, "<listitem><simpara>%s</simpara></listitem>\n", (value) ? value : "--");
+        g_fprintf (f, "</varlistentry>\n");
+}
+
+static void
+print_variablelist_entry_list (FILE        *f,
+                               const gchar *param,
+                               GList       *list)
+{
+        g_fprintf (f, "<varlistentry>\n");
+        g_fprintf (f, "<term><parameter>%s</parameter>&#160;:</term>\n", param);
+        g_fprintf (f, "<listitem><simpara>");
+
+        if (list) {
+                g_list_foreach (list, print_reference, f);
+        } else {
+                g_fprintf (f, "--");
+        }
+
+        g_fprintf (f, "</simpara></listitem>\n");
+        g_fprintf (f, "</varlistentry>\n");
+}
+
+static void
+print_list (FILE *f, GList *list)
+{
+	GList *it;
+	gchar *shortname;
+
+	g_fprintf (f, "<td>");
+	for (it = list; it != NULL; it = it->next) {
+		shortname = qname_to_shortname ((gchar *)it->data);
+		g_fprintf (f, "%s%s", shortname, (it->next ? ", " : ""));
+		g_free (shortname);
+	}
+	g_fprintf (f, "</td>");
+}
+
+static void
+print_deprecated_message (FILE *f)
+{
+	g_fprintf (f,"<tr>");
+	g_fprintf (f,"<td class=\"deprecated\" colspan=\"2\">This item is deprecated.</td>\n");
+	g_fprintf (f,"</tr>\n");
+}
+
+static void
+print_sgml_header (FILE *f, OntologyDescription *desc)
+{
+        gchar *upper_name;
+
+        g_fprintf (f, "<?xml version='1.0' encoding='UTF-8'?>\n");
+
+        g_fprintf (f, "<chapter id='%s-ontology'>\n", desc->localPrefix);
+
+        upper_name = g_ascii_strup (desc->localPrefix, -1);
+        g_fprintf (f, "<title>%s Ontology</title>\n", upper_name);
+        g_free (upper_name);
+
+        /* FIXME: get rid of "<>" */
+#if 0
+        /* Ontology authors */
+        g_fprintf (f, "<authorgroup>\n");
+	g_list_foreach (desc->authors, print_author, f);
+	g_list_foreach (desc->editors, print_editor, f);
+        g_list_foreach (desc->contributors, print_collab, f);
+        g_fprintf (f, "</authorgroup>\n");
+#endif
+
+        /* FIXME: upstream version, gitlog, copyright */
+
+#if 0
+        g_fprintf (f,"<html>\n");
+	g_fprintf (f,"<head>\n");
+	g_fprintf (f,"\t<link rel=\"stylesheet\" type=\"text/css\"");
+	g_fprintf (f," href=\"../resources/nie-maemo.css\" />\n");
+	g_fprintf (f,"<title>%s</title>\n", desc->title);
+	g_fprintf (f,"</head>\n");
+	g_fprintf (f,"<body>\n");
+	g_fprintf (f,"<div class=\"head\">\n");
+	g_fprintf (f," <div class=\"nav\">\n");
+
+	/* Three logos at the top. Tracker, maemo, nepomuk */
+	g_fprintf (f, " <a href=\"http://www.tracker-project.org\";>");
+	g_fprintf (f, "<img alt=\"Tracker logo\" src=\"../resources/tracker-logo.png\" /></a> \n");
+	g_fprintf (f, " <a href=\"http://www.maemo.org\";> <img alt=\"MAEMO logo\" ");
+	g_fprintf (f, " src=\"../resources/maemo-logo.gif\" /></a>\n");
+	g_fprintf (f, " <a href=\"http://nepomuk.semanticdesktop.org\";> ");
+	g_fprintf (f, "<img alt=\"Nepomuk logo\"  src=\"../resources/nepomuk-logo.png\"/></a>\n");
+
+	g_fprintf (f,"</div>\n");
+	g_fprintf (f,"</div>\n");
+
+	g_fprintf (f,"<h1>%s</h1>\n", desc->title);
+	g_fprintf (f," <dl>\n");
+	if (desc->upstream) {
+		g_fprintf (f,"  <dt>Upstream:</dt><dd><a href=\"%s\">Upstream version</a></dd>\n",
+		           desc->upstream);
+	} else {
+		g_fprintf (f,"  <dt>Upstream:</dt><dd>Not available</dd>\n");
+	}
+	g_fprintf (f,"  <dt></dt>\n");
+	g_fprintf (f,"  <dt></dt>\n");
+	g_fprintf (f, "</dl>\n <dl>\n");
+	g_fprintf (f,"  <dt>Authors:</dt>\n");
+	g_list_foreach (desc->authors, print_author, f);
+	g_fprintf (f, "</dl>\n <dl>\n");
+	g_fprintf (f,"  <dt>Editors:</dt>\n");
+	g_list_foreach (desc->editors, print_author, f);
+	if (desc->contributors) {
+		g_fprintf (f, "</dl>\n <dl>\n");
+		g_fprintf (f,"  <dt>Contributors:</dt>\n");
+		g_list_foreach (desc->contributors, print_author, f);
+	}
+	g_fprintf (f, "</dl>\n <dl>\n");
+	g_fprintf (f,"  <dt>Changelog:</dt>\n");
+	g_fprintf (f,"  <dd><a href=\"%s\">Tracker changes</a>",
+	           (desc->gitlog ? desc->gitlog : "#"));
+	g_fprintf (f," </dl>\n");
+	g_fprintf (f,"</div>\n");
+	g_fprintf (f,"<p class=\"copyright\">%s</p>\n",
+	           (desc->copyright ? desc->copyright : DEFAULT_COPYRIGHT));
+
+	g_fprintf (f,"<hr />\n");
+#endif
+}
+
+static void
+print_sgml_explanation (FILE *f, const gchar *explanation_file)
+{
+	gchar *raw_content;
+	gint   length;
+
+	if (explanation_file && g_file_test (explanation_file, G_FILE_TEST_EXISTS)) {
+		if (!g_file_get_contents (explanation_file, &raw_content, &length, NULL)) {
+			g_error ("Unable to load '%s'", explanation_file );
+		}
+		g_fprintf (f, "%s", raw_content);
+	}
+}
+
+static void
+print_sgml_footer (FILE *f)
+{
+	g_fprintf (f,"</chapter>\n");
+}
+
+static void
+print_ontology_class (gpointer key, gpointer value, gpointer user_data)
+{
+	OntologyClass *def = (OntologyClass *)value;
+	gchar *name, *id;
+	FILE *f = (FILE *)user_data;
+
+	g_return_if_fail (f != NULL);
+
+	name = qname_to_shortname (def->classname);
+
+        id = shortname_to_id (name);
+        g_fprintf (f, "<refsect2 id='%s'>\n", id);
+        g_free (id);
+
+        g_fprintf (f, "<title>%s</title>\n", name);
+
+        if (def->description) {
+                g_fprintf (f, "<para>%s</para>\n", def->description);
+        }
+
+        g_fprintf (f, "<variablelist>\n");
+
+        print_variablelist_entry_list (f, "Superclasses", def->superclasses);
+        print_variablelist_entry_list (f, "Subclasses", def->subclasses);
+        print_variablelist_entry_list (f, "In domain of", def->in_domain_of);
+        print_variablelist_entry_list (f, "In range of", def->in_range_of);
+
+        if (def->instances) {
+                print_variablelist_entry_list (f, "Predefined instances", def->instances);
+        }
+
+        g_fprintf (f, "</variablelist>\n");
+
+        if (def->notify) {
+                g_fprintf (f, "<note>\n");
+                g_fprintf (f, "<title>Note:</title>\n");
+                g_fprintf (f, "<para>This class notifies about changes</para>\n");
+                g_fprintf (f, "</note>\n");
+        }
+
+        g_fprintf (f, "</refsect2>\n\n");
+
+        g_free (name);
+}
+
+static void
+print_ontology_property (gpointer key, gpointer value, gpointer user_data)
+{
+	OntologyProperty *def = (OntologyProperty *) value;
+	gchar *name, *id;
+	FILE *f = (FILE *) user_data;
+
+	g_return_if_fail (f != NULL);
+
+	name = qname_to_shortname (def->propertyname);
+        id = shortname_to_id (name);
+
+        g_fprintf (f, "<refsect2 id='%s'>\n", id);
+        g_free (id);
+
+        g_fprintf (f, "<title>%s</title>\n", name);
+
+        if (def->description) {
+                g_fprintf (f, "<para>%s</para>\n", def->description);
+        }
+
+
+        g_fprintf (f, "<variablelist>\n");
+
+        print_variablelist_entry_list (f, "Type", def->type);
+        print_variablelist_entry_list (f, "Domain", def->domain);
+        print_variablelist_entry_list (f, "Range", def->range);
+        print_variablelist_entry_list (f, "Superproperties", def->superproperties);
+        print_variablelist_entry_list (f, "Subproperties", def->subproperties);
+
+        if (def->max_cardinality) {
+                print_variablelist_entry (f, "Cardinality", def->max_cardinality);
+        }
+
+        g_fprintf (f, "</variablelist>\n");
+        g_fprintf (f, "</refsect2>\n\n");
+}
+
+void
+ttl_sgml_print (OntologyDescription *description,
+                Ontology *ontology,
+                FILE *f,
+                const gchar *class_location_file,
+                const gchar *explanation_file)
+{
+        gchar *upper_name;
+
+        upper_name = g_ascii_strup (description->localPrefix, -1);
+
+        qname_init (description->baseUrl, description->localPrefix, class_location_file);
+	print_sgml_header (f, description);
+
+        /* FIXME: make desc files sgml */
+	/* print_sgml_explanation (f, explanation_file); */
+
+        g_fprintf (f, "<section id='%s-classes'>\n", description->localPrefix);
+	g_fprintf (f, "<title>%s Ontology Classes</title>\n", upper_name);
+	g_hash_table_foreach (ontology->classes, print_ontology_class, f);
+        g_fprintf (f, "</section>\n");
+
+        g_fprintf (f, "<section id='%s-properties'>\n", description->localPrefix);
+	g_fprintf (f, "<title>%s Ontology Properties</title>\n", upper_name);
+	g_hash_table_foreach (ontology->properties, print_ontology_property, f);
+        g_fprintf (f, "</section>\n");
+
+	print_sgml_footer (f);
+
+        g_free (upper_name);
+}
diff --git a/utils/services/ttl_html.h b/docs/tools/ttl_sgml.h
similarity index 73%
rename from utils/services/ttl_html.h
rename to docs/tools/ttl_sgml.h
index b85463c..e016c19 100644
--- a/utils/services/ttl_html.h
+++ b/docs/tools/ttl_sgml.h
@@ -1,5 +1,5 @@
-#ifndef __TTL_HTML_H__
-#define __TTL_HTML_H__
+#ifndef __TTL_SGML_H__
+#define __TTL_SGML_H__
 
 #include <gio/gio.h>
 #include "ttl_model.h"
@@ -7,7 +7,7 @@
 
 G_BEGIN_DECLS
 
-void ttl_html_print (OntologyDescription *description,
+void ttl_sgml_print (OntologyDescription *description,
                      Ontology *ontology,
                      FILE *output,
                      const gchar *class_location,
diff --git a/utils/Makefile.am b/utils/Makefile.am
index ad3a6ea..f10bdbc 100644
--- a/utils/Makefile.am
+++ b/utils/Makefile.am
@@ -5,5 +5,4 @@ SUBDIRS = 			\
 	lyrics			\
 	ontology		\
 	playlists		\
-	services		\
 	tracker-fts



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]