feat: Allow resolving alias to external modules#60
feat: Allow resolving alias to external modules#60pawamoy merged 1 commit intomkdocstrings:masterfrom
Conversation
|
Hello, thanks for the PR! May I ask what is your use-case, and what you think of this comment mkdocstrings/mkdocstrings#503 (comment)? |
Basically I have a rather large library that is exposed through multiple independent modules with other 'root' names - they do not share a package name (a bad case of need to preserve backward computability). The use of I think I can manage with pre loading as you suggested in the issue you have referenced, although it will require a bit more manual work, of finding out which modules to pre-load. I think I can change this PR to add From my POV the external and selectively using |
I see, thanks.
Yeah, because of the lack of a standard way to "export" objects or make them public,
Just to be clear: the preload solution would add a configuration option in the Python handler, and its value would be used as early as possible to load the specified modules in the handler's Both (preload, and external+ I'm imagining something like this: starting from scratch, users temporarily allow loading external modules, and at the end of the build, the Python handler outputs an info/debug message suggesting to disable external loading and enable pre-loading with the list of external modules it loaded during the build. Maybe we could even try to exclude modules for which no objects were rendered from this suggested list. But these are nice-to-have, it could be done later. If you feel like implementing both, that would be awesome! I'd recommend doing it in two distinct PRs. Let me know if that makes sense! In any case this conversation helped me clear my mind and I can see the path forward, so I'd eventually get it to it 🙂 |
5516ddf to
3d9eb81
Compare
|
I changed the PR to preload modules. It works good enough for my use case, and I'm ok with that, and with adding external at a different PR. Let me know if you think that is good enough. |
f3f704e to
a2bc632
Compare
|
Hello! No worries, pinging me is the right way 🙂 |
6bcd7df to
b774ff7
Compare
pawamoy
left a comment
There was a problem hiding this comment.
OK, sounds good to me. I checked it out and it seems it's not possible to preload the modules in the __init__ method yet. So lets do it this way for now and maybe we'll refactor later 🙂 Thanks a lot!
53ca4da to
fe64e72
Compare
Add option to preload external modules that are not part of the displayed documentation to allow resolving aliases to objects in these modules, and presenting their documentation in a module that imports them, and exports the imports with `__all__` attribute.
fe64e72 to
d9a6326
Compare
Add option to preload modules. Preloading modules allows to render members of objects that originate from other packages than their parent. Direct members of modules must be listed in `__all__`. This option typically allows to render aliases, by collecting their parent module (package) which allows to resolve these aliases. Issue mkdocstrings/mkdocstrings#503: mkdocstrings/mkdocstrings#503 PR #60: mkdocstrings/python#60
PR #61: mkdocstrings/python#61 Follow-up of PR #60: mkdocstrings/python#60 Co-authored-by: gilfree <gilfree@users.noreply.github.com>
Hi
I would like to suggest adding an option (false by default) to set griffe's resolve external modules flag to true.
What are your thoughts about it? Did I do it correctly? As I am not a native English speaker, my documentation my need some improvement.