Skip to content

Commit

Permalink
Tmptmptmp
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinugu committed Oct 17, 2023
1 parent 5d92354 commit 73df13f
Showing 1 changed file with 14 additions and 38 deletions.
52 changes: 14 additions & 38 deletions docs/pdocs/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,18 @@ def _var_docstrings(tree, module, cls=None, init=False):
if isinstance(child, ast.Assign) and len(child.targets) == 1:
if not init and isinstance(child.targets[0], ast.Name):
name = child.targets[0].id
elif (
isinstance(child.targets[0], ast.Attribute)
and isinstance(child.targets[0].value, ast.Name)
and child.targets[0].value.id == "self"
):
elif (isinstance(child.targets[0], ast.Attribute) and
isinstance(child.targets[0].value, ast.Name) and
child.targets[0].value.id == "self"):
name = child.targets[0].attr
else:
continue
if not _is_exported(name) and name not in getattr(module, "__all__", []):
continue

docstring = ""
if (
i + 1 < len(children)
and isinstance(children[i + 1], ast.Expr)
and isinstance(children[i + 1].value, ast.Str)
):
if (i + 1 < len(children) and isinstance(children[i + 1], ast.Expr) and
isinstance(children[i + 1].value, ast.Str)):
docstring = children[i + 1].value.s

vs[name] = Variable(name, module, docstring, cls=cls)
Expand Down Expand Up @@ -98,9 +93,8 @@ def _is_method(cls: typing.Type, method_name: str) -> bool:
if method_name in c.__dict__:
return not isinstance(c.__dict__[method_name], staticmethod)
else:
raise ValueError(
"{method_name} not found in {cls}.".format(method_name=method_name, cls=cls)
)
raise ValueError("{method_name} not found in {cls}.".format(
method_name=method_name, cls=cls))


def _filter(items, kind, attributes_set=(), attributes_not_set=(), sort=True):
Expand Down Expand Up @@ -131,7 +125,6 @@ class Doc(object):
also correspond to unexported members of the module, particularly in
a class's ancestor list.)
"""

def __init__(self, name, module, docstring):
"""
Initializes a documentation object, where `name` is the public
Expand Down Expand Up @@ -203,9 +196,7 @@ class Module(Doc):
"""

__pdoc__["Module.module"] = "The Python module object."
__pdoc__[
"Module.name"
] = """
__pdoc__["Module.name"] = """
The name of this module with respect to the context in which
it was imported. It is always an absolute import path.
"""
Expand Down Expand Up @@ -446,13 +437,8 @@ def __public_objs(self):
Python object.
"""
members = dict(inspect.getmembers(self.module))
return dict(
[
(name, obj)
for name, obj in members.items()
if self.__is_exported(name, inspect.getmodule(obj))
]
)
return dict([(name, obj) for name,
obj in members.items() if self.__is_exported(name, inspect.getmodule(obj))])

def allmodules(self):
yield self
Expand All @@ -470,7 +456,6 @@ class Class(Doc):
"""
Representation of a class's documentation.
"""

def __init__(self, name, module, class_obj):
"""
Same as `pdocs.Doc.__init__`, except `class_obj` must be a
Expand Down Expand Up @@ -518,8 +503,7 @@ def __init__(self, name, module, class_obj):

if inspect.isroutine(obj):
self.doc[name] = Function(
name, self.module, obj, cls=self, method=_is_method(self.cls, name)
)
name, self.module, obj, cls=self, method=_is_method(self.cls, name))
elif isinstance(obj, property):
docstring = getattr(obj, "__doc__", "")
self.doc_init[name] = Variable(name, self.module, docstring, cls=self)
Expand Down Expand Up @@ -648,7 +632,6 @@ class Function(Doc):
"""
Representation of documentation for a Python function or method.
"""

def __init__(self, name, module, func_obj, cls=None, method=False):
"""
Same as `pdoc.Doc.__init__`, except `func_obj` must be a
Expand Down Expand Up @@ -799,7 +782,6 @@ class Variable(Doc):
Representation of a variable's documentation. This includes
module, class and instance variables.
"""

def __init__(self, name, module, docstring, cls=None):
"""
Same as `pdoc.Doc.__init__`, except `cls` should be provided
Expand Down Expand Up @@ -837,21 +819,15 @@ class External(Doc):
the ancestor list of a class).
"""

__pdoc__[
"External.docstring"
] = """
__pdoc__["External.docstring"] = """
An empty string. External identifiers do not have
docstrings.
"""
__pdoc__[
"External.module"
] = """
__pdoc__["External.module"] = """
Always `None`. External identifiers have no associated
`pdoc.Module`.
"""
__pdoc__[
"External.name"
] = """
__pdoc__["External.name"] = """
Always equivalent to `pdoc.External.refname` since external
identifiers are always expressed in their fully qualified
form.
Expand Down

0 comments on commit 73df13f

Please sign in to comment.