Maria
Maria

Reputation: 31

pdoc can't import the function from other module

i'm using python 2.7 and trying to gather documentation for our testing project using pdoc.

pdoc is located here: D:\dev\Python27\Scripts the regression project here: C:\views\md_LDB_RegressionTests_v03.1_laptop\mts\Tests\LDB\Regression\Tests We are using proboscis for our tests and i'm trying to create html documentation for the separate group of tests, a separate python file in my case. I run such command:

D:\dev\Python27\Scripts>python pdoc --html "C:\views\md_LDB_RegressionTests_v03.
1_laptop\mts\Tests\LDB\Regression\Tests\tests\check_system_management\check_capa
bilities_encoding_problems.py"

and get such answer:

Traceback (most recent call last):
  File "pdoc", line 458, in <module>
    module = imp.load_source('__pdoc_file_module__', fp, f)
  File "C:\views\md_LDB_RegressionTests_v03.1_laptop\mts\Tests\LDB\Regression\Te
sts\tests\check_system_management\check_capabilities_encoding_problems.py", line
 4, in <module>
    from common.builders.system_request import default_create_system, create_cap
ability
ImportError: No module named common.builders.system_request

pdoc can't import the function from other modules in our regression... The structure of our project looks like this:

-Tests (C:\views\md_LDB_RegressionTests_v03.1_laptop\mts\Tests\LDB\Regression\Tests)
  -"common" package (with init file)
     -"builders" packege
        -system_request.py
  -"test" package
      -check_system_management package
         -check_capabilities_encoding_problems.py - this is the file i want to get documentation to

Of course there are lots of other packages but im not sure if it makes sense to describe all the structure now

The import part of the check_capabilities_encoding_problems.py looks like this:

import urllib
from hamcrest import assert_that, all_of
from proboscis import test, before_class, after_class
from common.builders.system_request import default_create_system, create_capability
from common.entity.LDBChecks import LDBChecks

How can i point to pdoc where to look for the functions of other modules? thank you!

Upvotes: 3

Views: 7240

Answers (3)

Premysl Vorac
Premysl Vorac

Reputation: 473

When using pdoc with my Spyder IDE, I use the following script to add a directory to pdoc path

import pdoc
libpath = r'C:\Path\To\Module'
pdoc.import_path.append(libpath)
mod = pdoc.import_module('ModuleName')
doc = pdoc.Module(mod)
string = doc.html()

The pdoc.import_path is a list of currently used paths to look for your module; pdoc.import_path equals sys.path in default. More info can be found in pdoc documentation.

Upvotes: 1

Gilco
Gilco

Reputation: 1336

pydoc and pdoc read your code!!!

if you will run it from the same directory pdoc3 --html . or pydoc -w . it should work if all the modules are in the same directory. but if they are not:

make sure your main module in each directory has it sys full path append to it (to the same directory).

sys.path.append("D:/Coding/project/....)

Relative path will not do the trick!

Upvotes: 0

You can set PYTHONPATH env variable. This is a path that say python where to find modules and packages by 3th party also you.

Upvotes: 1

Related Questions