ttlresource2sgml.c 20.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*
 * Copyright (C) 2015, Carlos Garnacho
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *
 * Authors: Carlos Garnacho <carlosg@gnome.org>
 */

#include <glib-object.h>
#include <glib/gprintf.h>
#include <gio/gio.h>
#include "ttl_loader.h"
#include "ttl_model.h"
#include "ttl_sgml.h"
28
#include "ttlresource2sgml.h"
29 30 31 32 33

#define TRACKER_ONTOLOGY_CLASS "http://www.tracker-project.org/ontologies/tracker#Ontology"

static void
class_get_parent_hierarchy (Ontology       *ontology,
34
                            const gchar    *class_name,
35 36
                            GList         **list)
{
37
	OntologyClass *klass;
38 39 40
	GList *l;

	/* Ensure we only got the same class there once */
41 42
	*list = g_list_remove (*list, (gpointer) class_name);
	*list = g_list_prepend (*list, (gpointer) class_name);
43

44 45 46 47 48 49
	klass = g_hash_table_lookup (ontology->classes, class_name);
	if (!klass) {
		klass = ttl_model_class_new (class_name);
		g_hash_table_insert (ontology->classes, klass->classname, klass);
		return;
	}
50

51 52
	for (l = klass->superclasses; l; l = l->next) {
		class_get_parent_hierarchy (ontology, l->data, list);
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
	}
}

static GList *
class_get_hierarchy (Ontology      *ontology,
                     OntologyClass *klass)
{
	GList *hierarchy = NULL, *l;

	/* Order is: parents, this class, and children. Guaranteed
	 * to be in an order where all parents are before a child.
	 * We first prepend all children, and then find out the
	 * upwards hierarchy recursively.
	 */
	for (l = klass->subclasses; l; l = l->next) {
		hierarchy = g_list_prepend (hierarchy, l->data);
	}

71
	class_get_parent_hierarchy (ontology, klass->classname, &hierarchy);
72 73 74 75 76 77 78 79 80 81 82

	return hierarchy;
}

static void
print_sgml_header (FILE          *f,
                   OntologyClass *klass,
                   Ontology      *ontology)
{
	gchar *id, *shortname;

83 84
	id = ttl_model_name_to_shortname (ontology, klass->classname, "-");
	shortname = ttl_model_name_to_shortname (ontology, klass->classname, NULL);
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128

        g_fprintf (f, "<?xml version='1.0' encoding='UTF-8'?>\n");
        g_fprintf (f, "<refentry id='%s'>\n", id);

        g_fprintf (f, "<refmeta><refentrytitle>%s</refentrytitle></refmeta>", shortname);
        g_fprintf (f, "<refnamediv><refname>%s</refname></refnamediv>", shortname);

	g_fprintf (f, "<refsect1 id='%s.description'>", id);

	if (klass->description) {
		g_fprintf (f, "<title>Description</title>\n");
		g_fprintf (f, "<para>%s</para>\n", klass->description);
	}

	if (klass->deprecated)
		g_fprintf (f, "<note><para>This class is deprecated.</para></note>\n");

	if (klass->notify)
		g_fprintf (f, "<note><para>This class emits notifications about changes, and can "
		           "be tracked through the <literal>GraphUpdated</literal> DBus signal.</para></note>\n");

	g_fprintf (f, "</refsect1>");

	g_free (shortname);
	g_free (id);
}

static void
print_sgml_footer (FILE *f)
{
	g_fprintf (f, "</refentry>\n");
}

static void
print_predefined_instances (FILE          *f,
                            OntologyClass *klass,
                            Ontology      *ontology)
{
	gchar *shortname, *id;
	GList *l;

	if (!klass->instances)
		return;

129 130
	shortname = ttl_model_name_to_shortname (ontology, klass->classname, NULL);
	id = ttl_model_name_to_shortname (ontology, klass->classname, "-");
131 132 133 134 135 136 137 138 139 140

	g_fprintf (f, "<refsect1 id='%s.predefined-instances'>", id);
	g_fprintf (f, "<title>Predefined instances</title><para>");
	g_fprintf (f, "%s has the following predefined instances: ", shortname);
        g_fprintf (f, "<itemizedlist>\n");

	g_free (shortname);
	g_free (id);

	for (l = klass->instances; l; l = l->next) {
141 142
		shortname = ttl_model_name_to_shortname (ontology, l->data, NULL);
		id = ttl_model_name_to_shortname (ontology, l->data, "-");
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173

		g_fprintf (f, "<listitem><para>");
		g_fprintf (f, "<link linkend=\"%s\">%s</link>", id, shortname);
		g_fprintf (f, "</para></listitem>\n");
		g_free (shortname);
		g_free (id);
	}

	g_fprintf (f, "</itemizedlist></para></refsect1>\n");
}

