in bot/code_review_bot/tasks/docupload.py [0:0]
def direct_doc_url(path, docs_url, trees):
base_docs_url = os.path.dirname(docs_url)
filename, _ = os.path.splitext(os.path.basename(path))
dirname = os.path.dirname(path)
for docs_match_in_trees, dirname_in_trees in trees.items():
if dirname.startswith(dirname_in_trees):
truncated_dirname = dirname.replace(dirname_in_trees, "", 1)
# Forging the link towards the documentation
return "/".join(
part.strip("/")
for part in [
base_docs_url,
docs_match_in_trees,
truncated_dirname,
f"{filename}.html",
]
if part
)
# We didn't find a mapping for the file in the trees artifact, this should never happen
logger.warn(
"Found no match in the trees.json mapping to build a direct documentation link",
file=path,
)
return docs_url