in update-toc.py [0:0]
def amend_href(self, toc_dict):
if not self.doc_repo_location:
return toc_dict
input_string = toc_dict["href"]
# if this is an external readme, we should not attempt to resolve the file to a different one, just return with no changes
if any([input_string.startswith(href) for href in self.excluded_href_paths]):
return toc_dict
# create a resolvable path to the readme on disk, without any of the docs ms specificity
resolvable_path = os.path.normpath(os.path.join(self.doc_repo_location, input_string.replace("~/", "")))
# apply moniker folder adjustments if necessary
if self.target_moniker is not None:
for replacement in MONIKER_REPLACEMENTS:
# input string maintains leading ~/ necessary for docs. update the moniker folder if it exists
input_string = input_string.replace(replacement, self.target_moniker)
# the resolvable path is different from the input_string in that it is actually a resolvable path.
# update it with the moniker folder so we can test for existence of the file
resolvable_path = resolvable_path.replace(replacement, self.target_moniker)
possible_target_readme = os.path.splitext(resolvable_path)[0] + ".md"
if os.path.exists(possible_target_readme):
toc_dict["href"] = input_string
else:
toc_dict.pop("href")
toc_dict["landingPageType"] = "Service"
return toc_dict