diff options
| author | Xavier Morel <xmo@odoo.com> | 2017-10-10 13:29:11 +0200 |
|---|---|---|
| committer | Xavier Morel <xmo@odoo.com> | 2017-10-10 13:29:11 +0200 |
| commit | 40ca8557e9e25832afa40afd84124319cb71f87b (patch) | |
| tree | b4792e33b8404b75274e33e317de1183bb86e795 /doc/_extensions/autojsdoc | |
| parent | 8071742959b03020ff2cf32670bb5495804eae57 (diff) | |
[FIX] building documentation with P3
* fix P3 incompatibilities in doc/_extensions
* vendor pyjsdoc, strip out everything we're not using and make what's
left P3-compatible (upstream is not P3 compliant)
* drop undeclared dependency on attrs as it turns out not to be much
used
Diffstat (limited to 'doc/_extensions/autojsdoc')
| -rw-r--r-- | doc/_extensions/autojsdoc/__main__.py | 6 | ||||
| -rw-r--r-- | doc/_extensions/autojsdoc/parser/jsdoc.py | 2 | ||||
| -rw-r--r-- | doc/_extensions/autojsdoc/parser/parser.py | 25 | ||||
| -rw-r--r-- | doc/_extensions/autojsdoc/parser/utils.py | 6 |
4 files changed, 21 insertions, 18 deletions
diff --git a/doc/_extensions/autojsdoc/__main__.py b/doc/_extensions/autojsdoc/__main__.py index 20ab65c2c37..2ac5f3a0cb3 100644 --- a/doc/_extensions/autojsdoc/__main__.py +++ b/doc/_extensions/autojsdoc/__main__.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from __future__ import print_function import cgitb import fnmatch import io @@ -6,13 +7,12 @@ import logging import click -import pyjsdoc import pyjsparser import sys from .parser.parser import ModuleMatcher from .parser.visitor import Visitor, SKIP -from . import jsdoc +from .parser import jsdoc class Printer(Visitor): def __init__(self, level=0): @@ -20,7 +20,7 @@ class Printer(Visitor): self.level = level def _print(self, text): - print ' ' * self.level, text + print(' ' * self.level, text) def enter_generic(self, node): self._print(node['type']) diff --git a/doc/_extensions/autojsdoc/parser/jsdoc.py b/doc/_extensions/autojsdoc/parser/jsdoc.py index 00406df42c1..a34a2aa9b83 100644 --- a/doc/_extensions/autojsdoc/parser/jsdoc.py +++ b/doc/_extensions/autojsdoc/parser/jsdoc.py @@ -174,7 +174,7 @@ class NSDoc(CommentDoc): for p in self.get_as_list('property') ) ] - return self.members.items() or self['_members'] or [] + return list(self.members.items()) or self['_members'] or [] def has_property(self, name): return self.get_property(name) is not None diff --git a/doc/_extensions/autojsdoc/parser/parser.py b/doc/_extensions/autojsdoc/parser/parser.py index d91b9f22596..358d20c8e9b 100644 --- a/doc/_extensions/autojsdoc/parser/parser.py +++ b/doc/_extensions/autojsdoc/parser/parser.py @@ -2,7 +2,6 @@ import collections import pyjsdoc -from attr import attrs, Factory, attr, astuple from . import jsdoc from . import utils @@ -97,21 +96,25 @@ def m2r(me, scope): utils._value(me['property'], strict=True) ) -@attrs(slots=True) +NOTHING = object() class Declaration(object): - id = attr(default=None) - comments = attr(default=Factory(list)) -@attrs(slots=True) + __slots__ = ['id', 'comments'] + def __init__(self, id=None, comments=NOTHING): + self.id = id + self.comments = [] if comments is NOTHING else comments + class ModuleContent(object): - dependencies = attr(default=Factory(set)) - post = attr(default=Factory(list)) + __slots__ = ['dependencies', 'post'] + def __init__(self, dependencies=NOTHING, post=NOTHING): + self.dependencies = set() if dependencies is NOTHING else dependencies + self.post = [] if post is NOTHING else post def __iter__(self): yield self.dependencies yield self.post -@attrs # needs dict as it's replacing a ModuleProxy class Nothing(object): - name = attr() + def __init__(self, name): + self.name = name def __bool__(self): return False __nonzero__ = __bool__ @@ -389,7 +392,7 @@ class ValueExtractor(Visitor): return SKIP def enter_FunctionExpression(self, node): - name, comments = astuple(self.declaration) + name, comments = (self.declaration.id, self.declaration.comments) self.result = jsdoc.parse_comments(comments, jsdoc.FunctionDoc) self.result.parsed['name'] = node['id'] and node['id']['name'] self._update_result_meta() @@ -437,7 +440,7 @@ class ValueExtractor(Visitor): }, }): # creates a new class, but may not actually return it obj = node['callee']['object'] - _, comments = astuple(self.declaration) + comments = self.declaration.comments self.result = cls = jsdoc.parse_comments(comments, jsdoc.ClassDoc) cls.parsed['extends'] = self.parent.refify(obj) self._update_result_meta() diff --git a/doc/_extensions/autojsdoc/parser/utils.py b/doc/_extensions/autojsdoc/parser/utils.py index b8b1a97e7aa..213327f6c0e 100644 --- a/doc/_extensions/autojsdoc/parser/utils.py +++ b/doc/_extensions/autojsdoc/parser/utils.py @@ -104,7 +104,7 @@ def resolve(obj, store): if obj is None: return None - if isinstance(obj, (unicode, bool, int, float)): + if isinstance(obj, (type(u''), bool, int, float)): return obj if isinstance(obj, ModuleProxy): @@ -139,11 +139,11 @@ class Namespace(Resolvable): r = super(Namespace, self).resolve(store) self.attrs = { k: resolve(v, store) - for k, v in self.attrs.iteritems() + for k, v in self.attrs.items() } return r def __getitem__(self, key): - assert isinstance(key, unicode), "%r is not a namespace key" % key + assert isinstance(key, type(u'')), "%r is not a namespace key" % key try: return self.attrs[key] except KeyError: |