static void
print_fts_properties (FILE          *f,
                      OntologyClass *klass,
                      Ontology      *ontology)
{
	gchar *shortname, *id;
	GList *l, *fts_props = NULL;

	for (l = klass->in_domain_of; l; l = l->next) {
		OntologyProperty *prop;

		prop = g_hash_table_lookup (ontology->properties, l->data);

		if (prop->fulltextIndexed)
			fts_props = g_list_prepend (fts_props, prop);
	}

	if (!fts_props)
		return;

174 175
	shortname = ttl_model_name_to_shortname (ontology, klass->classname, NULL);
	id = ttl_model_name_to_shortname (ontology, klass->classname, "-");
176 177 178 179 180 181 182 183 184 185

	g_fprintf (f, "<refsect1 id='%s.fts-properties'>", id);
	g_fprintf (f, "<title>Full-text-indexed properties</title><para>");
	g_fprintf (f, "%s has the following full-text-indexed properties: ", shortname);
        g_fprintf (f, "<itemizedlist>\n");

	for (l = fts_props; l; l = l->next) {
		gchar *prop_shortname, *prop_id;
		OntologyProperty *prop = l->data;

186 187
		prop_shortname = ttl_model_name_to_shortname (ontology, prop->propertyname, NULL);
		prop_id = ttl_model_name_to_shortname (ontology, prop->propertyname, "-");
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380

		g_fprintf (f, "<listitem><para>");
		g_fprintf (f, "<link linkend=\"%s.%s\">%s</link>", id, prop_id, prop_shortname);
		g_fprintf (f, "</para></listitem>\n");
		g_free (prop_shortname);
		g_free (prop_id);
	}

	g_fprintf (f, "</itemizedlist></para></refsect1>\n");
	g_free (shortname);
	g_free (id);
}

typedef struct {
	GString *str;
	gint visible_len;
} HierarchyString;

typedef struct {
	OntologyClass *class;
	GList *hierarchy;
	GHashTable *resolved_children;
	GHashTable *resolved_parents;
	GHashTable *placed;
	GPtrArray *strings;
} HierarchyContext;

static HierarchyString *
hierarchy_string_new (void)
{
	HierarchyString *str;

	str = g_new0 (HierarchyString, 1);
	str->str = g_string_new ("");

	return str;
}

static void
hierarchy_string_free (HierarchyString *str)
{
	g_string_free (str->str, TRUE);
	g_free (str);
}

static void
hierarchy_string_append (HierarchyString *str,
                         const gchar     *substr)
{
	g_string_append (str->str, substr);
	str->visible_len += g_utf8_strlen (substr, -1);
}

static void
hierarchy_string_append_link (HierarchyString *str,
                              const gchar     *substr,
                              const gchar     *link,
                              gboolean         bold)
{
	if (bold)
		g_string_append_printf (str->str, "<emphasis><link linkend=\"%s\">%s</link></emphasis>",
					link, substr);
	else
		g_string_append_printf (str->str, "<link linkend=\"%s\">%s</link>", link, substr);

	str->visible_len += g_utf8_strlen (substr, -1);
}

static GList *
list_filter (GList *original,
             GList *valid)
{
	GList *l, *filtered = NULL;

	for (l = original; l; l = l->next) {
		if (!g_list_find_custom (valid, l->data,
		                         (GCompareFunc) g_strcmp0))
			continue;

		filtered = g_list_prepend (filtered, l->data);
	}

	return filtered;
}

static HierarchyContext *
hierarchy_context_new (OntologyClass *klass,
                       Ontology      *ontology)
{
	HierarchyContext *context;
	GList *l;

	context = g_new0 (HierarchyContext, 1);
	context->class = klass;
	context->hierarchy = class_get_hierarchy (ontology, klass);
	context->placed = g_hash_table_new (g_str_hash, g_str_equal);
	context->resolved_parents = g_hash_table_new_full (g_str_hash,
	                                                   g_str_equal,
	                                                   NULL,
	                                                   (GDestroyNotify) g_list_free);
	context->resolved_children = g_hash_table_new_full (g_str_hash,
	                                                    g_str_equal,
	                                                    NULL,
	                                                    (GDestroyNotify) g_list_free);
	context->strings = g_ptr_array_new_with_free_func ((GDestroyNotify) hierarchy_string_free);

	for (l = context->hierarchy; l; l = l->next) {
		OntologyClass *cl = g_hash_table_lookup (ontology->classes, l->data);

		g_hash_table_insert (context->resolved_parents,
		                     cl->classname,
		                     list_filter (cl->superclasses,
		                                  context->hierarchy));
		g_hash_table_insert (context->resolved_children,
		                     cl->classname,
		                     list_filter (cl->subclasses,
		                                  context->hierarchy));

		g_ptr_array_add (context->strings, hierarchy_string_new ());
	}

	return context;
}

