def lang_link(lang, path): """ Generates links to other language docs. """ dots = [] for p in path.split(SEP): dots.append('..') return SEP.join(dots) + SEP + lang + SEP + path + app.builder.link_suffix
def lang_link(lang, path): """ Generates links to other language docs. """ dots = [] for p in path.split(SEP): dots.append("..") tokens = lang.split("_") if len(tokens) > 1: folder = tokens[0] else: folder = lang return SEP.join(dots) + SEP + folder + SEP + path + app.builder.link_suffix
def lang_link(lang, path): """ Generates links to other language docs. """ dots = [] for p in path.split(SEP): dots.append('..') tokens = lang.split('_') if len(tokens) > 1: folder = tokens[0] else: folder = lang return SEP.join(dots) + SEP + folder + SEP + path + app.builder.link_suffix
def relative_uri(base, to): """Return a relative URL from ``base`` to ``to``.""" if to.startswith(SEP): return to b2 = base.split(SEP) t2 = to.split(SEP) # remove common segments (except the last segment) for x, y in zip(b2[:-1], t2[:-1]): if x != y: break b2.pop(0) t2.pop(0) if b2 == t2: # Special case: relative_uri('f/index.html','f/index.html') # returns '', not 'index.html' return '' if len(b2) == 1 and t2 == ['']: # Special case: relative_uri('f/index.html','f/') should # return './', not '' return '.' + SEP return ('..' + SEP) * (len(b2)-1) + SEP.join(t2)
def relative_uri(base, to): """Return a relative URL from ``base`` to ``to``.""" if to.startswith(SEP): return to b2 = base.split(SEP) t2 = to.split(SEP) # remove common segments (except the last segment) for x, y in zip(b2[:-1], t2[:-1]): if x != y: break b2.pop(0) t2.pop(0) if b2 == t2: # Special case: relative_uri('f/index.html','f/index.html') # returns '', not 'index.html' return '' if len(b2) == 1 and t2 == ['']: # Special case: relative_uri('f/index.html','f/') should # return './', not '' return '.' + SEP return ('..' + SEP) * (len(b2) - 1) + SEP.join(t2)