[svn r38533] adding a way to modify the "apigen relative path"
from the command line, unifying conftest and confrest --HG-- branch : trunk
This commit is contained in:
parent
8c55dd3f35
commit
66b0639109
|
@ -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(
|
||||
|
|
|
@ -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,))
|
||||
|
||||
|
|
|
@ -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():
|
||||
|
|
Loading…
Reference in New Issue