static void
hierarchy_context_free (HierarchyContext *context)
{
	g_ptr_array_unref (context->strings);
	g_hash_table_unref (context->placed);
	g_hash_table_unref (context->resolved_parents);
	g_hash_table_unref (context->resolved_children);
	g_free (context);
}

static GList *
hierarchy_context_get_single_parented_children (HierarchyContext *context,
                                                OntologyClass    *klass,
                                                Ontology         *ontology)
{
	GList *filtered = NULL, *children, *l;

	children = g_hash_table_lookup (context->resolved_children,
	                                klass->classname);

	for (l = children; l; l = l->next) {
		GList *parents;

		parents = g_hash_table_lookup (context->resolved_parents, l->data);

		if (g_list_length (parents) == 1)
			filtered = g_list_prepend (filtered, l->data);
	}

	return filtered;
}

static void
fill_padding (HierarchyString *str,
              gint             max_len,
              gchar           *substr)
{
	gint padding = max_len - str->visible_len;

	if (padding <= 0)
		return;

	while (padding > 0) {
		hierarchy_string_append (str, substr);
		padding--;
	}
}

static gboolean
check_parents_placed (GList      *parents,
                      GHashTable *ht)
{
	GList *l;

	for (l = parents; l; l = l->next) {
		if (!g_hash_table_lookup (ht, l->data))
			return FALSE;
	}

	return TRUE;
}

static void
hierarchy_context_resolve_class (HierarchyContext *context,
                                 OntologyClass    *klass,
                                 Ontology         *ontology)
{
	GList *l = g_list_find_custom (context->hierarchy, klass->classname,
				       (GCompareFunc) g_strcmp0);
381
	gint pos = g_list_position (context->hierarchy, l);
382 383 384 385 386 387 388 389
	GList *children, *parents;
	gchar *shortname, *link;
	HierarchyString *str;
	gboolean is_child;

	if (pos < 0)
		return;

390 391
	shortname = ttl_model_name_to_shortname (ontology, klass->classname, NULL);
	link = ttl_model_name_to_shortname (ontology, klass->classname, "-");
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538
	parents = g_hash_table_lookup (context->resolved_parents,
	                               klass->classname);

	if (g_list_length (parents) > 1) {
		gboolean first_pending = TRUE;
		gint i, max_len = 0;

		/* This class has more than one parent in the current graph,
		 * those paint the lines on the right side.
		 */

		/* Step 1: Find the longest string */
		first_pending = TRUE;
		for (i = 0, l = context->hierarchy; i < pos && l; i++, l = l->next) {
			is_child = g_list_find_custom (klass->superclasses, l->data,
			                               (GCompareFunc) g_strcmp0) != NULL;
			if (!is_child && first_pending)
				continue;

			str = g_ptr_array_index (context->strings, i);
			max_len = MAX (max_len, str->visible_len);
		}

		/* Step 2: append the line art, we must fill in some padding if
		 * necessary.
		 */
		first_pending = TRUE;
		for (i = 0, l = context->hierarchy; i < pos && l; i++, l = l->next) {
			is_child = g_list_find_custom (klass->superclasses, l->data,
			                               (GCompareFunc) g_strcmp0) != NULL;

			if (!is_child && first_pending)
				continue;

			str = g_ptr_array_index (context->strings, i);

			fill_padding (str, max_len, is_child ? "─" : " ");

			if (first_pending) {
				hierarchy_string_append (str, "──┐");
				first_pending = FALSE;
			} else if (is_child) {
				hierarchy_string_append (str, "──┤");
			} else {
				hierarchy_string_append (str, "  │");
			}
		}

		/* Step 3: Finally, print the current class */
		str = g_ptr_array_index (context->strings, pos);
		fill_padding (str, max_len - 1, " ");

		hierarchy_string_append (str, "   └── ");
		hierarchy_string_append_link (str, shortname, link, klass == context->class);
		hierarchy_string_append (str, " ");
	} else {
		/* The current class has only 1 parent, lineart for those is
		 * displayed on the left side.
		 */

		/* Step 1: Print the current class */
		str = g_ptr_array_index (context->strings, pos);
		hierarchy_string_append_link (str, shortname, link, klass == context->class);
		hierarchy_string_append (str, " ");

		/* Step 2: Modify all strings downwards, adding the lineart
		 * necessary for all children of this class.
		 */
		children = hierarchy_context_get_single_parented_children (context, klass, ontology);
		l = l->next;
		pos++;

		for (; l; l = l->next, pos++) {
			guint len = g_list_length (children);
			GList *cur;

			str = g_ptr_array_index (context->strings, pos);
			cur = g_list_find_custom (children, l->data,
			                          (GCompareFunc) g_strcmp0);
			is_child = (cur != NULL);

			if (is_child) {
				if (len > 1)
					hierarchy_string_append (str, "├── ");
				else if (len == 1)
					hierarchy_string_append (str, "╰── ");

				children = g_list_delete_link (children, cur);
				g_hash_table_insert (context->placed,
				                     l->data, GINT_TO_POINTER (TRUE));
			} else {
				if (len > 0)
					hierarchy_string_append (str, "│   ");
				else if (len == 0 &&
					 !g_hash_table_lookup (context->placed, l->data)) {
					GList *cl_parents;

					cl_parents = g_hash_table_lookup (context->resolved_parents, l->data);

					if (g_list_length (cl_parents) == 1 ||
					    !check_parents_placed (cl_parents, context->placed)) {
						hierarchy_string_append (str, "    ");
					}
				}
			}
		}
	}

	g_free (shortname);
	g_free (link);
}

