سؤال

I have a package structured like this:

a/a1/a1.py

a/a2/a2.py

a/a3/a3.py

In a3.py, I imported modules a1 and a2 like these:

import a1.a1
import a2.a2

Then I run

pydoc -w a/

It produces a.html, a.a1.html, a.a1.a1.html, a.a2.html, a.a2.a2.html, a.a3.html, a.a3.a3.html. The problem with a3 is, the links of the imports, i.e., a1.a1 and a2.a2 are a1.a1.html and a2.a2.html. They are supposed to be a.a1.a1.html and a.a2.a2.html. Anyone has any suggestions on how to fix it? Thanks

[Update]. I now change the imports in a3.py to:

import a.a1.a1
import a.a2.a2

The generated a.a3.a3.html has only one link to a as a.html. I still want links to a1.a1 and a2.a2. Any suggestions?

هل كانت مفيدة؟

المحلول

Well, you could:

  • Change into the a/ directory, then run pydoc on your directories separately
  • Be strict with your import structure, as Python 3 forces you to (i.e. import a.a1.a1 or from ..a1 import a1)
  • Use a newer way to make HTML documentation, like Sphinx (there is some learning curve, though).
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top