Skip to content

Commit

Permalink
feat: Support griffe 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jan 14, 2022
1 parent 4cdb292 commit 28061de
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
16 changes: 7 additions & 9 deletions src/mkdocstrings/handlers/python/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,15 @@ def collect(self, identifier: str, config: dict) -> CollectorItem: # noqa: WPS2
lines_collection=self._lines_collection,
)
try:
module = loader.load_module(module_name)
except ModuleNotFoundError as error:
raise CollectionError from error
loader.load_module(module_name)
except ImportError as error:
raise CollectionError(str(error)) from error

for _ in range(5):
if loader.follow_aliases(module):
break
else:
logger.warning("some aliases could not be resolved")
unresolved, iterations = loader.resolve_aliases(only_exported=True, only_known_modules=True)
if unresolved:
logger.warning(f"{len(unresolved)} aliases were still unresolved after {iterations} iterations")

try:
return self._modules_collection[identifier]
except KeyError as error: # noqa: WPS440
raise CollectionError from error
raise CollectionError(f"{identifier} could not be found") from error
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ log.debug() }}
{% if config.show_if_no_docstring or attribute %}
{% if config.show_if_no_docstring or attribute.has_docstrings %}

<div class="doc doc-object doc-attribute">
{% with html_id = attribute.path %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ log.debug() }}
{% if config.show_if_no_docstring or class %}
{% if config.show_if_no_docstring or class.has_docstrings %}

<div class="doc doc-object doc-class">
{% with html_id = class.path %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
{% include "docstring/returns.html" with context %}
{% elif section.kind.value == "examples" %}
{% include "docstring/examples.html" with context %}
{% elif section.kind.value == "admonition" %}
<details class="{{ section.value.kind }}">
{{ section.title|convert_markdown(heading_level, html_id) }}
{{ section.value.contents|convert_markdown(heading_level, html_id) }}
</details>
{% endif %}
{% endfor %}
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ log.debug() }}
{% if config.show_if_no_docstring or function %}
{% if config.show_if_no_docstring or function.has_docstrings %}

<div class="doc doc-object doc-function">
{% with html_id = function.path %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ log.debug() }}
{% if config.show_if_no_docstring or module %}
{% if config.show_if_no_docstring or module.has_docstrings %}

<div class="doc doc-object doc-module">
{% with html_id = module.path %}
Expand Down

0 comments on commit 28061de

Please sign in to comment.