-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 19.10.2010 11:19, schrieb Vinay Sajip: > I have the following simple code structure: > > code/ > foo/ > __init__.py > from bar import baz > from bar.baz import Baz > bar/ > __init__.py > baz.py > class Baz(object): > "This is the Baz class". > pass > > The "code" directory is added to sys.path in conf.py. In my index.rst > I have: > > .. autoclass:: bar.baz.Baz > > .. autoclass:: foo.Baz > > .. autoclass:: foo.baz.Baz > > Now the first two of these work as expected, but the last one fails > with a "no module named baz" > error, even though foo.baz is the Python module bar.baz because of the > statement in foo/__init__.py which says "from bar import baz". > > If in conf.py I put the lines > > import foo > print bar.baz.Baz > print foo.Baz > print foo.baz.Baz > > then I get <class 'bar.baz.Baz'> printed thrice, as expected.
But you can't do import foo.baz which is basically what Sphinx is trying to do. > The reason I want to do this is, that foo's use of bar is effectively > an implementation detail. I want to represent bar.baz as foo.baz, > which I can't, though I can represent bar.baz.Baz as foo.Baz! > Obviously there are workarounds, but why should they be needed? I'm not sure how to "fix" this. Even if you could get Sphinx to import the contents of baz via foo, the __module__ attribute of classes and functions would be wrong, and therefore these wouldn't be documented if you don't give them explicitly as members. Maybe the solution would be a way to register "module aliases", to say "this module should be known as that module". cheers, Georg -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) iEYEARECAAYFAk0o67cACgkQN9GcIYhpnLAn+wCdEureNZQBYV5OehhxwZ/wX4ks XyQAoIs5H69xGcJ8SOorvR7aaNt050q3 =SUKm -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "sphinx-dev" group. To post to this group, send email to sphinx-...@googlegroups.com. To unsubscribe from this group, send email to sphinx-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sphinx-dev?hl=en.