astropy / sphinx-automodapi

Sphinx extension for generating API documentation
https://sphinx-automodapi.readthedocs.io
BSD 3-Clause "New" or "Revised" License
65 stars 45 forks source link

TypeError from flask import when generating html doc from automodapi #96

Open seanjkanderson opened 4 years ago

seanjkanderson commented 4 years ago

I am trying to document a routes.py/views.py script for a flask app. However, the build fails on from flask import request. I deduced this by commenting out lines until I isolated this import statement (if there is a better way to debug sphinx commands please let me know). The response:

(opt) Seans-MBP-4:docs seananderson$ sphinx-build -b html . _build
Running Sphinx v2.4.4
/Users/seananderson/Documents/nsr/data_engine/docs
/Users/seananderson/anaconda3/envs/opt/lib/python3.6/site-packages/m2r.py:652: RemovedInSphinx30Warning: app.add_source_parser() does not support suffix argument. Use app.add_source_suffix() instead.
  app.add_source_parser('.md', M2RParser)
loading pickled environment... done

Exception occurred:
  File "/Users/seananderson/anaconda3/envs/opt/lib/python3.6/site-packages/sphinx_automodapi/utils.py", line 99, in find_mod_objs
    fqnames.append(obj.__module__ + '.' + obj.__name__)
TypeError: must be str, not NoneType
The full traceback has been saved in /var/folders/4x/r93csfhd49n5vwksjfxz6m780000gn/T/sphinx-err-d7at05w8.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

The log file:

# Sphinx version: 2.4.4
# Python version: 3.6.8 (CPython)
# Docutils version: 0.14
# Jinja2 version: 2.10.3
# Last messages:

# Loaded extensions:
Traceback (most recent call last):
  File "/Users/seananderson/anaconda3/envs/opt/lib/python3.6/site-packages/sphinx/cmd/build.py", line 275, in build_main
    args.tags, args.verbosity, args.jobs, args.keep_going)
  File "/Users/seananderson/anaconda3/envs/opt/lib/python3.6/site-packages/sphinx/application.py", line 278, in __init__
    self._init_builder()
  File "/Users/seananderson/anaconda3/envs/opt/lib/python3.6/site-packages/sphinx/application.py", line 334, in _init_builder
    self.events.emit('builder-inited')
  File "/Users/seananderson/anaconda3/envs/opt/lib/python3.6/site-packages/sphinx/events.py", line 99, in emit
    results.append(callback(self.app, *args))
  File "/Users/seananderson/anaconda3/envs/opt/lib/python3.6/site-packages/sphinx_automodapi/automodsumm.py", line 256, in process_automodsumm_generation
    lines = automodsumm_to_autosummary_lines(sfn, app)
  File "/Users/seananderson/anaconda3/envs/opt/lib/python3.6/site-packages/sphinx_automodapi/automodsumm.py", line 331, in automodsumm_to_autosummary_lines
    filestr = automodapi.automodapi_replace(fr.read(), app, True, docname, False)
  File "/Users/seananderson/anaconda3/envs/opt/lib/python3.6/site-packages/sphinx_automodapi/automodapi.py", line 294, in automodapi_replace
    modnm, toskip, onlylocals=onlylocals)
  File "/Users/seananderson/anaconda3/envs/opt/lib/python3.6/site-packages/sphinx_automodapi/automodapi.py", line 405, in _mod_info
    for localnm, fqnm, obj in zip(*find_mod_objs(modname, onlylocals=onlylocals)):
  File "/Users/seananderson/anaconda3/envs/opt/lib/python3.6/site-packages/sphinx_automodapi/utils.py", line 99, in find_mod_objs
    fqnames.append(obj.__module__ + '.' + obj.__name__)
TypeError: must be str, not NoneType

To Reproduce Steps to reproduce the behavior:

Given a file:
### test.py
from flask import request

###

### Create a .rst file

===
Title
===

.. toctree::
   :maxdepth: 2
.. automodapi:: test

###

$ sphinx-build -b html . _build

Expected behavior The documentation is expected to build with a module level summary of the file (test.py would contain an instance of Test() for example)

Environment info