From 32761b9782c3635419afa0f72118a9a2d42ef318 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Mon, 22 Jun 2020 20:42:59 +0800 Subject: [PATCH] docs: fix link_roles not linking correctly for certain files Link_roles could link incorrectly if the name of a file matched the name of a submodule --- docs/en/third-party-tools/platformio.rst | 2 +- docs/idf_extensions/link_roles.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/en/third-party-tools/platformio.rst b/docs/en/third-party-tools/platformio.rst index c875abc40..d13bdeaa5 100644 --- a/docs/en/third-party-tools/platformio.rst +++ b/docs/en/third-party-tools/platformio.rst @@ -44,7 +44,7 @@ Tutorials ~~~~~~~~~ - `ESP-IDF and ESP32-DevKitC: debugging, unit testing, project analysis - `__ + `__ Project Examples ~~~~~~~~~~~~~~~~ diff --git a/docs/idf_extensions/link_roles.py b/docs/idf_extensions/link_roles.py index 7ed9affdc..744f6c34b 100644 --- a/docs/idf_extensions/link_roles.py +++ b/docs/idf_extensions/link_roles.py @@ -57,7 +57,8 @@ def github_link(link_type, idf_rev, submods, root_path, app_config): # Redirects to submodule repo if path is a submodule, else default to IDF repo def redirect_submodule(path, submods, rev): for key, value in submods.items(): - if path.lstrip('/').startswith(key): + # Add path separator to end of submodule path to ensure we are matching a directory + if path.lstrip('/').startswith(os.path.join(key, '')): return value.url.replace('.git', ''), value.rev, re.sub('^/{}/'.format(key), '', path) return IDF_REPO, rev, path