static GPtrArray *
class_get_parent_hierarchy_strings (OntologyClass *klass,
                                    Ontology      *ontology)
{
	HierarchyContext *context;
	GList *c;
	GPtrArray *strings;

	context = hierarchy_context_new (klass, ontology);

	for (c = context->hierarchy; c; c = c->next) {
		OntologyClass *cl = g_hash_table_lookup (ontology->classes, c->data);
		hierarchy_context_resolve_class (context, cl, ontology);
	}

	strings = g_ptr_array_ref (context->strings);
	hierarchy_context_free (context);

	return strings;
}

static void
print_class_hierarchy (FILE          *f,
                       OntologyClass *klass,
                       Ontology      *ontology)
{
	GPtrArray *strings;
	gchar *id;
	gint i;

	strings = class_get_parent_hierarchy_strings (klass, ontology);

	if (!strings)
		return;

539
	id = ttl_model_name_to_shortname (ontology, klass->classname, "-");
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566

	g_fprintf (f, "<refsect1 id='%s.hierarchy'>", id);
	g_fprintf (f, "<title>Class hierarchy</title>");
	g_fprintf (f, "<screen>");

	g_free (id);

	for (i = 0; i < strings->len; i++) {
		HierarchyString *str = g_ptr_array_index (strings, i);
		g_fprintf (f, "    %s\n", str->str->str);
	}

	g_fprintf (f, "</screen></refsect1>\n");
	g_ptr_array_unref (strings);
}

