Example #1
0
def restcheck(path):
    localpath = path
    if hasattr(path, 'localpath'):
        localpath = path.localpath
    checkdocutils() 
    import docutils.utils

    try: 
        cur = localpath
        for x in cur.parts(reverse=True):
            confrest = x.dirpath('confrest.py')
            if confrest.check(file=1): 
                confrest = confrest.pyimport()
                project = confrest.Project()
                _checkskip(path, project.get_htmloutputpath(path))
                project.process(path) 
                break
        else: 
            # defer to default processor 
            _checkskip(path)
            rest.process(path) 
    except KeyboardInterrupt: 
        raise 
    except docutils.utils.SystemMessage: 
        # we assume docutils printed info on stdout 
        py.test.fail("docutils processing failed, see captured stderr") 
Example #2
0
 def check_rest(self, tempdir):
     from py.__.misc import rest
     for path in tempdir.listdir('*.txt'):
         try:
             rest.process(path)
         except ImportError:
             py.test.skip('skipping rest generation because docutils is '
                          'not installed (this is a partial skip, the rest '
                          'of the test was successful)')
     for path in tempdir.listdir('*.txt'):
         for item, arg1, arg2, arg3 in genlinkchecks(path):
             item(arg1, arg2, arg3)
Example #3
0
def test_own_links():
    def callback(name, text):
        assert name == "foo"
        return "bar xyz", "http://codespeak.net/noclue"
    directive.register_linkrole("foo", callback)
    txt = testdir.join("link-role.txt")
    txt.write("""
:foo:`whatever`
""")
    html = txt.new(ext="html")
    rest.process(txt)
    assert html.check()
    htmlcontent = html.read()
    assert "http://codespeak.net/noclue" in htmlcontent
    assert "bar xyz" in htmlcontent
Example #4
0
 def _graphviz_html(self):
     if not py.path.local.sysfind("dot"):
         py.test.skip("graphviz needed")
     directive.set_backend_and_register_directives("html")
     if not py.path.local.sysfind("svn"):
         py.test.skip("svn needed")
     txt = datadir.join("graphviz.txt")
     html = txt.new(ext="html")
     png = datadir.join("example1.png")
     rest.process(txt)
     assert html.check()
     assert png.check()
     html_content = html.read()
     assert png.basename in html_content
     html.remove()
     png.remove()
Example #5
0
def test_own_links():
    def callback(name, text):
        assert name == "foo"
        return "bar xyz", "http://codespeak.net/noclue"

    directive.register_linkrole("foo", callback)
    txt = testdir.join("link-role.txt")
    txt.write("""
:foo:`whatever`
""")
    html = txt.new(ext="html")
    rest.process(txt)
    assert html.check()
    htmlcontent = html.read()
    assert "http://codespeak.net/noclue" in htmlcontent
    assert "bar xyz" in htmlcontent
Example #6
0
 def _graphviz_html(self):
     if not py.path.local.sysfind("dot"):
         py.test.skip("graphviz needed")
     directive.set_backend_and_register_directives("html")
     if not py.path.local.sysfind("svn"):
         py.test.skip("svn needed")
     txt = datadir.join("graphviz.txt")
     html = txt.new(ext="html")
     png = datadir.join("example1.png")
     rest.process(txt)
     assert html.check()
     assert png.check()
     html_content = html.read()
     assert png.basename in html_content
     html.remove()
     png.remove()
Example #7
0
     filenames = [py.path.svnwc(x) for x in args]
 
 if options.topdf:
     directive.set_backend_and_register_directives("latex")
     
 for p in filenames:
     if not p.check():
         log("path %s not found, ignoring" % p)
         continue
     def fil(p):
         return p.check(fnmatch='*.txt', versioned=True)
     def rec(p):
         return p.check(dotfile=0)
     if p.check(dir=1):
         for x in p.visit(fil, rec):
             rest.process(x)
     elif p.check(file=1):
         if p.ext == ".rst2pdfconfig":
             directive.set_backend_and_register_directives("latex")
             process_configfile(p, options.debug)
         else:
             if options.topdf:
                 cfg = p.new(ext=".rst2pdfconfig")
                 if cfg.check():
                     print "using config file %s" % (cfg, )
                     process_configfile(cfg, options.debug)
                 else:
                     process_rest_file(p.localpath,
                                       options.stylesheet,
                                   options.debug)
             else:
Example #8
0
        directive.set_backend_and_register_directives("latex")

    for p in filenames:
        if not p.check():
            log("path %s not found, ignoring" % p)
            continue

        def fil(p):
            return p.check(fnmatch='*.txt', versioned=True)

        def rec(p):
            return p.check(dotfile=0)

        if p.check(dir=1):
            for x in p.visit(fil, rec):
                rest.process(x)
        elif p.check(file=1):
            if p.ext == ".rst2pdfconfig":
                directive.set_backend_and_register_directives("latex")
                process_configfile(p, options.debug)
            else:
                if options.topdf:
                    cfg = p.new(ext=".rst2pdfconfig")
                    if cfg.check():
                        print "using config file %s" % (cfg, )
                        process_configfile(cfg, options.debug)
                    else:
                        process_rest_file(p.localpath, options.stylesheet,
                                          options.debug)
                else:
                    rest.process(p)