readthedocs / sphinx-autoapi

A new approach to API documentation in Sphinx.
https://sphinx-autoapi.readthedocs.io/
MIT License
415 stars 126 forks source link

AttributeError: 'Module' object has no attribute 'doc' #410

Closed 12rambau closed 7 months ago

12rambau commented 8 months ago

Recently the pydata-sphinx-theme pipeline started showing error upon build. Investigating the logs from RDT it seems the error is related to this extention:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/envs/1490/lib/python3.9/site-packages/sphinx/events.py", line 94, in emit
    results.append(listener.handler(self.app, *args))
  File "/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/envs/1490/lib/python3.9/site-packages/autoapi/extension.py", line 153, in run_autoapi
    if sphinx_mapper_obj.load(
  File "/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/envs/1490/lib/python3.9/site-packages/autoapi/mappers/python/mapper.py", line 300, in load
    data = self.read_file(path=path, dir_root=dir_root)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/envs/1490/lib/python3.9/site-packages/autoapi/mappers/python/mapper.py", line 318, in read_file
    parsed_data = Parser().parse_file(path)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/envs/1490/lib/python3.9/site-packages/autoapi/mappers/python/parser.py", line 41, in parse_file
    return self._parse_file(
  File "/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/envs/1490/lib/python3.9/site-packages/autoapi/mappers/python/parser.py", line 38, in _parse_file
    return self.parse(node)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/envs/1490/lib/python3.9/site-packages/autoapi/mappers/python/parser.py", line 265, in parse
    data = parse_func(node)
  File "/home/docs/checkouts/readthedocs.org/user_builds/pydata-sphinx-theme/envs/1490/lib/python3.9/site-packages/autoapi/mappers/python/parser.py", line 240, in parse_module
    "doc": _prepare_docstring(node.doc or ""),
AttributeError: 'Module' object has no attribute 'doc'

Do you have any idea where this would come from ?

evilaliv3 commented 7 months ago

I just wanted to add that we are incurring on this at @globaleaks as well and i confirm that we also use sphinx-autoapi; i will let you know if we will identify the specific reason

mcflugen commented 7 months ago

@12rambau, @evilaliv3 What version of sphinx-autoapi are you using? I just encountered the above error when using v2.1.1 but it went away when I upgraded to v3.0.0.

evilaliv3 commented 7 months ago

@mcflugen: i was not indicating the version so i guess it was using the version 3.0.0.

I did a test enforcing the usage of 2.1.1 and i continued to have the issue.

12rambau commented 7 months ago

The error was raised by our CI which uses the latest available version it was 3.0.0

AWhetter commented 7 months ago

It looks like you're using an old version of AutoAPI paired with a newer version of astroid. You can either pin the version of astroid (I'm not sure which version removed the doc attributes) or update your version of AutoAPI to v3.0.0. Here's where this was fixed in AutoAPI: https://github.com/readthedocs/sphinx-autoapi/commit/0ba883ab891b18aca00d7931a91ecf3aafb2439c