daizutabi / mkapi

A plugin for MkDocs to generate API documentation
https://daizutabi.github.io/mkapi/
MIT License
103 stars 19 forks source link

AbstractBaseClass - TypeError: descriptor 'mro' of 'type' object #12

Closed Ahrak closed 4 years ago

Ahrak commented 4 years ago

Hello,

Current version (0.7.7) throws TypeError if the base class is Abstract (abc.ABC)

Rerproduce Error: change the follwing in examples/inherit.py

from dataclasses import dataclass

from mkapi.core.base import Type
import abc

@dataclass
class Base(abc.ABC):
...

Trace:

ERROR   -  Error reading page 'usage/inherit.md': descriptor 'mro' of 'type' object needs an argument 
Traceback (most recent call last):
  File "./mkapi/.env/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "./mkapi/.env/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "./mkapi/.env/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "./mkapi/.env/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "./mkapi/.env/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "./mkapi/.env/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "./mkapi/.env/lib/python3.8/site-packages/mkdocs/__main__.py", line 152, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "./mkapi/.env/lib/python3.8/site-packages/mkdocs/commands/build.py", line 271, in build
    _populate_page(file.page, config, files, dirty)
  File "./mkapi/.env/lib/python3.8/site-packages/mkdocs/commands/build.py", line 167, in _populate_page
    page.markdown = config['plugins'].run_event(
  File "./mkapi/.env/lib/python3.8/site-packages/mkdocs/plugins.py", line 94, in run_event
    result = method(item, **kwargs)
  File "./mkapi/mkapi/plugins/mkdocs.py", line 86, in on_page_markdown
    page = Page(markdown, abs_src_path, self.abs_api_paths)
  File "<string>", line 6, in __init__
  File "./mkapi/mkapi/core/page.py", line 36, in __post_init__
    self.markdown = "\n\n".join(self.split(source))
  File "./mkapi/mkapi/core/page.py", line 57, in split
    node = get_node(name)
  File "./mkapi/mkapi/core/node.py", line 197, in get_node
    return _get_node(obj, sourcefile_index)
  File "./mkapi/mkapi/core/node.py", line 180, in _get_node
    return Node(obj, sourcefile_index)
  File "<string>", line 5, in __init__
  File "./mkapi/mkapi/core/node.py", line 30, in __post_init__
    super().__post_init__()
  File "./mkapi/mkapi/core/tree.py", line 49, in __post_init__
    self.members = self.get_members()
  File "./mkapi/mkapi/core/node.py", line 58, in get_members
    return get_members(self.obj)
  File "./mkapi/mkapi/core/node.py", line 169, in get_members
    member = get_node(obj, sourcefile_index)
  File "./mkapi/mkapi/core/node.py", line 197, in get_node
    return _get_node(obj, sourcefile_index)
  File "./mkapi/mkapi/core/node.py", line 180, in _get_node
    return Node(obj, sourcefile_index)
  File "<string>", line 5, in __init__
  File "./mkapi/mkapi/core/node.py", line 30, in __post_init__
    super().__post_init__()
  File "./mkapi/mkapi/core/tree.py", line 48, in __post_init__
    self.docstring = get_docstring(obj)
  File "./mkapi/mkapi/core/docstring.py", line 297, in get_docstring
    postprocess(docstring, obj)
  File "./mkapi/mkapi/core/docstring.py", line 230, in postprocess
    add_bases(doc, obj)
  File "./mkapi/mkapi/core/docstring.py", line 214, in add_bases
    bases = obj.mro()[1:-1]
TypeError: descriptor 'mro' of 'type' object needs an argument
daizutabi commented 4 years ago

I fixed the problem in Version 0.7.8.

img img2
Ahrak commented 4 years ago

yes, thx.