'Return paths to a file referenced from a document, relative to
documentation root and absolute.
In the input "filename", absolute filenames are taken as relative to the
source dir, while relative filenames are relative to the dir of the
containing document.'

def relfn2path(self, filename, docname=None):

    if (filename.startswith('/') or filename.startswith(os.sep)):
        rel_fn = filename[1:]
    else:
        docdir = path.dirname(self.doc2path((docname or self.docname), base=None))
        rel_fn = path.join(docdir, filename)
    try:
        return (rel_fn, path.abspath(path.join(self.srcdir, rel_fn)))
    except UnicodeDecodeError:
        enc_rel_fn = rel_fn.encode(sys.getfilesystemencoding())
        return (rel_fn, path.abspath(path.join(self.srcdir, enc_rel_fn)))
