[py-svn] r36477 - in py/dist/py/apigen: . source source/testing testing

guido at codespeak.net guido at codespeak.net
Thu Jan 11 14:00:30 CET 2007


Author: guido
Date: Thu Jan 11 14:00:28 2007
New Revision: 36477

Added:
   py/dist/py/apigen/linker.py
      - copied unchanged from r36476, py/dist/py/apigen/source/linker.py
   py/dist/py/apigen/testing/
   py/dist/py/apigen/testing/__init__.py
   py/dist/py/apigen/testing/test_linker.py
      - copied unchanged from r36476, py/dist/py/apigen/source/testing/test_linker.py
Removed:
   py/dist/py/apigen/source/linker.py
   py/dist/py/apigen/source/testing/test_linker.py
Log:
(hpk, guido) Moved the linker to the apigen dir


Deleted: /py/dist/py/apigen/source/linker.py
==============================================================================
--- /py/dist/py/apigen/source/linker.py	Thu Jan 11 14:00:28 2007
+++ (empty file)
@@ -1,36 +0,0 @@
-import py
-html = py.xml.html
-
-def getrelfspath(dotted_name):
-    # XXX need to make sure its imported on non-py lib 
-    return eval(dotted_name, {"py": py})
-
-class LazyHref(object):
-    def __init__(self, linker, linkid):
-        self._linker = linker
-        self._linkid = linkid
-
-    def __unicode__(self):
-        return unicode(self._linker.get_target(self._linkid))
-
-class Linker(object):
-    def __init__(self):
-        self.root = None
-        self._linkid2target = {}
-
-    def set_root(self, root):
-        assert self.root is None
-        self.root = root
-
-    def repr_link(self, linkid, linkcontent=None):
-        if linkcontent is None:
-            linkcontent = linkid
-        return html.a(linkcontent, href=LazyHref(self, linkid))
-
-    def set_link(self, linkid, target):
-        assert linkid not in self._linkid2target
-        self._linkid2target[linkid] = target
-
-    def get_target(self, linkid):
-        return '%s/%s' % (self.root, self._linkid2target[linkid])
-    

Deleted: /py/dist/py/apigen/source/testing/test_linker.py
==============================================================================
--- /py/dist/py/apigen/source/testing/test_linker.py	Thu Jan 11 14:00:28 2007
+++ (empty file)
@@ -1,75 +0,0 @@
-import py
-html = py.xml.html
-from py.__.apigen.source.linker import Linker, getrelfspath
-
-class TestLinker(object):
-    def test_one_lazy_link(self):
-        linker = Linker()
-        linker.set_root('/root')
-        tag = linker.repr_link('py.path.local')
-        linker.set_link('py.path.local', 'py/path/local.html')
-        resolved = tag.unicode()
-        assert (resolved ==
-                '<a href="/root/py/path/local.html">py.path.local</a>')
-    
-    def test_lazy_link_different_text(self):
-        linker = Linker()
-        linker.set_root('/root')
-        content = html.em('foo')
-        tag = linker.repr_link('py.path.local', content)
-        linker.set_link('py.path.local', 'py/path/local.html')
-        resolved = tag.unicode(indent=0)
-        assert (resolved ==
-                '<a href="/root/py/path/local.html"><em>foo</em></a>')
-
-    def test_source_link_getrelfspath(self):
-        linker = Linker()
-        linker.set_root('/root')
-
-        relfspath = getrelfspath('py.path.local')
-        tag = linker.repr_link(relfspath, "sourcelink")
-        linker.set_link(relfspath, "hello/world")
-        resolved = tag.unicode(indent=0)
-        assert (resolved ==
-                '<a href="/root/hello/world">sourcelink</a>')
-
-# considerations for futurue use
-"""
-snippet = create_method_html('foo.bar', dsa, linker)
-snippet.unicode() # links get resolved here?
-
-def create_method_html(dotted_name, dsa, linker):
-    ...
-    # <a href="<linker.root>/py/path/local.html#py.path.local.dirpath">
-    a = linker.make_source_link(dotted_name)
-    ...
-
-def create_source_code_view(srcpath, linker):
-    ...
-    # <a name="py.path.local.dirpath"></a>dirpath()
-    anchor = linker.provide_anchor(dotted_name)
-
-def convert_srcpath_to_htmlpath(srcpath):
-    return 'source/%s.html' % (srcpath,)
-
-def write_sources(root, linker):
-    for fpath in root.visit(fil='*.py'):
-        relpath = fpath.relto(root)
-        htmlpath = convert_srcpath_to_htmlpath(relpath)
-        linker.set_link(relpath, htmlpath)
-        gen_source_code_view(relpath, htmlpath)
-        
-  
-Linker: 
-def make_source_link(self, dotted_name):
-    relpath = py.path.local(inspect.getfile(dottedname).... 
-    anchor = linker.get_anchor_name(dotted_name)
-    #html.a(text, href=<relpath>#anchor)
-    ... upon resolving time ... 
-    linkref = linker.get_html_relpath(relpath)
-    linkref += "#" + anchor 
-
-def _make_anchored_link(self, relpath, anchor, text):
-    #html.a(text, href=<relpath>#anchor)
-
-"""

Added: py/dist/py/apigen/testing/__init__.py
==============================================================================



More information about the pytest-commit mailing list