Merge lp:~jelmer/pydoctor/add-module-inspect into lp:~mwhudson/pydoctor/dev

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 568
Proposed branch: lp:~jelmer/pydoctor/add-module-inspect
Merge into: lp:~mwhudson/pydoctor/dev
Diff against target: 72 lines (+14/-12)
2 files modified
pydoctor/driver.py (+2/-2)
pydoctor/model.py (+12/-10)
To merge this branch: bzr merge lp:~jelmer/pydoctor/add-module-inspect
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Pending
Review via email: mp+43407@code.launchpad.net

Description of the change

Hi Michael,

This branch makes --add-module use the same function for loading modules as --add-package. This makes it possible to document top-level C modules with pydoctor.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Looks good, thanks.

I wonder if prependedpackage was ever useful to anyone at all...

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On Mon, 2010-12-13 at 11:47 +1300, Michael Hudson wrote:
> Looks good, thanks.
>
> I wonder if prependedpackage was ever useful to anyone at all...
I remember it being useful to document bzr plugins... I didn't
acidentally kill it, did I?

Cheers,

Jelmer

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

On Sun, 12 Dec 2010 23:58:13 +0100, Jelmer Vernooij <email address hidden> wrote:
> On Mon, 2010-12-13 at 11:47 +1300, Michael Hudson wrote:
> > Looks good, thanks.
> >
> > I wonder if prependedpackage was ever useful to anyone at all...
> I remember it being useful to document bzr plugins... I didn't
> acidentally kill it, did I?

I don't think so :-)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'pydoctor/driver.py'
2--- pydoctor/driver.py 2010-12-06 04:04:29 +0000
3+++ pydoctor/driver.py 2010-12-11 00:04:58 +0000
4@@ -317,8 +317,8 @@
5 system.msg('addPackage', 'adding directory ' + path)
6 system.addPackage(path, prependedpackage)
7 else:
8- system.msg('addModule', 'adding module ' + path)
9- system.addModule(path, prependedpackage)
10+ system.msg('addModuleFromPath', 'adding module ' + path)
11+ system.addModuleFromPath(prependedpackage, path)
12 system.packages.append(path)
13
14 # step 3: move the system to the desired state
15
16=== modified file 'pydoctor/model.py'
17--- pydoctor/model.py 2010-12-06 04:02:40 +0000
18+++ pydoctor/model.py 2010-12-11 00:04:58 +0000
19@@ -529,9 +529,7 @@
20
21 mod.sourceHref = posixpath.join(mod.system.sourcebase, *trailing)
22
23- def addModule(self, modpath, parentPackage=None):
24- fname = os.path.basename(modpath)
25- modname = os.path.splitext(fname)[0]
26+ def addModule(self, modpath, modname, parentPackage=None):
27 mod = self.Module(self, modname, None, parentPackage)
28 self.addObject(mod)
29 self.progress(
30@@ -582,7 +580,7 @@
31 self.addObject(c)
32 self._introspectThing(v, c, parentMod)
33
34- def introspectModule(self, module_full_name, py_mod):
35+ def introspectModule(self, py_mod, module_full_name):
36 module = self.ensureModule(module_full_name)
37 module.docstring = py_mod.__doc__
38 self._introspectThing(py_mod, module, module)
39@@ -611,23 +609,27 @@
40 if os.path.exists(initname):
41 self.addPackage(fullname, package)
42 elif not fname.startswith('.'):
43- self._addModuleFromPath(package, fullname)
44+ self.addModuleFromPath(package, fullname)
45
46- def _addModuleFromPath(self, package, path):
47+ def addModuleFromPath(self, package, path):
48 for (suffix, mode, type) in imp.get_suffixes():
49 if not path.endswith(suffix):
50 continue
51+ module_name = os.path.basename(path[:-len(suffix)])
52 if type == imp.C_EXTENSION:
53 if not self.options.introspect_c_modules:
54 continue
55- module_full_name = "%s.%s" % (
56- package.fullName(), os.path.basename(path[:-len(suffix)]))
57+ if package is not None:
58+ module_full_name = "%s.%s" % (
59+ package.fullName(), module_name)
60+ else:
61+ module_full_name = module_name
62 py_mod = imp.load_module(
63 module_full_name, open(path, 'rb'), path,
64 (suffix, mode, type))
65- self.introspectModule(module_full_name, py_mod)
66+ self.introspectModule(py_mod, module_full_name)
67 elif type == imp.PY_SOURCE:
68- self.addModule(path, package)
69+ self.addModule(path, module_name, package)
70 break
71
72 def handleDuplicate(self, obj):

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: