[tracker] Doc: Show in HTML when a class/property is marked as deprecated
- From: Ivan Frade <ifrade src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] Doc: Show in HTML when a class/property is marked as deprecated
- Date: Wed, 9 Dec 2009 12:31:20 +0000 (UTC)
commit fefe13d1b2a0c41e1a87cf538bc81aa8c323d379
Author: Ivan Frade <ivan frade nokia com>
Date: Wed Dec 9 14:28:28 2009 +0200
Doc: Show in HTML when a class/property is marked as deprecated
utils/services/resources/nie-maemo.css | 13 +++++++++
utils/services/ttl_html.c | 30 +++++++++++++++++---
utils/services/ttl_loader.c | 46 +++++++++++++++++++++++++------
utils/services/ttl_model.c | 2 +
utils/services/ttl_model.h | 2 +
5 files changed, 79 insertions(+), 14 deletions(-)
---
diff --git a/utils/services/resources/nie-maemo.css b/utils/services/resources/nie-maemo.css
index 0321f40..07fc22f 100644
--- a/utils/services/resources/nie-maemo.css
+++ b/utils/services/resources/nie-maemo.css
@@ -45,6 +45,19 @@ TD.rowheader {
width: 20%;
}
+/* Deprecated class/properties */
+table.deprecated {
+ border: dotted;
+}
+
+td.deprecated {
+ color: #f88324;
+}
+
+h3.deprecated {
+ color: #f88324;
+}
+
:visited {
color: #609;
background: transparent
diff --git a/utils/services/ttl_html.c b/utils/services/ttl_html.c
index a6b8b78..211eea9 100644
--- a/utils/services/ttl_html.c
+++ b/utils/services/ttl_html.c
@@ -65,6 +65,14 @@ print_list (FILE *f, GList *list)
}
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_html_header (FILE *f, OntologyDescription *desc)
{
g_fprintf (f,"<html>\n");
@@ -162,11 +170,16 @@ print_ontology_class (gpointer key, gpointer value, gpointer user_data)
g_fprintf (f,"<a name=\"%s\">\n", &anchor[1]);
g_free (anchor);
- g_fprintf (f,"<h3>%s</h3>\n", name);
+ if (def->deprecated) {
+ g_fprintf (f,"<h3 class=\"deprecated\">%s</h3>\n", name);
+ g_fprintf (f,"<table class=\"deprecated\">\n");
+ print_deprecated_message (f);
+ } else {
+ g_fprintf (f,"<h3>%s</h3>\n", name);
+ g_fprintf (f,"<table class=\"doctable\">\n");
+ }
g_free (name);
- g_fprintf (f,"<table class=\"doctable\">\n");
-
g_fprintf (f,"<tr>");
g_fprintf (f,"<td class=\"rowheader\">Superclasses</td>");
print_references_list (f, def->superclasses);
@@ -226,9 +239,16 @@ print_ontology_property (gpointer key, gpointer value, gpointer user_data)
g_fprintf (f,"<a name=\"%s\">", &anchor[1]);
g_free (anchor);
- g_fprintf (f,"<h3>%s</h3>\n", name);
+ if (def->deprecated) {
+ g_fprintf (f,"<h3 class=\"deprecated\">%s</h3>\n", name);
+ g_fprintf (f,"<table class=\"deprecated\">\n");
+ print_deprecated_message (f);
+ } else {
+ g_fprintf (f,"<h3>%s</h3>\n", name);
+ g_fprintf (f,"<table class=\"doctable\">\n");
+ }
g_free (name);
- g_fprintf (f,"<table class=\"doctable\">\n");
+
g_fprintf (f,"<tr>");
g_fprintf (f,"<td class=\"rowheader\">Type</td>");
diff --git a/utils/services/ttl_loader.c b/utils/services/ttl_loader.c
index 58429bf..dfdc563 100644
--- a/utils/services/ttl_loader.c
+++ b/utils/services/ttl_loader.c
@@ -20,6 +20,8 @@
#define TRACKER_NS "http://www.tracker-project.org/ontologies/tracker#"
#define TRACKER_NOTIFY TRACKER_NS "notify"
+#define NAO_DEPRECATED "http://www.semanticdesktop.org/ontologies/2007/08/15/nao#deprecated"
+
/* Ontology description */
#define DSC_PREFIX "http://www.tracker-project.org/temp/dsc#"
@@ -35,6 +37,18 @@
#define DSC_LOCALPREFIX DSC_PREFIX "localPrefix"
#define DSC_COPYRIGHT DSC_PREFIX "copyright"
+static gboolean
+string_to_boolean (const gchar *str) {
+ if (!g_strcmp0 (str, "true")) {
+ return TRUE;
+ } else if (!g_strcmp0 (str, "false")) {
+ return FALSE;
+ } else {
+ g_error ("Unable to map '%s' into boolean", str);
+ }
+}
+
+
static void
load_in_memory (Ontology *ontology,
const gchar *turtle_subject,
@@ -101,13 +115,8 @@ load_in_memory (Ontology *ontology,
g_error ("Something wrong");
}
- if (!g_strcmp0 (turtle_object, "true")) {
- def->notify = TRUE;
- } else if (!g_strcmp0 (turtle_object, "false")) {
- def->notify = FALSE;
- } else {
- g_error ("Unable to map '%s' into boolean", turtle_object);
- }
+ def->notify = string_to_boolean (turtle_object);
+
} else if (!g_strcmp0 (turtle_predicate, RDFS_COMMENT)) {
OntologyClass *klass;
OntologyProperty *prop;
@@ -199,11 +208,30 @@ load_in_memory (Ontology *ontology,
g_strdup (turtle_subject));
}
+ } else if (!g_strcmp0 (turtle_predicate, NAO_DEPRECATED)) {
+ /*
+ * X nao:deprecated true
+ *
+ * This can apply to classes OR properties!
+ */
+ OntologyProperty *prop;
+ OntologyClass *klass;
-
+ prop = g_hash_table_lookup (ontology->properties, turtle_subject);
+ if (prop) {
+ prop->deprecated = string_to_boolean (turtle_object);
+ } else {
+ /* Try with a class */
+ klass = g_hash_table_lookup (ontology->classes, turtle_subject);
+ if (klass) {
+ klass->deprecated = string_to_boolean (turtle_object);
+ } else {
+ g_error ("'%s' is not a class nor a property!?", turtle_subject);
+ }
+ }
} else if (!g_strcmp0 (turtle_predicate, RDFS_LABEL)) {
- /* Intentionalyy ignored */
+ /* Intentionaly ignored */
} else {
/* DEBUG
g_print ("UNHANDLED %s %s %s\n",
diff --git a/utils/services/ttl_model.c b/utils/services/ttl_model.c
index ccf4c29..6b32118 100644
--- a/utils/services/ttl_model.c
+++ b/utils/services/ttl_model.c
@@ -15,6 +15,7 @@ ttl_model_class_new (const gchar *classname)
def->description = NULL;
def->instances = NULL;
def->notify = FALSE;
+ def->deprecated = FALSE;
return def;
}
@@ -53,6 +54,7 @@ ttl_model_property_new (const gchar *propname)
prop->subproperties = NULL;
prop->max_cardinality = NULL;
prop->description = NULL;
+ prop->deprecated = FALSE;
return prop;
}
diff --git a/utils/services/ttl_model.h b/utils/services/ttl_model.h
index 733e4af..47af64d 100644
--- a/utils/services/ttl_model.h
+++ b/utils/services/ttl_model.h
@@ -14,6 +14,7 @@ typedef struct {
gchar *description;
GList *instances;
gboolean notify;
+ gboolean deprecated;
} OntologyClass;
typedef struct {
@@ -25,6 +26,7 @@ typedef struct {
GList *subproperties;
gchar *max_cardinality;
gchar *description;
+ gboolean deprecated;
} OntologyProperty;
typedef struct {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]