mozilla / sphinx-js

Autodoc-style extraction into Sphinx for your JS project
https://pypi.python.org/pypi/sphinx-js/
MIT License
282 stars 81 forks source link

unhandled case in typedoc processing #167

Open dealsumm opened 3 years ago

dealsumm commented 3 years ago

I'm trying to run sphinx-js on a react typesctipt project. running sphinx-build -v -b html -d _build/doctrees . _build/html I get the following exception traceback:

File "/usr/local/lib/python3.8/site-packages/sphinx/events.py", line 110, in emit
    results.append(listener.handler(self.app, *args))
  File "/usr/local/lib/python3.8/site-packages/sphinx_js/__init__.py", line 60, in analyze
    app._sphinxjs_analyzer = analyzer.from_disk(abs_source_paths,
  File "/usr/local/lib/python3.8/site-packages/sphinx_js/typedoc.py", line 40, in from_disk
    return cls(json, base_dir)
  File "/usr/local/lib/python3.8/site-packages/sphinx_js/typedoc.py", line 29, in __init__
    ir_objects = self._convert_all_nodes(json)
  File "/usr/local/lib/python3.8/site-packages/sphinx_js/typedoc.py", line 113, in _convert_all_nodes
    converted, more_todo = self._convert_node(todo.pop())
  File "/usr/local/lib/python3.8/site-packages/sphinx_js/typedoc.py", line 166, in _convert_node
    **self._top_level_properties(node))
  File "/usr/local/lib/python3.8/site-packages/sphinx_js/typedoc.py", line 65, in _top_level_properties
    source = node.get('sources')[0]
TypeError: 'NoneType' object is not subscriptable

I'm not sure if the cause is something I did incorrect or if it's a case that is not covered in the typedoc implementation.

erikrose commented 3 years ago

Don't worry; it's not your fault. However, I'd be curious if it works under TypeDoc 0.15.0, which is the latest version we've tested with.

nagmo commented 3 years ago

@erikrose thanks, I've tested it with typedoc version 0.15.0 and it has the same exact issue. do you have a suggestion for a quick fix until the issue is resolved?

erikrose commented 3 years ago

Unfortunately not. First of all, we shouldn't be saying node.get('sources')[0]; we might as well say node['sources'][0] and crash a little earlier. But that's a nitpick. This 'source' key is a vital thing, so there's no obvious way to paper over it. I wonder _top_level_properties is getting passed the wrong thing somehow. Can you reduce your code to the smallest bit that will trigger the error and share it?