Beispiel #1
0
 def write_page(self, title, reltargetpath, tag, nav):
     targetpath = self.base.join(reltargetpath)
     relbase= relpath('%s%s' % (targetpath.dirpath(), targetpath.sep),
                      self.base.strpath + '/')
     page = wrap_page(self.project, title, targetpath, tag, nav, self.base,
                      self.pageclass)
     # we write the page with _temporary_ hrefs here, need to be replaced
     # from the TempLinker later
     content = page.unicode()
     targetpath.ensure()
     targetpath.write(content.encode("utf8"))
Beispiel #2
0
    def process(self, txtpath): 
        encoding = self.encoding
        content = self.get_content(txtpath, encoding)
        docpath = self.get_docpath()
        outputpath = self.get_htmloutputpath(txtpath)

        stylesheet = self.stylesheet
        if isinstance(self.stylesheet, py.path.local):
            if not docpath.join(stylesheet.basename).check():
                docpath.ensure(dir=True)
                stylesheet.copy(docpath)
            stylesheet = relpath(outputpath.strpath,
                                 docpath.join(stylesheet.basename).strpath)

        content = convert_rest_html(content, txtpath,
                                    stylesheet=stylesheet, encoding=encoding)
        content = strip_html_header(content, encoding=encoding)

        page = self.Page(self, "[%s] " % txtpath.purebasename,
                         outputpath, stylesheeturl=stylesheet)

        try:
            svninfo = txtpath.info() 
            modified = " modified %s by %s" % (worded_time(svninfo.mtime),
                                               getrealname(svninfo.last_author))
        except (KeyboardInterrupt, SystemExit): 
            raise
        except:
            modified = " "

        page.contentspace.append(
            html.div(html.div(modified, style="float: right; font-style: italic;"), 
                     id = 'docinfoline'))

        page.contentspace.append(py.xml.raw(content))
        outputpath.ensure().write(page.unicode().encode(encoding)) 
Beispiel #3
0
def gen_check(frompath, topath, sep, expected):
    result = relpath(frompath, topath, sep=sep)
    assert result == expected
Beispiel #4
0
 def get_relpath(self):
     return linker.relpath(self.targetpath.strpath,
                           get_apigenpath().strpath) + '/'
Beispiel #5
0
def get_apigen_relpath():
    return relpath(get_docpath().strpath + '/',
                   get_apigenpath().strpath + '/')
Beispiel #6
0
 def a_apigenref(self, name, relhtmlpath):
     apipath = get_apigenpath()
     return html.a(name, class_="menu",
                   href=relpath(self.targetpath.strpath,
                                apipath.join(relhtmlpath).strpath))
Beispiel #7
0
 def a_docref(self, name, relhtmlpath):
     docpath = self.project.get_docpath()
     return html.a(name, class_="menu",
                   href=relpath(self.targetpath.strpath,
                                docpath.join(relhtmlpath).strpath))