Skip to content

Commit

Permalink
Tmptmp
Browse files Browse the repository at this point in the history
  • Loading branch information
sveinugu committed Oct 17, 2023
1 parent 22acdab commit bbaa17e
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 22 deletions.
25 changes: 13 additions & 12 deletions docs/templates/pdocs/class.mako
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,20 @@ ${cls.docstring}
mro = cls.mro()
subclasses = cls.subclasses()
%>
% if mro:
${h4('Ancestors (in MRO)')}
% for c in mro:
* ${c.refname}
% endfor
% endif
% if subclasses:
${h4('Descendants')}
% for c in subclasses:
* ${c.refname}
% endfor
% endif
## % if mro:
## ${h4('Ancestors (in MRO)')}
## % for c in mro:
## * ${c.refname}
## % endfor
## % endif
## % if subclasses:
## ${h4('Descendants')}
## % for c in subclasses:
## * ${c.refname}
## % endfor
## % endif
% if class_vars_internal:
${h4('Class variables')}
Expand Down
23 changes: 21 additions & 2 deletions scripts/generate_portray_docs_in_browser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
#!/usr/bin/env python

import pdocs.doc
from portray import api as portray_api

portray_api.in_browser()

def _is_exported(ident_name):
return not ident_name.startswith("_") or ident_name in [
'__enter__',
'__exit__',
'__cmp__',
'__eq__',
'__getattr__',
'__setattr__',
'__getitem_',
'__setitem__',
'__delitem__',
'__iter__',
'__call__'
]


pdocs.doc._is_exported = _is_exported

portray_api.in_browser()
48 changes: 40 additions & 8 deletions src/omnipy/util/mako_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,49 @@ def filter_external(members: List[Doc]):


def filter_internal(members: List[Doc]):
return list(_ for _ in members if not externally_inherited(_))
ret = {_.name: externally_inherited(_) for _ in members}

ret = list(_ for _ in members if not externally_inherited(_))
return ret


# def _fill_inheritance(self):
# """
# Traverses this class's ancestor list and attempts to fill in
# missing documentation from its ancestor's documentation.
#
# The first pass connects variables, methods and functions with
# their inherited couterparts. (The templates will decide how to
# display docstrings.) The second pass attempts to add instance
# variables to this class that were only explicitly declared in
# a parent class. This second pass is necessary since instance
# variables are only discoverable by traversing the abstract
# syntax tree.
# """
# mro = [self.module.find_ident(c.name) for c in self.module.mro(self) if c != self]
# mro = [c for c in mro if isinstance(c, Class)]
def internal(member: Doc):
module_name = ""


def externally_inherited(member: Doc):
if hasattr(member, 'inherits'):
if externally_inherited(member.inherits):
if internal(member.inherits):
return True
elif not member.inherits.cls.module.name.startswith('omnipy'):
print(member.inherits.cls.module.name)
return True
return member.name not in vars(member.cls.cls)
else:
module_name = member.inherits.cls.module.name
elif hasattr(member.cls.cls, member.name):
member_obj = getattr(member.cls.cls, member.name)
if hasattr(member_obj, '__module__') and member_obj.__module__:
module_name = member_obj.__module__
print(f'Without inherits: {member.name} from {module_name}')
else:
return False

return module_name.startswith('omnipy')


def externally_inherited(member: Doc):
inherited = member.name not in vars(member.cls.cls)
return inherited and not internal(member)


def merge_signature_with_docstring(func: Function,
Expand Down

0 comments on commit bbaa17e

Please sign in to comment.