[py-svn] r38533 - py/trunk/py/doc

hpk at codespeak.net hpk at codespeak.net
Mon Feb 12 01:37:49 CET 2007


Author: hpk
Date: Mon Feb 12 01:37:48 2007
New Revision: 38533

Modified:
   py/trunk/py/doc/confrest.py
   py/trunk/py/doc/conftest.py
   py/trunk/py/doc/test_conftest.py
Log:
adding a way to modify the "apigen relative path"
from the command line, unifying conftest and confrest


Modified: py/trunk/py/doc/confrest.py
==============================================================================
--- py/trunk/py/doc/confrest.py	(original)
+++ py/trunk/py/doc/confrest.py	Mon Feb 12 01:37:48 2007
@@ -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 @@
         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 @@
         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(

Modified: py/trunk/py/doc/conftest.py
==============================================================================
--- py/trunk/py/doc/conftest.py	(original)
+++ py/trunk/py/doc/conftest.py	Mon Feb 12 01:37:48 2007
@@ -11,9 +11,17 @@
         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 @@
 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 @@
                         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 @@
             relpath += 'index.html'
         else:
             relpath += '.html'
-        return (text, '../../apigen/source/%s' % (relpath,))
+        return (text, apigen_relpath + 'source/%s' % (relpath,))
 

Modified: py/trunk/py/doc/test_conftest.py
==============================================================================
--- py/trunk/py/doc/test_conftest.py	(original)
+++ py/trunk/py/doc/test_conftest.py	Mon Feb 12 01:37:48 2007
@@ -110,20 +110,22 @@
     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():



More information about the pytest-commit mailing list