-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
feat: Support inheritance #170
Conversation
eb65091
to
9f93ff0
Compare
470c96c
to
80d0000
Compare
f4de5f5
to
0706e6e
Compare
This looks great! One quick thought on...
I wonder if it will be helpful downstream in the python handler to emit a warning, if someone uses |
Good point! We already log a debug message when a base class cannot be resolved: logger.debug(f"Base class {base_path} is not loaded, or not static, it cannot be resolved") Do you think that's enough? I don't want to add anything about upstream projects (mkdocstrings, mkdocstrings-python) within Griffe, as it's not concerned by them. |
4f000ba
to
aa621e3
Compare
Ah, yeah that seems great! I think we might be thinking of the same thing, but using upstream and downstream in different ways (I think of mkdocstrings as downstream of griffe 😅). I was thinking it might be helpful to give a more specific message in mkdocs-python, like "You may not see documentation for all members, since class X is not pre-loaded." But the griffe message already seems very reasonable |
You're right, I should have said downstream 🤔
Thanks, I get it now. Unfortunately, once in mkdocstrings-python, I don't think there's a clean way to rework the message 😕 Lets go with the Griffe debug message for now, and see later if it can be improved (if it generates too much confusion within users) 🙂 I'll definitely add such a message in the docs though! |
aa621e3
to
150d47a
Compare
This needs a bit more work for proper integration within mkdocstrings' Python handler. I'll explain later. |
The consumer API can be used when navigating or modifying the tree once it was built by Griffe and extensions. The producer API must be used when building the objects tree, so by Griffe itself and by extensions. Using the consumer API while building is risky because the consumer API does ~~magic~~ convenient things and trigger too-early computation of different things like inherited members.
150d47a
to
8738081
Compare
Ready for review, if some of you would like to run a final pass 🙂 |
Closes #138
Closes #153
Unblocks work on #96, mkdocstrings/python#40, mkdocstrings/python#13
Related to mkdocstrings/mkdocstrings#459, mkdocstrings/mkdocstrings#157, mkdocstrings/mkdocstrings#536
Tagging people who are probably interested: @samsja, @tazend, @cpcloud, @famura, @machow, @gab832, @analog-cbarber, @jayqi, @chrieke, @tristanlatr
Feel free to tag others. Also, subscribe to this PR to get future notifications: I'll explain the changes in this PR later so that we can discuss them. Or unsubscribe to stop getting notifications 🙂
Explanation:
Object.inherited_members
Class
es representing them) and use C3 linearization to build the dict of inherited members according to Python's MRO (method resolution order)modules_collection
) are fetchedmkdocstrings and the Python handler:
inherit_members: true/false
, false by defaultmembers
attribute of objects will be used to filter membersall_members
property of objects will be used to filter membersTodo: