diff options
21 files changed, 674 insertions, 23 deletions
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py index e962b914..7924b2d3 100644 --- a/giscanner/docwriter.py +++ b/giscanner/docwriter.py @@ -38,10 +38,18 @@ def make_page_id(node, recursive=False): else: return 'index' + if hasattr(node, '_chain') and node._chain: + parent = node._chain[-1] + else: + parent = None + + if parent is None: + return '%s.%s' % (node.namespace.name, node.name) + if isinstance(node, (ast.Property, ast.Signal, ast.VFunction)): - return '%s-%s' % (make_page_id(node.parent, recursive=True), node.name) + return '%s-%s' % (make_page_id(parent, recursive=True), node.name) else: - return '%s.%s' % (make_page_id(node.parent, recursive=True), node.name) + return '%s.%s' % (make_page_id(parent, recursive=True), node.name) def get_node_kind(node): if isinstance(node, ast.Namespace): @@ -314,7 +322,10 @@ class DocFormatter(object): return make_page_id(node) def format_xref(self, node, **attrdict): - if isinstance(node, ast.Member): + if node is None: + attrs = [('xref', 'index')] + attrdict.items() + return xmlwriter.build_xml_tag('link', attrs) + elif isinstance(node, ast.Member): # Enum/BitField members are linked to the main enum page. return self.format_xref(node.parent, **attrdict) + '.' + node.name else: @@ -587,27 +598,25 @@ class DocWriter(object): # directory already made pass - nodes = [self._transformer.namespace] - for node in self._transformer.namespace.itervalues(): - if isinstance(node, ast.Function) and node.moved_to is not None: - continue - if getattr(node, 'disguised', False): - continue - nodes.append(node) - if isinstance(node, (ast.Class, ast.Interface, ast.Record)): - nodes += getattr(node, 'methods', []) - nodes += getattr(node, 'static_methods', []) - nodes += getattr(node, 'virtual_methods', []) - nodes += getattr(node, 'properties', []) - nodes += getattr(node, 'signals', []) - nodes += getattr(node, 'constructors', []) - for node in nodes: - if self._formatter.should_render_node(node): - self._render_node(node, output) - - def _render_node(self, node, output): + self._walk_node(output, self._transformer.namespace, []) + self._transformer.namespace.walk(lambda node, chain: self._walk_node(output, node, chain)) + + def _walk_node(self, output, node, chain): + if isinstance(node, ast.Function) and node.moved_to is not None: + return False + if getattr(node, 'disguised', False): + return False + if self._formatter.should_render_node(node): + self._render_node(node, chain, output) + return True + return False + + def _render_node(self, node, chain, output): namespace = self._transformer.namespace + # A bit of a hack...maybe this should be an official API + node._chain = list(chain) + page_kind = get_node_kind(node) template_name = '%s/%s.tmpl' % (self._language, page_kind) page_id = make_page_id(node) diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.AnnotationObject.watch.page b/tests/scanner/Regress-1.0-C-expected/Regress.AnnotationObject.watch.page index 0f9933de..76402aab 100644 --- a/tests/scanner/Regress-1.0-C-expected/Regress.AnnotationObject.watch.page +++ b/tests/scanner/Regress-1.0-C-expected/Regress.AnnotationObject.watch.page @@ -38,7 +38,7 @@ void regress_annotation_object_watch (RegressAnnotationObject* object, <p>This is here just for the sake of being overriden by its -<link xref="Regress.AnnotationObject.watch_full"/>.</p> +<link xref="Regress.watch_full"/>.</p> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.FooBUnion.get_contained_type.page b/tests/scanner/Regress-1.0-C-expected/Regress.FooBUnion.get_contained_type.page new file mode 100644 index 00000000..1ee353fd --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.FooBUnion.get_contained_type.page @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<page id="Regress.FooBUnion.get_contained_type" + type="topic" + style="method" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="Regress.FooBUnion" group="method" type="guide"/> + <api:function> + <api:returns> + <api:type>int</api:type> + </api:returns> + <api:name>regress_foo_bunion_get_contained_type</api:name> + <api:arg> + <api:type>RegressFooBUnion*</api:type> + <api:name>bunion</api:name> + </api:arg> + </api:function> + + </info> + <title>regress_foo_bunion_get_contained_type</title> + +<synopsis><code mime="text/x-csrc"> +int regress_foo_bunion_get_contained_type (RegressFooBUnion* bunion); +</code></synopsis> + + + + + + + +<terms> +<item> +<title><code>bunion</code></title> + +</item> +<item> +<title><code>Returns</code></title> + +</item> +</terms> + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.FooBUnion.new.page b/tests/scanner/Regress-1.0-C-expected/Regress.FooBUnion.new.page new file mode 100644 index 00000000..b760f204 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.FooBUnion.new.page @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<page id="Regress.FooBUnion.new" + type="topic" + style="constructor" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="Regress.FooBUnion" group="constructor" type="guide"/> + <api:function> + <api:returns> + <api:type>RegressFooBUnion*</api:type> + </api:returns> + <api:name>regress_foo_bunion_new</api:name> + </api:function> + + </info> + <title>regress_foo_bunion_new</title> + +<synopsis><code mime="text/x-csrc"> +RegressFooBUnion* regress_foo_bunion_new (void); +</code></synopsis> + + + + + + + +<terms> +<item> +<title><code>Returns</code></title> + +</item> +</terms> + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.FooEnumType.method.page b/tests/scanner/Regress-1.0-C-expected/Regress.FooEnumType.method.page new file mode 100644 index 00000000..6ecf2dd9 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.FooEnumType.method.page @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<page id="Regress.FooEnumType.method" + type="topic" + style="function" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="function" type="guide"/> + <api:function> + <api:returns> + <api:type>int</api:type> + </api:returns> + <api:name>regress_foo_enum_type_method</api:name> + <api:arg> + <api:type>RegressFooEnumType</api:type> + <api:name>regress_foo_enum</api:name> + </api:arg> + </api:function> + + </info> + <title>regress_foo_enum_type_method</title> + +<synopsis><code mime="text/x-csrc"> +int regress_foo_enum_type_method (RegressFooEnumType regress_foo_enum); +</code></synopsis> + + + + + + + +<terms> +<item> +<title><code>regress_foo_enum</code></title> + +</item> +<item> +<title><code>Returns</code></title> + +</item> +</terms> + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.FooEnumType.returnv.page b/tests/scanner/Regress-1.0-C-expected/Regress.FooEnumType.returnv.page new file mode 100644 index 00000000..aa0c6c1b --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.FooEnumType.returnv.page @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<page id="Regress.FooEnumType.returnv" + type="topic" + style="function" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="function" type="guide"/> + <api:function> + <api:returns> + <api:type>RegressFooEnumType</api:type> + </api:returns> + <api:name>regress_foo_enum_type_returnv</api:name> + <api:arg> + <api:type>int</api:type> + <api:name>x</api:name> + </api:arg> + </api:function> + + </info> + <title>regress_foo_enum_type_returnv</title> + +<synopsis><code mime="text/x-csrc"> +RegressFooEnumType regress_foo_enum_type_returnv (int x); +</code></synopsis> + + + + + + + +<terms> +<item> +<title><code>x</code></title> + +</item> +<item> +<title><code>Returns</code></title> + +</item> +</terms> + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.FooError.quark.page b/tests/scanner/Regress-1.0-C-expected/Regress.FooError.quark.page new file mode 100644 index 00000000..dde46fb0 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.FooError.quark.page @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<page id="Regress.FooError.quark" + type="topic" + style="function" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="function" type="guide"/> + <api:function> + <api:returns> + <api:type>GQuark</api:type> + </api:returns> + <api:name>regress_foo_error_quark</api:name> + </api:function> + + </info> + <title>regress_foo_error_quark</title> + +<synopsis><code mime="text/x-csrc"> +GQuark regress_foo_error_quark (void); +</code></synopsis> + + + + + + + +<terms> +<item> +<title><code>Returns</code></title> + +</item> +</terms> + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.FooInterfaceIface.do_regress_foo.page b/tests/scanner/Regress-1.0-C-expected/Regress.FooInterfaceIface.do_regress_foo.page new file mode 100644 index 00000000..0b900420 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.FooInterfaceIface.do_regress_foo.page @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<page id="Regress.FooInterfaceIface.do_regress_foo" + type="topic" + style="default" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="default" type="guide"/> + + </info> + <title>Regress.FooInterfaceIface.do_regress_foo</title> + + + + + + + + + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.FooObjectClass.read_fn.page b/tests/scanner/Regress-1.0-C-expected/Regress.FooObjectClass.read_fn.page new file mode 100644 index 00000000..39078bfc --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.FooObjectClass.read_fn.page @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<page id="Regress.FooObjectClass.read_fn" + type="topic" + style="default" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="default" type="guide"/> + + </info> + <title>Regress.FooObjectClass.read_fn</title> + + + + + + + + + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.FooObjectClass.virtual_method.page b/tests/scanner/Regress-1.0-C-expected/Regress.FooObjectClass.virtual_method.page new file mode 100644 index 00000000..2882c6d7 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.FooObjectClass.virtual_method.page @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<page id="Regress.FooObjectClass.virtual_method" + type="topic" + style="default" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="default" type="guide"/> + + </info> + <title>Regress.FooObjectClass.virtual_method</title> + + + + + + + + + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.FooSubInterfaceIface.destroy_event.page b/tests/scanner/Regress-1.0-C-expected/Regress.FooSubInterfaceIface.destroy_event.page new file mode 100644 index 00000000..95136833 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.FooSubInterfaceIface.destroy_event.page @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<page id="Regress.FooSubInterfaceIface.destroy_event" + type="topic" + style="default" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="default" type="guide"/> + + </info> + <title>Regress.FooSubInterfaceIface.destroy_event</title> + + + + + + + + + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.FooSubInterfaceIface.do_bar.page b/tests/scanner/Regress-1.0-C-expected/Regress.FooSubInterfaceIface.do_bar.page new file mode 100644 index 00000000..ec46cdde --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.FooSubInterfaceIface.do_bar.page @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<page id="Regress.FooSubInterfaceIface.do_bar" + type="topic" + style="default" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="default" type="guide"/> + + </info> + <title>Regress.FooSubInterfaceIface.do_bar</title> + + + + + + + + + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.FooSubInterfaceIface.do_baz.page b/tests/scanner/Regress-1.0-C-expected/Regress.FooSubInterfaceIface.do_baz.page new file mode 100644 index 00000000..d0f58041 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.FooSubInterfaceIface.do_baz.page @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<page id="Regress.FooSubInterfaceIface.do_baz" + type="topic" + style="default" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="default" type="guide"/> + + </info> + <title>Regress.FooSubInterfaceIface.do_baz</title> + + + + + + + + + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestABCError.quark.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestABCError.quark.page new file mode 100644 index 00000000..7ed5152f --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestABCError.quark.page @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<page id="Regress.TestABCError.quark" + type="topic" + style="function" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="function" type="guide"/> + <api:function> + <api:returns> + <api:type>GQuark</api:type> + </api:returns> + <api:name>regress_test_abc_error_quark</api:name> + </api:function> + + </info> + <title>regress_test_abc_error_quark</title> + +<synopsis><code mime="text/x-csrc"> +GQuark regress_test_abc_error_quark (void); +</code></synopsis> + + + + + + + +<terms> +<item> +<title><code>Returns</code></title> + +</item> +</terms> + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestEnum.param.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestEnum.param.page new file mode 100644 index 00000000..542ba60c --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestEnum.param.page @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<page id="Regress.TestEnum.param" + type="topic" + style="function" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="function" type="guide"/> + <api:function> + <api:returns> + <api:type>const gchar*</api:type> + </api:returns> + <api:name>regress_test_enum_param</api:name> + <api:arg> + <api:type>RegressTestEnum</api:type> + <api:name>e</api:name> + </api:arg> + </api:function> + + </info> + <title>regress_test_enum_param</title> + +<synopsis><code mime="text/x-csrc"> +const gchar* regress_test_enum_param (RegressTestEnum e); +</code></synopsis> + + + + + + + +<terms> +<item> +<title><code>e</code></title> + +</item> +<item> +<title><code>Returns</code></title> + +</item> +</terms> + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestError.quark.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestError.quark.page new file mode 100644 index 00000000..9140ac56 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestError.quark.page @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<page id="Regress.TestError.quark" + type="topic" + style="function" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="function" type="guide"/> + <api:function> + <api:returns> + <api:type>GQuark</api:type> + </api:returns> + <api:name>regress_test_error_quark</api:name> + </api:function> + + </info> + <title>regress_test_error_quark</title> + +<synopsis><code mime="text/x-csrc"> +GQuark regress_test_error_quark (void); +</code></synopsis> + + + + + + + +<terms> +<item> +<title><code>Returns</code></title> + +</item> +</terms> + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestObjClass._regress_reserved1.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestObjClass._regress_reserved1.page new file mode 100644 index 00000000..3aec1433 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestObjClass._regress_reserved1.page @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<page id="Regress.TestObjClass._regress_reserved1" + type="topic" + style="default" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="default" type="guide"/> + + </info> + <title>Regress.TestObjClass._regress_reserved1</title> + + + + + + + + + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestObjClass._regress_reserved2.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestObjClass._regress_reserved2.page new file mode 100644 index 00000000..8bfc4d19 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestObjClass._regress_reserved2.page @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<page id="Regress.TestObjClass._regress_reserved2" + type="topic" + style="default" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="default" type="guide"/> + + </info> + <title>Regress.TestObjClass._regress_reserved2</title> + + + + + + + + + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestObjClass.allow_none_vfunc.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestObjClass.allow_none_vfunc.page new file mode 100644 index 00000000..b45f05d2 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestObjClass.allow_none_vfunc.page @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<page id="Regress.TestObjClass.allow_none_vfunc" + type="topic" + style="default" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="default" type="guide"/> + + </info> + <title>Regress.TestObjClass.allow_none_vfunc</title> + + + + + + + + + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestObjClass.matrix.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestObjClass.matrix.page new file mode 100644 index 00000000..312b198e --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestObjClass.matrix.page @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<page id="Regress.TestObjClass.matrix" + type="topic" + style="default" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="default" type="guide"/> + + </info> + <title>Regress.TestObjClass.matrix</title> + + + + + + + + + + + +</page> diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestOtherError.quark.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestOtherError.quark.page new file mode 100644 index 00000000..4ed8d539 --- /dev/null +++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestOtherError.quark.page @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<page id="Regress.TestOtherError.quark" + type="topic" + style="function" + xmlns="http://projectmallard.org/1.0/" + xmlns:api="http://projectmallard.org/experimental/api/" + xmlns:ui="http://projectmallard.org/1.0/ui/"> + <info> + + <link xref="index" group="function" type="guide"/> + <api:function> + <api:returns> + <api:type>GQuark</api:type> + </api:returns> + <api:name>regress_test_unconventional_error_quark</api:name> + </api:function> + + </info> + <title>regress_test_unconventional_error_quark</title> + +<synopsis><code mime="text/x-csrc"> +GQuark regress_test_unconventional_error_quark (void); +</code></synopsis> + + + + + + + +<terms> +<item> +<title><code>Returns</code></title> + +</item> +</terms> + + + +</page> |