[gobject-introspection/wip/transformer] Add JS formatter (same as python). Implement more properties stuff Add hacks to make functions links
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/wip/transformer] Add JS formatter (same as python). Implement more properties stuff Add hacks to make functions links
- Date: Fri, 30 Jul 2010 22:04:19 +0000 (UTC)
commit fd341789d92f6303569abea7be477d8a6f716b5c
Author: Zachary Goldberg <zgoldberg src gnome org>
Date: Wed Jul 28 19:00:23 2010 -0400
Add JS formatter (same as python). Implement more properties stuff Add hacks to make functions links
giscanner/gicodeformatters.py | 26 ++++++++++++++-
giscanner/gidocgen.py | 68 +++++++++++++++++++++++++++++------------
2 files changed, 72 insertions(+), 22 deletions(-)
---
diff --git a/giscanner/gicodeformatters.py b/giscanner/gicodeformatters.py
index 3f2b981..b5d1898 100644
--- a/giscanner/gicodeformatters.py
+++ b/giscanner/gicodeformatters.py
@@ -76,8 +76,10 @@ class DocBookFormatter(object):
if method_name_link:
writer.write_tag("link", [("linkend",
- "%s-details_%s" % (method.name,
- clazz.name))],
+ "%s%s-function-%s" % (
+ method.parent_class.name,
+ method.name,
+ clazz.name))],
clazz.get_method_name(method))
else:
writer.write_line(clazz.get_method_name(method))
@@ -203,3 +205,23 @@ class PythonDocBookFormatter(DocBookFormatter):
@classmethod
def update_parameters(clazz, method, parameters):
return parameters
+
+class JavaScriptDocBookFormatter(DocBookFormatter):
+ name = "JavaScript"
+ seperator = "."
+
+ @classmethod
+ def get_type_string(clazz, type):
+ return str(type)
+
+ @classmethod
+ def get_method_name(clazz, method):
+ return method.name
+
+ @classmethod
+ def render_parameter(clazz, param_type, param_name):
+ return "%s %s" % (param_type, param_name)
+
+ @classmethod
+ def update_parameters(clazz, method, parameters):
+ return parameters
diff --git a/giscanner/gidocgen.py b/giscanner/gidocgen.py
index 6526798..4662232 100644
--- a/giscanner/gidocgen.py
+++ b/giscanner/gidocgen.py
@@ -2,10 +2,12 @@ import sys
from .ast import *
from .girparser import GIRParser
from .xmlwriter import XMLWriter
-from .gicodeformatters import CDocBookFormatter, PythonDocBookFormatter, space
+from .gicodeformatters import *
import logging
-FORMATTERS = [CDocBookFormatter, PythonDocBookFormatter]
+FORMATTERS = [CDocBookFormatter,
+ PythonDocBookFormatter,
+ JavaScriptDocBookFormatter]
class GIDocGenerator(object):
@@ -109,12 +111,13 @@ class DocBookWriter(DocWriter):
self.writer.push_tag("refmeta")
self.writer.write_tag("refentrytitle", [
("role", "top_of_page"),
- ("id", "%s-%s.top_of_page" % (page.namespace.name,
- page.name))],
+ ("id", "%s-%s.%s.top_of_page" % (page.namespace.name,
+ page.name,
+ formatter.name))],
"%s%s - %s" % (page.namespace.name,
page.name, formatter.name))
- self.writer.write_tag("manvolumenum", [], "1")
+ self.writer.write_tag("manvolumenum", [], "3")
self.writer.write_tag("refmiscinfo", [], page.namespace.name)
self.writer.pop_tag()
self.writer.push_tag("refnamediv")
@@ -136,28 +139,31 @@ class DocBookWriter(DocWriter):
file.close()
def _render_entity(self, entity, formatter):
-
- with self.writer.tagcontext('refsect1',
- [('id', "%s-details_%s" % (entity.get_name(),
- formatter.name)),
- ("role", "details")]):
- self.writer.write_tag("title", [("role", "details.title")],
- "Details")
-
+ func_id = "%s%s-function-%s" % (
+ entity.get_data().parent_class.name,
+ entity.get_name(),
+ formatter.name)
+
+ # Stupid hack to get links to work. This refsect1
+ # should not be here.
+ self.writer.push_tag('refsect1',
+ [('id', func_id),
+ ('role', 'function')])
self.writer.push_tag('refsect2',
- [('id', "%s-function" % entity.get_name()),
- ('role', 'struct')])
+ [('id', func_id),
+ ('role', 'function')])
self.writer.write_tag("title", [], entity.get_name())
with self.writer.tagcontext("indexterm",
- [("zone", "%s" % entity.get_name())]):
- self.writer.write_tag("primary", [], entity.get_name())
+ [("zone", "%s" % func_id)]):
+ self.writer.write_tag("primary", [], func_id)
formatter.render(self.writer, entity)
self.writer.pop_tag()
+ self.writer.pop_tag()
def _render_page(self, page, formatter):
@@ -183,7 +189,8 @@ class DocBookWriter(DocWriter):
self.writer.write_tag("para", [], page.description)
with self.writer.tagcontext("refsynopsisdiv", [
- ('id', '%s.synopsis' % page.name),
+ ('id', '%s.%s.synopsis' % (formatter.name,
+ page.name)),
('role', 'synopsis')
]):
self.writer.write_tag("title", [("role", "synopsis.title")],
@@ -314,9 +321,30 @@ class DocBookWriter(DocWriter):
self.writer.write_tag("para", [], page.get_doc())
- for entity in page.get_entities():
- self._render_entity(entity, formatter)
+ with self.writer.tagcontext('refsect1',
+ [('id', "%s-details_%s" % (
+ page.name,
+ formatter.name)),
+ ("role", "details")]):
+ self.writer.write_tag("title", [("role", "details.title")],
+ "Details")
+
+
+ for entity in page.get_entities("method"):
+ self._render_entity(entity, formatter)
+ with self.writer.tagcontext('refsect1',
+ [('id', "%s-properties_%s" % (
+ page.name,
+ formatter.name)),
+ ("role", "details")]):
+
+ self.writer.write_tag("title", [("role", "properties.title")],
+ "Properties")
+
+ for entity in page.get_entities("property"):
+ self._render_entity(entity, formatter)
+
class DocEntity(object):
def __init__(self, entity_name, entity_type, entity_data):
self.entity_name = entity_name
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]