Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sidebar #602

Merged
merged 6 commits into from
Jun 30, 2022
Merged

Fix sidebar #602

merged 6 commits into from
Jun 30, 2022

Conversation

tristanlatr
Copy link
Contributor

@tristanlatr tristanlatr commented Jun 12, 2022

Fixes #601

@codecov
Copy link

codecov bot commented Jun 12, 2022

Codecov Report

Merging #602 (4a2eefd) into master (19e2976) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #602      +/-   ##
==========================================
+ Coverage   91.13%   91.16%   +0.02%     
==========================================
  Files          46       46              
  Lines        7839     7840       +1     
  Branches     1701     1701              
==========================================
+ Hits         7144     7147       +3     
+ Misses        434      433       -1     
+ Partials      261      260       -1     
Impacted Files Coverage Δ
pydoctor/templatewriter/pages/__init__.py 84.00% <100.00%> (ø)
pydoctor/templatewriter/pages/sidebar.py 98.03% <100.00%> (+0.98%) ⬆️
pydoctor/templatewriter/util.py 96.29% <100.00%> (+0.04%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 19e2976...4a2eefd. Read the comment docs.

@tristanlatr tristanlatr requested a review from glyph June 14, 2022 01:45
Comment on lines 117 to 119
for inherited_via,attrs in inherited_members(cls):
if len(inherited_via)>1:
children.extend(attrs)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual fix!

Copy link
Member

@glyph glyph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -166,7 +172,7 @@ def _children(self, inherited: bool = False) -> Optional[List[Documentable]]:
return sorted((o for o in util.list_inherited_members(self.ob) if o.isVisible),
key=util.objects_order)
else:
return None
assert False, "Use inherited=True only with Class instances"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate trying to keep the diff small, but assertions in the negative path like this are somewhat confusing to read; it seems like there's going to be a path through at first and then there isn't. When reading the assertion in a traceback it's less clear what's being asserted. Instead, I'd do:

assert isinstance(self.ob, Class), "Use inherited=True only with Class instances"
return sorted((o for o in util.list_inherited_members(self.ob) if o.isVisible), key=util.objects_order)

Sorry that's not a suggestion, but it modifies lines outside the diff…

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've applies your suggestion.


if isinstance(self.ob, Class):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Longer-term question: could this be added as a method to Documentable so we can just call it on self.ob rather than dispatching on type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the _children() method?
I’ts using processing code that is not currently in the model, in the util.py file.
But I agree it could be moved in the model.

We could introduce a method as follow:

def children(inherited:bool=False, ofclass:Optional[Type[Documentable]]=None) -> Iterator[Documentable]

@tristanlatr tristanlatr merged commit eb364bb into master Jun 30, 2022
@tristanlatr tristanlatr deleted the fix-sidebar branch June 30, 2022 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken inherited attributes in sidebar
2 participants