From b2928ab9778d2a284cb2cf0a8f61602cea789c64 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 13 Jul 2019 17:52:33 +0200 Subject: [PATCH] documentation/python: allow relative links in top navbar. For (local) Magnum Python docs I need to link to C++ docs, which are in ../../../bla/index.html. --- documentation/python.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/documentation/python.py b/documentation/python.py index b62e1315..a56de157 100755 --- a/documentation/python.py +++ b/documentation/python.py @@ -1365,11 +1365,13 @@ def run(basedir, config, templates): if urllib.parse.urlparse(path).netloc: return path return os.path.basename(path) # Filter to return URL for given symbol. If the path is a string, first try - # to treat it as an URL. If that fails, turn it into a list and try to look - # it up in various dicts. + # to treat it as an URL -- either it needs to have the scheme or at least + # one slash for relative links (in contrast, Python names don't have + # slashes). If that fails, turn it into a list and try to look it up in + # various dicts. def path_to_url(path): if isinstance(path, str): - if urllib.parse.urlparse(path).netloc: return path + if urllib.parse.urlparse(path).netloc or '/' in path: return path path = [path] entry = state.name_map['.'.join(path)] # TODO: this will blow up if linking to something that's not a module, -- 2.30.2