def enter_generic(self, node): # just traverse all top-level statements, check their comments, and # bail for comment in node.get('comments') or []: if '@typedef' in comment['value']: extract = '\n' + jsdoc.strip_stars('/*' + comment['value'] + '\n*/') parsed = pyjsdoc.parse_comment(extract, u'') p = jsdoc.ParamDoc(parsed['typedef']) parsed['name'] = p.name parsed['sourcemodule'] = self.parent.module # TODO: add p.type as superclass somehow? Builtin types not in scope :( self.result.append(jsdoc.ClassDoc(parsed)) return SKIP
def parse_comments(comments, doctype=None): # find last comment which starts with a * docstring = next( (c['value'] for c in reversed(comments or []) if c['value'].startswith(u'*')), None) or u"" # \n prefix necessary otherwise parse_comment fails to take first # block comment parser strips delimiters, but strip_stars fails without # them extract = '\n' + strip_stars('/*' + docstring + '\n*/') parsed = pyjsdoc.parse_comment(extract, u'') if doctype == 'FunctionExpression': doctype = FunctionDoc elif doctype == 'ObjectExpression' or doctype is None: doctype = guess if doctype is guess: return doctype(parsed) # in case a specific doctype is given, allow overriding it anyway return guess(parsed, default=doctype)
def parse_comments(comments, doctype=None): # find last comment which starts with a * docstring = next(( c['value'] for c in reversed(comments or []) if c['value'].startswith(u'*') ), None) or u"" # \n prefix necessary otherwise parse_comment fails to take first # block comment parser strips delimiters, but strip_stars fails without # them extract = '\n' + strip_stars('/*' + docstring + '\n*/') parsed = pyjsdoc.parse_comment(extract, u'') if doctype == 'FunctionExpression': doctype = FunctionDoc elif doctype == 'ObjectExpression' or doctype is None: doctype = guess if doctype is guess: return doctype(parsed) # in case a specific doctype is given, allow overriding it anyway return guess(parsed, default=doctype)