diff options
author | Dieter Verfaillie <dieterv@optionexplicit.be> | 2013-04-24 14:06:18 +0200 |
---|---|---|
committer | Dieter Verfaillie <dieterv@optionexplicit.be> | 2013-05-07 23:38:22 +0200 |
commit | c9e2d880011c530ff1454fe31a2d40d189860be5 (patch) | |
tree | 9acdf7d7cf409ffd8d0f7967ebf9d03497d31269 /giscanner/docwriter.py | |
parent | a031129d8ab28e2f51e95e7266f1274bdc592557 (diff) | |
download | gobject-introspection-c9e2d880011c530ff1454fe31a2d40d189860be5.tar.gz |
tests: Update misc/pep8.py to 1.4.5
Version in our tree is a wee bit outdated. For example,
later work will introduce an utf8 encoded python source
file which our old pep8.py does not yet understand (yeah,
it really was *that* ancient)...
Updated from:
https://raw.github.com/jcrocholl/pep8/1.4.5/pep8.py
Takes 552c1f1525e37a30376790151c1ba437776682c5,
f941537d1c0a40f0906490ed160db6c79af572d3,
5a4afe2a77d0ff7d9fea13dd93c3304a6ca993de and
a17f157e19bd6792c00321c8020dca5e5a281f45 into account...
https://bugzilla.gnome.org/show_bug.cgi?id=699535
Diffstat (limited to 'giscanner/docwriter.py')
-rw-r--r-- | giscanner/docwriter.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py index b3716ec6..982ab37c 100644 --- a/giscanner/docwriter.py +++ b/giscanner/docwriter.py @@ -31,6 +31,7 @@ from mako.lookup import TemplateLookup from . import ast, xmlwriter from .utils import to_underscores + def make_page_id(node, recursive=False): if isinstance(node, ast.Namespace): if recursive: @@ -51,6 +52,7 @@ def make_page_id(node, recursive=False): else: return '%s.%s' % (make_page_id(parent, recursive=True), node.name) + def get_node_kind(node): if isinstance(node, ast.Namespace): node_kind = 'namespace' @@ -78,6 +80,7 @@ def get_node_kind(node): return node_kind + class TemplatedScanner(object): def __init__(self, specs): self.specs = self.unmangle_specs(specs) @@ -141,6 +144,7 @@ class TemplatedScanner(object): if pos < len(text): yield ('other', text[pos:], None) + class DocstringScanner(TemplatedScanner): def __init__(self): specs = [ @@ -156,6 +160,7 @@ class DocstringScanner(TemplatedScanner): super(DocstringScanner, self).__init__(specs) + class DocFormatter(object): def __init__(self, transformer): self._transformer = transformer @@ -358,6 +363,7 @@ class DocFormatter(object): parent_chain.reverse() return parent_chain + class DocFormatterC(DocFormatter): language = "C" mime_type = "text/x-csrc" @@ -380,7 +386,7 @@ class DocFormatterC(DocFormatter): return getattr(node, 'ctype') def format_function_name(self, func): - if isinstance(func, (ast.Function)): + if isinstance(func, ast.Function): return func.symbol else: return func.name @@ -388,6 +394,7 @@ class DocFormatterC(DocFormatter): def get_parameters(self, node): return node.all_parameters + class DocFormatterIntrospectableBase(DocFormatter): def should_render_node(self, node): if isinstance(node, ast.Record) and node.is_gtype_struct_for is not None: @@ -398,6 +405,7 @@ class DocFormatterIntrospectableBase(DocFormatter): return super(DocFormatterIntrospectableBase, self).should_render_node(node) + class DocFormatterPython(DocFormatterIntrospectableBase): language = "Python" mime_type = "text/python" @@ -418,7 +426,7 @@ class DocFormatterPython(DocFormatterIntrospectableBase): if getattr(node, "is_method", False): return True - if isinstance(node, (ast.VFunction)): + if isinstance(node, ast.VFunction): return True return False @@ -451,8 +459,7 @@ class DocFormatterPython(DocFormatterIntrospectableBase): "GParam": "GLib.Param", "PyObject": "object", "GStrv": "[str]", - "GVariant": "GLib.Variant", - } + "GVariant": "GLib.Variant"} return fundamental_types.get(name, name) @@ -476,6 +483,7 @@ class DocFormatterPython(DocFormatterIntrospectableBase): def get_parameters(self, node): return node.all_parameters + class DocFormatterGjs(DocFormatterIntrospectableBase): language = "Gjs" mime_type = "text/x-gjs" @@ -490,7 +498,7 @@ class DocFormatterGjs(DocFormatterIntrospectableBase): if getattr(node, "is_method", False): return True - if isinstance(node, (ast.VFunction)): + if isinstance(node, ast.VFunction): return True return False @@ -514,8 +522,7 @@ class DocFormatterGjs(DocFormatterIntrospectableBase): "GParam": "GLib.Param", "PyObject": "Object", "GStrv": "[String]", - "GVariant": "GLib.Variant", - } + "GVariant": "GLib.Variant"} return fundamental_types.get(name, name) @@ -558,12 +565,14 @@ class DocFormatterGjs(DocFormatterIntrospectableBase): params.append(param) return params + LANGUAGES = { "c": DocFormatterC, "python": DocFormatterPython, "gjs": DocFormatterGjs, } + class DocWriter(object): def __init__(self, transformer, language): self._transformer = transformer |