[tracker/sam/ontology-docs: 19/22] docs: Fix links to properties
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sam/ontology-docs: 19/22] docs: Fix links to properties
- Date: Mon, 13 Apr 2020 00:05:14 +0000 (UTC)
commit b0b33bd5db79f84d39693ab953e560ebe2744408
Author: Sam Thursfield <sam afuera me uk>
Date: Sun Apr 12 22:12:23 2020 +0200
docs: Fix links to properties
docs/tools/ttl_xml.c | 8 ++++----
docs/tools/ttlresource2xml.c | 28 +++++++++++++++++-----------
docs/tools/ttlresource2xml.h | 1 +
3 files changed, 22 insertions(+), 15 deletions(-)
---
diff --git a/docs/tools/ttl_xml.c b/docs/tools/ttl_xml.c
index a8ca8d9b9..a32e377b2 100644
--- a/docs/tools/ttl_xml.c
+++ b/docs/tools/ttl_xml.c
@@ -240,17 +240,17 @@ print_toc_extra_properties (FILE *f,
while (g_hash_table_iter_next (&iter, (gpointer*) &classname, (gpointer*) &props_for_class)) {
for (l = props_for_class; l; l = l->next) {
OntologyProperty *prop;
- g_autofree char *basename = NULL, *id = NULL;
+ g_autofree char *basename = NULL, *class_id = NULL;
prop = g_hash_table_lookup (ontology->properties, l->data);
basename = ttl_model_name_to_basename (ontology, prop->propertyname);
- id = ttl_model_name_to_shortname (ontology, prop->propertyname, "-");
+ class_id = ttl_model_name_to_shortname (ontology, classname, "-");
if (l != props_for_class) {
g_fprintf (f, ", ");
}
- g_fprintf (f, "<link linkend=\"%s\">%s</link>", id, basename);
+ g_fprintf (f, "<link linkend=\"%s.%s.property.%s\">%s</link>", id, class_id,
basename, basename);
}
}
@@ -316,7 +316,7 @@ ttl_xml_print (OntologyDescription *description,
g_hash_table_iter_init (&iter, extra_properties);
while (g_hash_table_iter_next (&iter, (gpointer *)&classname, (gpointer
*)&properties_for_class)) {
- print_ontology_extra_properties (ontology, classname, properties_for_class, f);
+ print_ontology_extra_properties (ontology, description->localPrefix, classname,
properties_for_class, f);
}
g_fprintf (f, "</refsect1>\n");
diff --git a/docs/tools/ttlresource2xml.c b/docs/tools/ttlresource2xml.c
index 212f430c0..186a48b83 100644
--- a/docs/tools/ttlresource2xml.c
+++ b/docs/tools/ttlresource2xml.c
@@ -560,16 +560,14 @@ print_class_hierarchy (FILE *f,
static void
print_property_table (FILE *f,
Ontology *ontology,
- const char *classname,
+ const char *id,
GList *properties)
{
- g_autofree gchar *id = NULL;
GList *l;
if (!properties)
return;
- id = ttl_model_name_to_shortname (ontology, classname, "-");
g_fprintf (f, "<refsect3 id='%s.properties'>", id);
g_fprintf (f, "<title>Properties</title>");
@@ -594,6 +592,8 @@ print_property_table (FILE *f,
g_fprintf (f, "<td>");
g_fprintf (f, "<indexterm zone='%s.%s'><primary sortas='%s'>%s</primary></indexterm>",
id, prop_id, shortname, shortname);
+ g_fprintf (f, "<anchor id='%s.property.%s' />",
+ id, basename);
g_fprintf (f, "%s", basename);
g_fprintf (f, "</td>");
@@ -700,31 +700,37 @@ print_ontology_class (Ontology *ontology,
print_predefined_instances (f, klass, ontology);
print_fts_properties (f, klass, ontology);
- print_property_table (f, ontology, klass->classname, klass->in_domain_of);
+ print_property_table (f, ontology, id, klass->in_domain_of);
g_fprintf (f, "</refsect2>\n");
}
void
print_ontology_extra_properties (Ontology *ontology,
+ const char *ontology_prefix,
const char *classname,
GList *properties_for_class,
FILE *f)
{
- g_autofree gchar *id = NULL;
+ g_autofree gchar *short_classname = NULL;
+ g_autofree gchar *section_id = NULL, *class_id = NULL;
g_return_if_fail (f != NULL);
- id = ttl_model_name_to_shortname (ontology, classname, "-");
+ short_classname = ttl_model_name_to_shortname (ontology, classname, ":");
- g_fprintf (f, "<refsect2 id='%s'>\n", id);
- g_fprintf (f, "<title>Properties for %s</title>\n", id);
+ class_id = ttl_model_name_to_shortname (ontology, classname, "-");
+ section_id = g_strconcat (ontology_prefix, ".", class_id, NULL);
- g_fprintf (f, "<refsect3 id='%s.description'>\n", id);
+ g_fprintf (f, "<refsect2 id='%s'>\n", section_id);
+ g_fprintf (f, "<title>Properties for %s</title>\n", short_classname);
+
+ g_fprintf (f, "<refsect3>\n");
g_fprintf (f, " <title>Description</title>\n");
- g_fprintf (f, " <para>Properties which can be used for %s resources.</para>", id);
+ g_fprintf (f, " <para>Properties which can be used for %s resources.</para>",
+ short_classname);
g_fprintf (f, "</refsect3>\n");
- print_property_table (f, ontology, classname, properties_for_class);
+ print_property_table (f, ontology, section_id, properties_for_class);
g_fprintf (f, "</refsect2>\n");
}
diff --git a/docs/tools/ttlresource2xml.h b/docs/tools/ttlresource2xml.h
index f35f32a57..748e5bff0 100644
--- a/docs/tools/ttlresource2xml.h
+++ b/docs/tools/ttlresource2xml.h
@@ -31,6 +31,7 @@ void print_ontology_class (Ontology *ontology,
OntologyClass *klass,
FILE *f);
void print_ontology_extra_properties (Ontology *ontology,
+ const char *ontology_prefix,
const char *classname,
GList *properties_for_class,
FILE *f);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]