NiklasRosenstein / pydoc-markdown

Create Python API documentation in Markdown format.
http://niklasrosenstein.github.io/pydoc-markdown/
Other
462 stars 105 forks source link

Bad import from 'nr.types' #89

Closed wibimaster closed 5 years ago

wibimaster commented 5 years ago

Hi,

I just installed the @develop version (because main release does not work with my project)

When I try to do a pydoc-markdown --modules debug --search-path src/ > docs.md (debug is my module), I got this error :

Traceback (most recent call last): File "/usr/local/bin/pydoc-markdown", line 6, in from pydoc_markdown.main import _entry_point File "/usr/local/lib/python3.7/site-packages/pydoc_markdown/main.py", line 30, in from nr.types import record ImportError: cannot import name 'record' from 'nr.types' (/usr/local/lib/python3.7/site-packages/nr/types/init.py)

I searched on nr.types : https://pypi.org/project/nr.types/ And I cannot find nr.types.record

I'm working with Python 3.7, is this the reason of this fail ?

Thanks !

NiklasRosenstein commented 5 years ago

Hey @wibimaster ,

sorry for the troubles. Can you try to run this command and then run pydoc-markdown again?

$ pip install 'nr.types==2.3.0'

I recently released nr.types 3.x but the Pydoc-Markdown setup.py does not specify a max-version

wibimaster commented 5 years ago

I tried, now I got another error message :

$ pip freeze | grep nr.types nr.types==2.3.0

$ pydoc-markdown --modules debug --search-path src/ > docs.md Traceback (most recent call last): File "/usr/local/bin/pydoc-markdown", line 6, in from pydoc_markdown.main import _entry_point File "/usr/local/lib/python3.7/site-packages/pydoc_markdown/main.py", line 31, in from nr.types.structured import Field, Object, WildcardField, extract ModuleNotFoundError: No module named 'nr.types.structured'

NiklasRosenstein commented 5 years ago

I actually forgot to bump the version in setup.py, so 2.3.0 is actually too low.

Also the nr.types.record import is a leftover. I've removed it in the last commit. Please pull and install the newest version of nr.types again. 😄

NiklasRosenstein commented 5 years ago

Actually hold on for a few minutes.

NiklasRosenstein commented 5 years ago

Ok now it should work. :D

wibimaster commented 5 years ago

Thank you ! I'm not working at the moment, but I try as soon as possible :)

NiklasRosenstein commented 5 years ago

Ack! Please let me know if you have any issues. I'm not super-actively working on it right now, but I want to pick it up again soon.

wibimaster commented 5 years ago

$ pip install -U git+https://github.com/NiklasRosenstein/pydoc-markdown.git@develop [...]

$ pip freeze | grep nr.types nr.types==3.1.0

$ pydoc-markdown --modules debug --search-path src/ > docs.md Traceback (most recent call last): File "/usr/local/bin/pydoc-markdown", line 10, in sys.exit(_entry_point()) File "/usr/local/lib/python3.7/site-packages/pydoc_markdown/main.py", line 122, in _entry_point = lambda: sys.exit(main()) File "/usr/local/lib/python3.7/site-packages/pydoc_markdown/main.py", line 117, in main pydocmd.load_module_graph() File "/usr/local/lib/python3.7/site-packages/pydoc_markdown/main.py", line 74, in load_module_graph loader.load(loader.config, self.graph) File "/usr/local/lib/python3.7/site-packages/pydoc_markdown/contrib/loaders/python.py", line 495, in load module = parse_file(None, filename, module_name) File "/usr/local/lib/python3.7/site-packages/pydoc_markdown/contrib/loaders/python.py", line 77, in parse_file return Parser().parse(parse_to_ast(code, filename), filename, module_name) File "/usr/local/lib/python3.7/site-packages/pydoc_markdown/contrib/loaders/python.py", line 101, in parse self.parse_declaration(module, node) File "/usr/local/lib/python3.7/site-packages/pydoc_markdown/contrib/loaders/python.py", line 121, in parse_declaration return self.parse_funcdef(parent, child, True, decorators) File "/usr/local/lib/python3.7/site-packages/pydoc_markdown/contrib/loaders/python.py", line 170, in parse_funcdef args = self.parse_parameters(parameters) File "/usr/local/lib/python3.7/site-packages/pydoc_markdown/contrib/loaders/python.py", line 222, in parse_parameters result.append(consume_arg(node, argtype, index)) File "/usr/local/lib/python3.7/site-packages/pydoc_markdown/contrib/loaders/python.py", line 191, in consume_arg name = node.value AttributeError: 'Node' object has no attribute 'value'

NiklasRosenstein commented 5 years ago

Interesting, consume_arg() expects a lib2to3.pytree.Leaf object, not a Node object. Could you share what code you are trying to generate docs for? That would help me debug this. It's probably a case of the syntax structure in function defs that I didn't consider

NiklasRosenstein commented 5 years ago

Btw. I added an assertion in cbbc9cd1cda8de63dbf0b341f5ab36cb463be703 which should tell you at which line in your Python source code this fails.

wibimaster commented 5 years ago

Hmm yep, now it fails with an assertion ;) But I'm not sure it helps me... It points on this line of my code :

def run_ml_server(project_name: str, project_type: ProjectType, port: int) -> bool:

Does your project fail on typing ?

NiklasRosenstein commented 5 years ago

It should not fail with typing. Can you try again now? It should be fixed :)

NiklasRosenstein commented 5 years ago

Hey! I'll close this for now as, for as far as I can tell, it is now working as expected. Thanks for reporting it! 😃