[gobject-introspection/gir-docbook] [docbook] Make DocBookWriter use Transformer
- From: Laszlo Pandy <lpandy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/gir-docbook] [docbook] Make DocBookWriter use Transformer
- Date: Thu, 11 Aug 2011 10:41:26 +0000 (UTC)
commit 28bc1cbdfc5b213d7c926e05f35709c55f5908b1
Author: Laszlo Pandy <lpandy src gnome org>
Date: Thu Aug 11 10:57:14 2011 +0200
[docbook] Make DocBookWriter use Transformer
giscanner/docbookwriter.py | 10 ++++++----
giscanner/docmain.py | 8 +++-----
giscanner/transformer.py | 9 +++++++++
tools/g-ir-doc-tool.in | 3 +++
4 files changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/giscanner/docbookwriter.py b/giscanner/docbookwriter.py
index 42c4fbe..8e38ec4 100644
--- a/giscanner/docbookwriter.py
+++ b/giscanner/docbookwriter.py
@@ -160,11 +160,13 @@ class DocBookWriter(object):
def _add_page(self, page):
self._pages.append(page)
- def add_namespace(self, namespace):
- self._namespace = namespace
- self._formatter.set_namespace(namespace)
+ def add_transformer(self, transformer):
+ self._transformer = transformer
+
+ self._namespace = self._transformer._namespace
+ self._formatter.set_namespace(self._namespace)
- for name, node in namespace.iteritems():
+ for name, node in self._namespace.iteritems():
self._add_node(node, name)
def _add_node(self, node, name):
diff --git a/giscanner/docmain.py b/giscanner/docmain.py
index 7684944..29b5ddf 100644
--- a/giscanner/docmain.py
+++ b/giscanner/docmain.py
@@ -21,17 +21,15 @@
import optparse
from .docbookwriter import DocBookWriter
-from .girparser import GIRParser
+from .transformer import Transformer
class GIDocGenerator(object):
def parse(self, filename):
- self.parser = GIRParser()
- self.parser.parse(filename)
+ self.transformer = Transformer.parse_from_gir(filename)
def generate(self, writer, output):
- ns = self.parser.get_namespace()
- writer.add_namespace(ns)
+ writer.add_transformer(self.transformer)
writer.write(output)
def doc_main(args):
diff --git a/giscanner/transformer.py b/giscanner/transformer.py
index 6689fc7..88be838 100644
--- a/giscanner/transformer.py
+++ b/giscanner/transformer.py
@@ -178,6 +178,15 @@ None."""
% (girname, searchdirs))
sys.exit(1)
+ @staticmethod
+ def parse_from_gir(filename):
+ transformer = Transformer(None)
+ transformer._parse_include(filename)
+ parser = transformer._cachestore.load(filename)
+ transformer._namespace = parser.get_namespace()
+ del transformer._includes[transformer._namespace.name]
+ return transformer
+
def _parse_include(self, filename, uninstalled=False):
parser = None
if self._cachestore is not None:
diff --git a/tools/g-ir-doc-tool.in b/tools/g-ir-doc-tool.in
index dcf0112..4a84afa 100644
--- a/tools/g-ir-doc-tool.in
+++ b/tools/g-ir-doc-tool.in
@@ -21,6 +21,9 @@
import os
import sys
+import __builtin__
+
+__builtin__.__dict__['DATADIR'] = "@datarootdir@"
if 'GI_SCANNER_DEBUG' in os.environ:
def on_exception(exctype, value, tb):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]