ml-tooling / lazydocs

📖 Generate markdown API documentation from Google-style Python docstring. The lazy alternative to Sphinx.
MIT License
205 stars 38 forks source link

Doesn't find absolute imports to parts of a module when Python itself does #39

Closed marcelr-bk closed 1 year ago

marcelr-bk commented 2 years ago

Hello, I have a structure like this:

foo
`-- __init__.py
`-- common.py
`-- bar.py

where in bar.py I do import foo.common. When running lazydocs, I get the message Failed to generate docs for module foo.bar: AttributeError("module 'foo' has no attribute 'common'",)

However, when just starting a new Python shell and doing import foo.bar there are no complaints, so I'd expect it to work in Lazydocs as well.

Anything that I'm missing, or is this a bug?

thucngyyen commented 1 year ago

you probably need to add PYTHONPATH = path/to/module/

pauloburke commented 1 year ago

I'm also running into a similar issue when using the generate_docs function.

In my case, it can't find the module.

I'm using the following structure:

/my-repo --/src ---- /my-module ------ init.py ------ file1.py ------ file2.py (that imports file1.py by using "import my-module.file1 as file1")

and I'm running the generate_docs like this:

generate_docs( [ pathlib.Path("src/my-module/file1.py"), pathlib.Path("src/my-module/file2.py") ], ... )

pauloburke commented 1 year ago

Update: It worked by adding the "src" folder to python path using sys.path.append(os.path.join(os.getcwd(),"src"))

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 14 days