summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2009-02-03 16:09:57 -0500
committerDavid Zeuthen <davidz@redhat.com>2009-02-03 16:09:57 -0500
commit0ede449fe1c1ee02a6a34836c672e19cde94377c (patch)
tree19e3825ec7078385368988d63a03c7e0c7ccffee
parentfd46c70ea822904afd004cc9ac26effa9bbabb42 (diff)
generate docbook docs for structs
-rw-r--r--docs/eggdbus/Makefile.am5
-rw-r--r--docs/eggdbus/eggdbus-docs.xml5
-rw-r--r--src/eggdbus/docbook.c123
-rw-r--r--src/eggdbus/docbook.h4
-rw-r--r--src/eggdbus/eggdbusbindingtool.c21
-rw-r--r--src/tests/Makefile.am2
6 files changed, 158 insertions, 2 deletions
diff --git a/docs/eggdbus/Makefile.am b/docs/eggdbus/Makefile.am
index 940f55c..26a9331 100644
--- a/docs/eggdbus/Makefile.am
+++ b/docs/eggdbus/Makefile.am
@@ -73,6 +73,11 @@ content_files = \
../../src/tests/docbook-enum-Error.xml \
../../src/tests/docbook-enum-OtherFlags.xml \
../../src/tests/docbook-enum-Vehicle.xml \
+ ../../src/tests/docbook-struct-Pair.xml \
+ ../../src/tests/docbook-struct-Point.xml \
+ ../../src/tests/docbook-struct-DescribedPair.xml \
+ ../../src/tests/docbook-struct-DescribedPoint.xml \
+ ../../src/tests/docbook-struct-StructWithVariant.xml \
../../src/tests/docbook-interface-com.example.Frob.xml \
../../src/tests/docbook-interface-com.example.Tweak.xml \
../../src/tests/docbook-interface-com.example.Twiddle.xml \
diff --git a/docs/eggdbus/eggdbus-docs.xml b/docs/eggdbus/eggdbus-docs.xml
index bd4b688..3437a37 100644
--- a/docs/eggdbus/eggdbus-docs.xml
+++ b/docs/eggdbus/eggdbus-docs.xml
@@ -145,6 +145,11 @@
<xi:include href="../../src/tests/docbook-enum-Error.xml"/>
<xi:include href="../../src/tests/docbook-enum-OtherFlags.xml"/>
<xi:include href="../../src/tests/docbook-enum-Vehicle.xml"/>
+ <xi:include href="../../src/tests/docbook-struct-Pair.xml"/>
+ <xi:include href="../../src/tests/docbook-struct-Point.xml"/>
+ <xi:include href="../../src/tests/docbook-struct-DescribedPair.xml"/>
+ <xi:include href="../../src/tests/docbook-struct-DescribedPoint.xml"/>
+ <xi:include href="../../src/tests/docbook-struct-StructWithVariant.xml"/>
<xi:include href="../../src/tests/docbook-interface-com.example.Frob.xml"/>
<xi:include href="../../src/tests/docbook-interface-com.example.Tweak.xml"/>
<xi:include href="../../src/tests/docbook-interface-com.example.Twiddle.xml"/>
diff --git a/src/eggdbus/docbook.c b/src/eggdbus/docbook.c
index 2ae44e9..f20bd4b 100644
--- a/src/eggdbus/docbook.c
+++ b/src/eggdbus/docbook.c
@@ -1056,3 +1056,126 @@ enum_generate_docbook (EnumData *enum_data,
return ret;
}
+/* ---------------------------------------------------------------------------------------------------- */
+
+gboolean
+struct_generate_docbook (StructData *struct_data,
+ GError **error)
+{
+ gboolean ret;
+ gchar *struct_summary_doc_string;
+ gchar *struct_doc_string;
+ guint n;
+ gboolean has_none_elem;
+ guint max_type_len;
+
+ ret = FALSE;
+ has_none_elem = TRUE;
+
+ struct_summary_doc_string = get_summary_doc_string (struct_data->annotations, "Structure");
+ struct_doc_string = get_doc_string (struct_data->annotations, "Structure");
+
+ g_print ("<?xml version=\"1.0\"?>\n"
+ "<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2 //EN\"\n"
+ "\"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">\n");
+
+ g_print ("<refentry id=\"struct-%s\">\n", struct_data->name);
+ g_print (" <refmeta>\n");
+ g_print (" <refentrytitle role=\"top_of_page\">%s</refentrytitle>\n", struct_data->name);
+ g_print (" </refmeta>\n");
+ g_print (" <refnamediv>\n");
+ g_print (" <refname>%s</refname>\n", struct_data->name);
+ g_print (" <refpurpose>%s</refpurpose>\n", struct_summary_doc_string);
+ g_print (" </refnamediv>\n");
+
+ g_print (" <refsect1>\n");
+
+ g_print (" <refsect2>\n");
+ g_print (" <title><anchor role=\"struct\" id=\"%s\"/>The %s Structure</title>\n",
+ struct_data->name,
+ struct_data->name);
+ g_print (" <para>\n");
+ g_print (" <programlisting>\n");
+ max_type_len = 0;
+ for (n = 0; n < struct_data->num_elements; n++)
+ {
+ StructElemData *elem = struct_data->elements[n];
+ guint type_len;
+ gchar *type_name;
+
+ docbook_get_typename_for_signature (elem->signature, &type_name, NULL);
+ type_len = strlen (type_name);
+ g_free (type_name);
+
+ if (type_len > max_type_len)
+ max_type_len = type_len;
+ }
+ g_print ("{\n");
+ for (n = 0; n < struct_data->num_elements; n++)
+ {
+ StructElemData *elem = struct_data->elements[n];
+ gchar *type_name;
+ gchar *type_name_link;
+ guint type_len;
+
+ if (n > 0)
+ g_print (",\n");
+
+ docbook_get_typename_for_signature (elem->signature, &type_name, &type_name_link);
+ type_len = strlen (type_name);
+
+ g_print (" %s%*s %s",
+ type_name_link,
+ max_type_len - type_len, "",
+ elem->name);
+
+ g_free (type_name);
+ g_free (type_name_link);
+ }
+ g_print ("\n"
+ "}\n");
+ g_print (" </programlisting>\n");
+ g_print (" <para>\n");
+ g_print ("%s\n", struct_doc_string);
+ g_print (" </para>\n");
+
+ g_print (" <variablelist role=\"struct\">\n");
+
+ for (n = 0; n < struct_data->num_elements; n++)
+ {
+ StructElemData *elem = struct_data->elements[n];
+ gchar *struct_doc_string;
+ gchar *type_name_link;
+
+ struct_doc_string = get_doc_string (elem->annotations, "Member");
+ docbook_get_typename_for_signature (elem->signature, NULL, &type_name_link);
+
+ g_print (" <varlistentry>\n");
+ g_print (" <term><literal>%s <structfield>%s</structfield></literal></term>\n", type_name_link, elem->name);
+ g_print (" <listitem>\n");
+ g_print (" <para>\n");
+ g_print ("%s\n", struct_doc_string);
+ g_print (" </para>\n");
+ g_print (" </listitem>\n");
+ g_print (" </varlistentry>\n");
+
+ g_free (type_name_link);
+ g_free (struct_doc_string);
+ }
+ g_print (" </variablelist>\n");
+ g_print (" </para>\n");
+ g_print (" </refsect2>\n");
+
+ g_print (" </refsect1>\n");
+
+
+ g_print ("</refentry>\n");
+
+ ret = TRUE;
+
+ g_free (struct_doc_string);
+ g_free (struct_summary_doc_string);
+
+ return ret;
+}
+
diff --git a/src/eggdbus/docbook.h b/src/eggdbus/docbook.h
index 3e141cb..6e84f85 100644
--- a/src/eggdbus/docbook.h
+++ b/src/eggdbus/docbook.h
@@ -24,6 +24,7 @@
#include "eggdbusinterface.h"
#include "enum.h"
+#include "struct.h"
G_BEGIN_DECLS
@@ -33,6 +34,9 @@ gboolean interface_generate_docbook (const EggDBusInterfaceInfo *interface,
gboolean enum_generate_docbook (EnumData *enum_data,
GError **error);
+gboolean struct_generate_docbook (StructData *struct_data,
+ GError **error);
+
G_END_DECLS
#endif /* __DOCBOOK_H */
diff --git a/src/eggdbus/eggdbusbindingtool.c b/src/eggdbus/eggdbusbindingtool.c
index b29f924..6b60691 100644
--- a/src/eggdbus/eggdbusbindingtool.c
+++ b/src/eggdbus/eggdbusbindingtool.c
@@ -1273,12 +1273,31 @@ generate_struct_interfaces (GSList *nodes,
StructData *struct_data = l->data;
gchar *h_file_name;
gchar *c_file_name;
+ gchar *docbook_file_name;
- /* now generate C and H files for struct_interface unless they are user supplied */
+ /* now generate Docbook, H and C files for struct_interface unless they are user supplied */
if (struct_data->user_supplied)
continue;
+ /* generate docbook file */
+ docbook_file_name = g_strdup_printf ("docbook-struct-%s.xml", struct_data->name);
+ file_print_func_begin (docbook_file_name);
+ if (!struct_generate_docbook (struct_data, error))
+ {
+ g_free (docbook_file_name);
+ file_print_func_end (FALSE, NULL);
+ goto out;
+ }
+ if (!file_print_func_end (TRUE, error))
+ {
+ g_free (docbook_file_name);
+ goto out;
+ }
+ g_printerr ("Wrote %s\n", docbook_file_name);
+ generated_files = g_slist_prepend (generated_files, g_strdup (docbook_file_name));
+ g_free (docbook_file_name);
+
/* generate header file */
h_file_name = compute_file_name (name_space, struct_data->name, ".h");
file_print_func_begin (h_file_name);
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index bea8866..7bc1b24 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -37,7 +37,7 @@ test-built-sources.stamp : Makefile.am $(top_builddir)/src/eggdbus/eggdbus-bindi
# keep in sync with contents of test-built-sources.stamp (Thanks autotools)
#
-test_built_sources = testbindingsmarshal.c testbindingsmarshal.h testbindingsmarshal.list testbindings.c testbindings.h testbindingstypes.h testtwiddle.c testtwiddle.h docbook-interface-com.example.Twiddle.xml testtweak.c testtweak.h docbook-interface-com.example.Tweak.xml testfrob.c testfrob.h docbook-interface-com.example.Frob.xml testvehicle.c testvehicle.h docbook-enum-Vehicle.xml testotherflags.c testotherflags.h docbook-enum-OtherFlags.xml testdeleteflags.c testdeleteflags.h docbook-enum-DeleteFlags.xml testcreateflags.c testcreateflags.h docbook-enum-CreateFlags.xml testdetailederror.c testdetailederror.h docbook-enum-DetailedError.xml testerror.c testerror.h docbook-enum-Error.xml teststructwithvariant.c teststructwithvariant.h testextendeddescribedpoint.c testextendeddescribedpoint.h testdescribedpair.c testdescribedpair.h testdescribedpoint.c testdescribedpoint.h testpair.c testpair.h testpoint.c testpoint.h
+test_built_sources = testbindingsmarshal.c testbindingsmarshal.h testbindingsmarshal.list testbindings.c testbindings.h testbindingstypes.h testtwiddle.c testtwiddle.h docbook-interface-com.example.Twiddle.xml testtweak.c testtweak.h docbook-interface-com.example.Tweak.xml testfrob.c testfrob.h docbook-interface-com.example.Frob.xml testvehicle.c testvehicle.h docbook-enum-Vehicle.xml testotherflags.c testotherflags.h docbook-enum-OtherFlags.xml testdeleteflags.c testdeleteflags.h docbook-enum-DeleteFlags.xml testcreateflags.c testcreateflags.h docbook-enum-CreateFlags.xml testdetailederror.c testdetailederror.h docbook-enum-DetailedError.xml testerror.c testerror.h docbook-enum-Error.xml teststructwithvariant.c teststructwithvariant.h docbook-struct-StructWithVariant.xml testextendeddescribedpoint.c testextendeddescribedpoint.h docbook-struct-ExtendedDescribedPoint.xml testdescribedpair.c testdescribedpair.h docbook-struct-DescribedPair.xml testdescribedpoint.c testdescribedpoint.h docbook-struct-DescribedPoint.xml testpair.c testpair.h docbook-struct-Pair.xml testpoint.c testpoint.h docbook-struct-Point.xml
libeggdbustests_la_SOURCES = \
test-built-sources.stamp \