From 40ca8557e9e25832afa40afd84124319cb71f87b Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Tue, 10 Oct 2017 13:29:11 +0200 Subject: [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 --- doc/_extensions/autojsdoc/parser/parser.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'doc/_extensions/autojsdoc/parser/parser.py') 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() -- cgit v1.2.3