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

Dodging Ambiguity With Pathnames Not Working #133

Closed Plaskowitz closed 4 years ago

Plaskowitz commented 4 years ago

Hello,

I am currently documenting my Django Project. But I have a problem with ambiguous functionnames that occur in different JavaScript files. I tried using the Pathname to solve this:

.. js:autofunction:: ./tt_timeout/static/tt_timeout/js/on_page_load.readyFunc

But when doing so I get this error:

Exception occurred: File "C:\Users\username\AppData\Roaming\Python\Python37\site-packages\six.py", line 581, in iterkeys return iter(d.keys(**kw)) AttributeError: 'Value' object has no attribute 'keys'.

Full Traceback:

 # Sphinx version: 2.4.0
# Python version: 3.7.0 (CPython)
# Docutils version: 0.16 release
# Jinja2 version: 2.11.1
# Last messages:
#   reading sources... [ 47%] apps/welcome_page/welcome_page_index
#   
#   reading sources... [ 52%] apps/tt_timeout/tt_timeout_index
#   
#   reading sources... [ 58%] apps/welcome_page/backend/backend
#   
#   reading sources... [ 64%] apps/welcome_page/backend/views
#   
#   reading sources... [ 70%] apps/tt_timeout/frontend/on_page_load
#   
# Loaded extensions:
#   sphinx.ext.mathjax (2.4.0) from C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\ext\mathjax.py
#   sphinxcontrib.applehelp (1.0.1) from C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinxcontrib\applehelp\__init__.py
#   sphinxcontrib.devhelp (1.0.1) from C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinxcontrib\devhelp\__init__.py
#   sphinxcontrib.htmlhelp (1.0.2) from C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinxcontrib\htmlhelp\__init__.py
#   sphinxcontrib.serializinghtml (1.1.3) from C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinxcontrib\serializinghtml\__init__.py
#   sphinxcontrib.qthelp (1.0.2) from C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinxcontrib\qthelp\__init__.py
#   alabaster (0.7.12) from C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\alabaster\__init__.py
#   sphinx.ext.autodoc.type_comment (2.4.0) from C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\ext\autodoc\type_comment.py
#   sphinx.ext.autodoc (2.4.0) from C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\ext\autodoc\__init__.py
#   sphinx_js (unknown version) from C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx_js\__init__.py
Traceback (most recent call last):
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\cmd\build.py", line 276, in build_main
    app.build(args.force_all, filenames)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\application.py", line 349, in build
    self.builder.build_update()
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\builders\__init__.py", line 299, in build_update
    len(to_build))
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\builders\__init__.py", line 311, in build
    updated_docnames = set(self.read())
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\builders\__init__.py", line 418, in read
    self._read_serial(docnames)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\builders\__init__.py", line 439, in _read_serial
    self.read_doc(docname)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\builders\__init__.py", line 479, in read_doc
    doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\io.py", line 316, in read_doc
    pub.publish()
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\core.py", line 218, in publish
    self.settings)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\io.py", line 130, in read
    self.parse()
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\readers\__init__.py", line 77, in parse
    self.parser.parse(self.input, document)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\parsers.py", line 93, in parse
    self.statemachine.run(inputlines, document, inliner=self.inliner)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\parsers\rst\states.py", line 171, in run
    input_source=document['source'])
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\statemachine.py", line 242, in run
    context, state, transitions)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\parsers\rst\states.py", line 2769, in underline
    self.section(title, source, style, lineno - 1, messages)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\parsers\rst\states.py", line 327, in section
    self.new_subsection(title, lineno, messages)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\parsers\rst\states.py", line 395, in new_subsection
    node=section_node, match_titles=True)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\parsers\rst\states.py", line 282, in nested_parse
    node=node, match_titles=match_titles)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\parsers\rst\states.py", line 196, in run
    results = StateMachineWS.run(self, input_lines, input_offset)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\statemachine.py", line 242, in run
    context, state, transitions)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\statemachine.py", line 459, in check_line
    return method(match, context, next_state)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\parsers\rst\states.py", line 2342, in explicit_markup
    nodelist, blank_finish = self.explicit_construct(match)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\parsers\rst\states.py", line 2354, in explicit_construct
    return method(self, expmatch)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\parsers\rst\states.py", line 2097, in directive
    directive_class, match, type_name, option_presets)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\docutils\parsers\rst\states.py", line 2146, in run_directive
    result = directive_instance.run()
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx\domains\__init__.py", line 265, in run
    return super().run()
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx_js\directives.py", line 38, in run
    return AutoFunctionRenderer.from_directive(self, app).rst_nodes()
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx_js\renderers.py", line 69, in rst_nodes
    doclet, full_path = self._app._sphinxjs_doclets_by_path.get_with_path(self._partial_path)
  File "C:\Users\username\AppData\Local\conda\conda\envs\py37_32\lib\site-packages\sphinx_js\suffix_tree.py", line 48, in get_with_path
    key = next(iterkeys(tree))
  File "C:\Users\username\AppData\Roaming\Python\Python37\site-packages\six.py", line 581, in iterkeys
    return iter(d.keys(**kw))
AttributeError: 'Value' object has no attribute 'keys' 

Does anybody know what I am doing wrong, or where the problem lies? Thanks for your help! Much appreciated!

erikrose commented 4 years ago

I think you may have found a reproduction of #95, which I was looking for in order to merge it! Can you perchance reduce your code to a minimal case that reproduces this bug? If so, I will merge the fix ASAP.

Plaskowitz commented 4 years ago

Hello,

Not sure how you want my reduced code but here is a zipped version: sphinx-js_issue#133.zip

When i run make html the error occurs. (Still on the same versions as in the Traceback above)

Note: When I delete line 13 in the index.rst the error changes into: No JSDoc documentation was found for object "./subfolder/test.testFunction" or any path ending with that. Suggesting that I might still do something wrong here...

erikrose commented 4 years ago

Perfect; thank you. I will take a look.

erikrose commented 4 years ago

Your reproduction works great. I will distill it to a test, and then it's off to the races. Thank you!

erikrose commented 4 years ago

Fixed in ed4df1de93238afc09240222ce48d0f16f21af66! Thanks so much for the reproduction; that made all the difference. In fact, while I was in there, I found another problem with the suffix tree. I'll fix that one, too. Thanks again!