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
=== modified file 'pydoctor/driver.py'
--- pydoctor/driver.py 2010-12-06 04:04:29 +0000
+++ pydoctor/driver.py 2010-12-11 00:04:58 +0000
@@ -317,8 +317,8 @@
317 system.msg('addPackage', 'adding directory ' + path)317 system.msg('addPackage', 'adding directory ' + path)
318 system.addPackage(path, prependedpackage)318 system.addPackage(path, prependedpackage)
319 else:319 else:
320 system.msg('addModule', 'adding module ' + path)320 system.msg('addModuleFromPath', 'adding module ' + path)
321 system.addModule(path, prependedpackage)321 system.addModuleFromPath(prependedpackage, path)
322 system.packages.append(path)322 system.packages.append(path)
323323
324 # step 3: move the system to the desired state324 # step 3: move the system to the desired state
325325
=== modified file 'pydoctor/model.py'
--- pydoctor/model.py 2010-12-06 04:02:40 +0000
+++ pydoctor/model.py 2010-12-11 00:04:58 +0000
@@ -529,9 +529,7 @@
529529
530 mod.sourceHref = posixpath.join(mod.system.sourcebase, *trailing)530 mod.sourceHref = posixpath.join(mod.system.sourcebase, *trailing)
531531
532 def addModule(self, modpath, parentPackage=None):532 def addModule(self, modpath, modname, parentPackage=None):
533 fname = os.path.basename(modpath)
534 modname = os.path.splitext(fname)[0]
535 mod = self.Module(self, modname, None, parentPackage)533 mod = self.Module(self, modname, None, parentPackage)
536 self.addObject(mod)534 self.addObject(mod)
537 self.progress(535 self.progress(
@@ -582,7 +580,7 @@
582 self.addObject(c)580 self.addObject(c)
583 self._introspectThing(v, c, parentMod)581 self._introspectThing(v, c, parentMod)
584582
585 def introspectModule(self, module_full_name, py_mod):583 def introspectModule(self, py_mod, module_full_name):
586 module = self.ensureModule(module_full_name)584 module = self.ensureModule(module_full_name)
587 module.docstring = py_mod.__doc__585 module.docstring = py_mod.__doc__
588 self._introspectThing(py_mod, module, module)586 self._introspectThing(py_mod, module, module)
@@ -611,23 +609,27 @@
611 if os.path.exists(initname):609 if os.path.exists(initname):
612 self.addPackage(fullname, package)610 self.addPackage(fullname, package)
613 elif not fname.startswith('.'):611 elif not fname.startswith('.'):
614 self._addModuleFromPath(package, fullname)612 self.addModuleFromPath(package, fullname)
615613
616 def _addModuleFromPath(self, package, path):614 def addModuleFromPath(self, package, path):
617 for (suffix, mode, type) in imp.get_suffixes():615 for (suffix, mode, type) in imp.get_suffixes():
618 if not path.endswith(suffix):616 if not path.endswith(suffix):
619 continue617 continue
618 module_name = os.path.basename(path[:-len(suffix)])
620 if type == imp.C_EXTENSION:619 if type == imp.C_EXTENSION:
621 if not self.options.introspect_c_modules:620 if not self.options.introspect_c_modules:
622 continue621 continue
623 module_full_name = "%s.%s" % (622 if package is not None:
624 package.fullName(), os.path.basename(path[:-len(suffix)]))623 module_full_name = "%s.%s" % (
624 package.fullName(), module_name)
625 else:
626 module_full_name = module_name
625 py_mod = imp.load_module(627 py_mod = imp.load_module(
626 module_full_name, open(path, 'rb'), path,628 module_full_name, open(path, 'rb'), path,
627 (suffix, mode, type))629 (suffix, mode, type))
628 self.introspectModule(module_full_name, py_mod)630 self.introspectModule(py_mod, module_full_name)
629 elif type == imp.PY_SOURCE:631 elif type == imp.PY_SOURCE:
630 self.addModule(path, package)632 self.addModule(path, module_name, package)
631 break633 break
632634
633 def handleDuplicate(self, obj):635 def handleDuplicate(self, obj):

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: