Skip to content
Snippets Groups Projects
Commit 0f7b5490 authored by Yannick DAYER's avatar Yannick DAYER
Browse files

[py] Link documentation of package in main branch.

parent 341259b1
No related branches found
No related tags found
1 merge request!149Link documentation of package with a main branch
Pipeline #69770 failed
......@@ -111,15 +111,20 @@ package-z
]
# test linkage to official documentation
server = "http://www.idiap.ch/software/bob/docs/bob/%s/master/"
os.environ["BOB_DOCUMENTATION_SERVER"] = server
server = (
"http://www.idiap.ch/software/bob/docs/bob/%s/master/",
"http://www.idiap.ch/software/bob/docs/bob/%s/master/sphinx",
"http://www.idiap.ch/software/bob/docs/bob/%s/main/",
"http://www.idiap.ch/software/bob/docs/bob/%s/main/sphinx",
)
os.environ["BOB_DOCUMENTATION_SERVER"] = "|".join(server)
result = link_documentation(additional_packages, stringio(f))
expected = [
"https://docs.python.org/%d.%d/" % sys.version_info[:2],
"https://matplotlib.org/stable/",
"https://setuptools.readthedocs.io/en/latest/",
server % "bob.extension",
server % "gridtk",
server[0] % "bob.extension",
server[3] % "gridtk",
]
result = [k[0] for k in result.values()]
assert sorted(result) == sorted(expected)
......
......@@ -198,7 +198,14 @@ def link_documentation(
if "BOB_DOCUMENTATION_SERVER" in os.environ:
server = os.environ["BOB_DOCUMENTATION_SERVER"]
else:
server = "http://www.idiap.ch/software/bob/docs/bob/%(name)s/%(version)s/|http://www.idiap.ch/software/bob/docs/bob/%(name)s/%(version)s/sphinx|http://www.idiap.ch/software/bob/docs/bob/%(name)s/master/|http://www.idiap.ch/software/bob/docs/bob/%(name)s/master/sphinx"
server = (
"http://www.idiap.ch/software/bob/docs/bob/%(name)s/%(version)s/"
"|http://www.idiap.ch/software/bob/docs/bob/%(name)s/%(version)s/sphinx"
"|http://www.idiap.ch/software/bob/docs/bob/%(name)s/main/"
"|http://www.idiap.ch/software/bob/docs/bob/%(name)s/main/sphinx"
"|http://www.idiap.ch/software/bob/docs/bob/%(name)s/master/"
"|http://www.idiap.ch/software/bob/docs/bob/%(name)s/master/sphinx"
)
# array support for BOB_DOCUMENTATION_SERVER
# transforms "(file:///path/to/dir https://example.com/dir| http://bla )"
......@@ -226,7 +233,7 @@ def link_documentation(
)
except pkg_resources.DistributionNotFound:
version = "stable" # package is not a runtime dep, only referenced
url = s % {"name": package_name, "version": version}
url = s.format(name=package_name, version=version)
try:
# otherwise, urlopen will fail
......@@ -249,6 +256,7 @@ def link_documentation(
# url request failed with a something else than 404 Error
print("Requesting URL %s returned error: %s" % (url, exc))
# notice mapping is not updated here, as the URL does not exist
print(f"Nothing found at {url}.")
except URLError as exc:
print(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment