Chilipp / autodocsumm

Extending your autodoc API docs with a summary
Apache License 2.0
48 stars 14 forks source link

Error if using autosummary for a cython extension module #6

Closed coldfix closed 5 years ago

coldfix commented 5 years ago

Hi,

when adding the :autosummary: option to a automodule directive for a python module that was generated by cython, I get an error with the following traceback:

  File "[...]/autodocsumm/autodocsumm/__init__.py", line 421, in run
    doc_nodes = AutodocDirective.run(self)
  File "[...]/sphinx/ext/autodoc/directive.py", line 135, in run
    documenter.generate(more_content=self.content)
  File "[...]/sphinx/ext/autodoc/__init__.py", line 711, in generate
    self.analyzer = ModuleAnalyzer.for_module(self.real_modname)
  File "[...]/sphinx/pycode/__init__.py", line 72, in for_module
    type, source = get_module_source(modname)
  File "[...]/sphinx/util/__init__.py", line 312, in get_module_source
    raise PycodeError('source is not a .py file: %r' % filename)

The pure automodule directive without autosummary works.

So far, I haven't investigated deep enough on how this could be fixed.

Chilipp commented 5 years ago

Hi @coldfix! Thanks for your thorough investigations 😄 Yes, this might cause difficulties since it is not straightforward to handle the docstrings of cython files. I'll have a look into it

Chilipp commented 5 years ago

Hi @coldfix, I think I found a solution in PR https://github.com/Chilipp/autodocsumm/pull/7. Could you try this and verify that it works? I basically mimic the behaviour of the AutosummaryDocumenter.get_grouped_documenters method.

This solution is motivated (and copied) from the autodoc.Documenter.generate method.