static void
print_properties (FILE          *f,
                  OntologyClass *klass,
                  Ontology      *ontology)
{
	gchar *id, *prop_id, *shortname, *type_name, *type_class_id;
	GList *l;

	if (!klass->in_domain_of)
		return;

567
	id = ttl_model_name_to_shortname (ontology, klass->classname, "-");
568 569 570 571 572 573 574 575
	g_fprintf (f, "<refsect1 id='%s.properties'>", id);
	g_fprintf (f, "<title>Properties</title>");

	for (l = klass->in_domain_of; l; l = l->next) {
		OntologyProperty *prop;

		prop = g_hash_table_lookup (ontology->properties, l->data);

576 577 578 579
		prop_id = ttl_model_name_to_shortname (ontology, prop->propertyname, "-");
		shortname = ttl_model_name_to_shortname (ontology, prop->propertyname, NULL);
		type_name = ttl_model_name_to_shortname (ontology, prop->range->data, NULL);
		type_class_id = ttl_model_name_to_shortname (ontology, prop->range->data, "-");
580

581 582 583
		g_fprintf (f, "<refsect2 id='%s.%s' role='property'>", id, prop_id);
		g_fprintf (f, "<indexterm zone='%s.%s'><primary sortas='%s'>%s</primary></indexterm>",
		           id, prop_id, shortname, shortname);
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620
		g_fprintf (f, "<title>The <literal>“%s”</literal> property</title>", shortname);
		g_fprintf (f, "<programlisting>“%s”"
			   "          <link linkend=\"%s\">%s</link>"
			   "</programlisting>",
			   shortname, type_class_id, type_name);

		if (prop->description) {
			g_fprintf (f, "<para>%s</para>", prop->description);
		}

		if (prop->max_cardinality) {
			g_fprintf (f, "<para>Number of possible elements per resource (Cardinality): %s</para>",
				   prop->max_cardinality);
		} else {
			g_fprintf (f, "<para>Number of possible elements per resource (Cardinality): Unlimited</para>");
		}

		if (prop->fulltextIndexed) {
			g_fprintf (f, "<note><para>This property is full-text-indexed, and can be looked up through <literal>fts:match</literal>.</para></note>\n");
		}

		if (prop->deprecated) {
			g_fprintf (f, "<note><para>This property is deprecated.</para></note>\n");
		}

		if (prop->superproperties) {
			GList *l;

			g_fprintf (f, "<note><para>This property supersedes the following properties from this or parent classes:</para>\n");
			g_fprintf (f, "<itemizedlist>\n");

			for (l = prop->superproperties; l; l = l->next) {
				gchar *class_shortname, *shortname, *class_id, *superprop_id;
				OntologyProperty *superprop;
				OntologyClass *cl;

				superprop = g_hash_table_lookup (ontology->properties, l->data);
621 622 623 624 625 626 627 628 629

				if (!superprop) {
					superprop = ttl_model_property_new (l->data);
					g_hash_table_insert (ontology->properties, superprop->propertyname, superprop);
				}

				if (!superprop->domain)
					continue;

630 631
				cl = g_hash_table_lookup (ontology->classes, superprop->domain->data);

632 633 634 635
				shortname = ttl_model_name_to_shortname (ontology, superprop->propertyname, NULL);
				class_shortname = ttl_model_name_to_shortname (ontology, cl->classname, NULL);
				superprop_id = ttl_model_name_to_shortname (ontology, superprop->propertyname, "-");
				class_id = ttl_model_name_to_shortname (ontology, cl->classname, "-");
636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676

				g_fprintf (f, "<listitem><para>");
				g_fprintf (f, "<link linkend=\"%s.%s\"><literal>“%s”</literal> from the <literal>%s</literal> class</link>",
				           class_id, superprop_id,
				           shortname, class_shortname);
				g_fprintf (f, "</para></listitem>\n");

				g_free (class_id);
				g_free (superprop_id);
				g_free (class_shortname);
				g_free (shortname);
			}

			g_fprintf (f, "</itemizedlist></note>\n");
		}

		g_fprintf (f, "</refsect2>\n");

		g_free (type_class_id);
		g_free (type_name);
		g_free (shortname);
		g_free (prop_id);
	}

	g_fprintf (f, "</refsect1>");
	g_free (id);
}

static void
generate_class_docs (OntologyClass *klass,
                     Ontology      *ontology,
                     FILE          *f)
{
	print_sgml_header (f, klass, ontology);
	print_class_hierarchy (f, klass, ontology);
	print_predefined_instances (f, klass, ontology);
	print_fts_properties (f, klass, ontology);
	print_properties (f, klass, ontology);
	print_sgml_footer (f);
}

677 678 679
void
generate_ontology_class_docs (Ontology *ontology,
                              GFile    *output_dir)
680 681
{
	OntologyClass *klass;
682
	GList *classes, *l;
683 684
	FILE *f;

685
	classes = g_hash_table_get_values (ontology->classes);
686

687
	for (l = classes; l; l = l->next) {
688
		gchar *shortname, *class_filename, *output_file;
689
		GFile *child;
690

691
		klass = l->data;
692
		shortname = ttl_model_name_to_shortname (ontology, klass->classname, "-");
693
		class_filename = g_strdup_printf ("%s.xml", shortname);
694 695 696
		child = g_file_get_child (output_dir, class_filename);

		output_file = g_file_get_path (child);
697 698

		f = fopen (output_file, "w");
699 700 701 702 703

		if (f == NULL) {
			g_error ("Could not open %s for writing.\n", output_file);
		}

704 705 706 707 708 709 710 711
		g_free (class_filename);
		g_free (output_file);
		g_free (shortname);

		generate_class_docs (klass, ontology, f);
		fclose (f);
	}

712
	g_list_free (classes);
713
}