[py-svn] r38650 - in py/trunk/py: apigen bin
guido at codespeak.net
guido at codespeak.net
Tue Feb 13 00:14:51 CET 2007
Author: guido
Date: Tue Feb 13 00:14:50 2007
New Revision: 38650
Added:
py/trunk/py/bin/_docgen.py (contents, props changed)
Modified:
py/trunk/py/apigen/layout.py
Log:
Added env var for creating relative links to the py lib docs (in the nav bar),
added script to generate py lib's docs and api docs in a subdir in one go.
Modified: py/trunk/py/apigen/layout.py
==============================================================================
--- py/trunk/py/apigen/layout.py (original)
+++ py/trunk/py/apigen/layout.py Tue Feb 13 00:14:50 2007
@@ -31,12 +31,15 @@
self.body.insert(0, self.nav)
def update_menubar_links(self, node):
+ docrelpath = py.std.os.environ.get('APIGEN_DOCRELPATH', '../py/doc')
+ if not docrelpath.endswith('/'):
+ docrelpath += '/'
for item in node:
if not isinstance(item, py.xml.Tag):
continue
if (item.__class__.__name__ == 'a' and hasattr(item.attr, 'href')
and not item.attr.href.startswith('http://')):
- item.attr.href = self.relpath + '../py/doc/' + item.attr.href
+ item.attr.href = self.relpath + docrelpath + item.attr.href
def setup_scripts_styles(self, copyto=None):
for path, name in self.stylesheets:
Added: py/trunk/py/bin/_docgen.py
==============================================================================
--- (empty file)
+++ py/trunk/py/bin/_docgen.py Tue Feb 13 00:14:50 2007
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+
+""" quick tool to get documentation + apigen docs generated
+
+ given a certain targetpath, apigen docs will be placed in 'apigen',
+
+ user can choose to only build either docs or apigen docs: in this case,
+ the navigation bar will be adjusted
+"""
+
+from _findpy import py
+import py
+pypath = py.__package__.getpath()
+
+def run_tests(path, envvars='', args=''):
+ pytestpath = pypath.join('bin/py.test')
+ cmd = ('PYTHONPATH="%s" %s python "%s" %s "%s"' %
+ (pypath.dirpath(), envvars, pytestpath, args, path))
+ print cmd
+ py.process.cmdexec(cmd)
+
+def build_apigen_docs(targetpath, testargs=''):
+ run_tests(pypath,
+ 'APIGEN_TARGET="%s/apigen" APIGEN_DOCRELPATH="../doc/"' % (
+ targetpath,),
+ testargs + ' --apigen="%s/apigen/apigen.py"' % (pypath,))
+
+def build_docs(targetpath, testargs):
+ docpath = pypath.join('doc')
+ run_tests(docpath, '',
+ testargs + ' --forcegen --apigenrelpath="../apigen/"')
+ topath = targetpath.ensure('doc', dir=True)
+ docpath.copy(topath)
+
+def build_nav(targetpath, docs=True, api=True):
+ pass
+
+def build(targetpath, docs=True, api=True, testargs=''):
+ targetpath.ensure(dir=True)
+ if docs:
+ print 'building docs'
+ build_docs(targetpath, testargs)
+ if api:
+ print 'building api'
+ build_apigen_docs(targetpath, testargs)
+
+if __name__ == '__main__':
+ import sys
+ if len(sys.argv) == 1:
+ print 'usage: %s <targetdir> [options]'
+ print
+ print ' targetdir: a path to a directory (created if it doesn\'t'
+ print ' exist) where the docs are put'
+ print ' options: options passed to py.test when running the tests'
+ sys.exit(1)
+ targetpath = py.path.local(sys.argv[1])
+ args = ' '.join(sys.argv[2:])
+ build(targetpath, True, True, args)
+
More information about the pytest-commit
mailing list