From 66b0639109381e6f7a3e2f0a2b714f8c1fdc1b6d Mon Sep 17 00:00:00 2001 From: hpk Date: Mon, 12 Feb 2007 01:37:48 +0100 Subject: [PATCH] [svn r38533] adding a way to modify the "apigen relative path" from the command line, unifying conftest and confrest --HG-- branch : trunk --- py/doc/confrest.py | 8 +++++--- py/doc/conftest.py | 15 ++++++++++++--- py/doc/test_conftest.py | 14 ++++++++------ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/py/doc/confrest.py b/py/doc/confrest.py index 94fb8b9ab..d79e3706c 100644 --- a/py/doc/confrest.py +++ b/py/doc/confrest.py @@ -1,6 +1,7 @@ import py from py.__.misc.rest import convert_rest_html, strip_html_header from py.__.misc.difftime import worded_time +from py.__.doc.conftest import get_apigen_relpath mydir = py.magic.autopath().dirpath() html = py.xml.html @@ -22,6 +23,7 @@ class Page(object): self.fill() def fill(self): + apigen_relpath = get_apigen_relpath() content_type = "%s;charset=%s" %(self.type, self.encoding) self.head.append(html.title(self.title)) self.head.append(html.meta(name="Content-Type", content=content_type)) @@ -33,12 +35,12 @@ class Page(object): self.menubar = html.div( html.a("home", href="home.html", class_="menu"), " ", html.a("doc", href="index.html", class_="menu"), " ", - html.a("api", href="../../apigen/api/index.html", class_="menu"), + html.a("api", href=apigen_relpath + "api/index.html", class_="menu"), " ", - html.a("source", href="../../apigen/source/index.html", + html.a("source", href=apigen_relpath + "source/index.html", class_="menu"), " ", html.a("contact", href="contact.html", class_="menu"), " ", - html.a("getting-started", href="getting-started.html", class_="menu"), " ", + html.a("download", href="download.html", class_="menu"), " ", id="menubar", ) self.metaspace = html.div( diff --git a/py/doc/conftest.py b/py/doc/conftest.py index d03363dc4..aa7da3c62 100644 --- a/py/doc/conftest.py +++ b/py/doc/conftest.py @@ -11,9 +11,17 @@ option = py.test.config.addoptions("documentation check options", Option('', '--forcegen', action="store_true", dest="forcegen", default=False, help="force generation of html files even if they appear up-to-date" + ), + Option('', '--apigenrelpath', + action="store", dest="apigen_relpath", default="../../apigen", + type="string", + help="force generation of html files even if they appear up-to-date" ) ) +def get_apigen_relpath(): + return py.test.config.option.apigen_relpath + "/" + def deindent(s, sep='\n'): leastspaces = -1 lines = s.split(sep) @@ -254,9 +262,10 @@ class DocDirectory(py.test.collect.Directory): Directory = DocDirectory def resolve_linkrole(name, text, check=True): + apigen_relpath = get_apigen_relpath() if name == 'api': if text == 'py': - return ('py', '../../apigen/api/index.html') + return ('py', apigen_relpath + 'api/index.html') else: assert text.startswith('py.'), ( 'api link "%s" does not point to the py package') % (text,) @@ -275,7 +284,7 @@ def resolve_linkrole(name, text, check=True): raise AssertionError( 'problem with linkrole :api:`%s`: can not resolve ' 'dotted name %s' % (text, dotted_name,)) - return (text, '../../apigen/api/%s.html' % (dotted_name,)) + return (text, apigen_relpath + 'api/%s.html' % (dotted_name,)) elif name == 'source': assert text.startswith('py/'), ('source link "%s" does not point ' 'to the py package') % (text,) @@ -290,5 +299,5 @@ def resolve_linkrole(name, text, check=True): relpath += 'index.html' else: relpath += '.html' - return (text, '../../apigen/source/%s' % (relpath,)) + return (text, apigen_relpath + 'source/%s' % (relpath,)) diff --git a/py/doc/test_conftest.py b/py/doc/test_conftest.py index 52a3646de..6eee97293 100644 --- a/py/doc/test_conftest.py +++ b/py/doc/test_conftest.py @@ -110,20 +110,22 @@ def test_js_ignore(): assert len(l+l2) == 3 def test_resolve_linkrole(): + from py.__.doc.conftest import get_apigen_relpath + apigen_relpath = get_apigen_relpath() from py.__.doc.conftest import resolve_linkrole assert resolve_linkrole('api', 'py.foo.bar', False) == ( - 'py.foo.bar', '../../apigen/api/foo.bar.html') + 'py.foo.bar', apigen_relpath + 'api/foo.bar.html') assert resolve_linkrole('api', 'py.foo.bar()', False) == ( - 'py.foo.bar()', '../../apigen/api/foo.bar.html') + 'py.foo.bar()', apigen_relpath + 'api/foo.bar.html') assert resolve_linkrole('api', 'py', False) == ( - 'py', '../../apigen/api/index.html') + 'py', apigen_relpath + 'api/index.html') py.test.raises(AssertionError, 'resolve_linkrole("api", "foo.bar")') assert resolve_linkrole('source', 'py/foo/bar.py', False) == ( - 'py/foo/bar.py', '../../apigen/source/foo/bar.py.html') + 'py/foo/bar.py', apigen_relpath + 'source/foo/bar.py.html') assert resolve_linkrole('source', 'py/foo/', False) == ( - 'py/foo/', '../../apigen/source/foo/index.html') + 'py/foo/', apigen_relpath + 'source/foo/index.html') assert resolve_linkrole('source', 'py/', False) == ( - 'py/', '../../apigen/source/index.html') + 'py/', apigen_relpath + 'source/index.html') py.test.raises(AssertionError, 'resolve_linkrole("source", "/foo/bar/")') def test_resolve_linkrole_check_api():