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

Merge branch 'fix-doc-link' into 'master'

Link documentation of package with a  main branch

See merge request !149
parents 341259b1 29d83344
No related branches found
No related tags found
1 merge request!149Link documentation of package with a main branch
Pipeline #70488 passed
...@@ -106,20 +106,23 @@ package-z ...@@ -106,20 +106,23 @@ package-z
"python", "python",
"matplotlib", "matplotlib",
"bob.extension", "bob.extension",
"gridtk",
"other.bob.package", "other.bob.package",
] ]
# test linkage to official documentation # test linkage to official documentation
server = "http://www.idiap.ch/software/bob/docs/bob/%s/master/" server = (
os.environ["BOB_DOCUMENTATION_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)) result = link_documentation(additional_packages, stringio(f))
expected = [ expected = [
"https://docs.python.org/%d.%d/" % sys.version_info[:2], "https://docs.python.org/%d.%d/" % sys.version_info[:2],
"https://matplotlib.org/stable/", "https://matplotlib.org/stable/",
"https://setuptools.readthedocs.io/en/latest/", "https://setuptools.readthedocs.io/en/latest/",
server % "bob.extension", server[0] % "bob.extension",
server % "gridtk",
] ]
result = [k[0] for k in result.values()] result = [k[0] for k in result.values()]
assert sorted(result) == sorted(expected) assert sorted(result) == sorted(expected)
......
...@@ -198,7 +198,14 @@ def link_documentation( ...@@ -198,7 +198,14 @@ def link_documentation(
if "BOB_DOCUMENTATION_SERVER" in os.environ: if "BOB_DOCUMENTATION_SERVER" in os.environ:
server = os.environ["BOB_DOCUMENTATION_SERVER"] server = os.environ["BOB_DOCUMENTATION_SERVER"]
else: 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 # array support for BOB_DOCUMENTATION_SERVER
# transforms "(file:///path/to/dir https://example.com/dir| http://bla )" # transforms "(file:///path/to/dir https://example.com/dir| http://bla )"
...@@ -226,7 +233,7 @@ def link_documentation( ...@@ -226,7 +233,7 @@ def link_documentation(
) )
except pkg_resources.DistributionNotFound: except pkg_resources.DistributionNotFound:
version = "stable" # package is not a runtime dep, only referenced 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: try:
# otherwise, urlopen will fail # otherwise, urlopen will fail
...@@ -249,6 +256,7 @@ def link_documentation( ...@@ -249,6 +256,7 @@ def link_documentation(
# url request failed with a something else than 404 Error # url request failed with a something else than 404 Error
print("Requesting URL %s returned error: %s" % (url, exc)) print("Requesting URL %s returned error: %s" % (url, exc))
# notice mapping is not updated here, as the URL does not exist # notice mapping is not updated here, as the URL does not exist
print(f"Nothing found at {url}.")
except URLError as exc: except URLError as exc:
print( print(
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
================================== ==================================
It is often required to extend the functionality of your package as a It is often required to extend the functionality of your package as a
framework. :ref:`bob.bio.base <bob.bio.base>` is a good example; it provides an framework. `bob.bio.base <https://gitlab.idiap.ch/bob/bob.bio.base>`__ is a good example; it provides an
API and other packages build upon it. The utilities provided in this page are API and other packages build upon it. The utilities provided in this page are
helpful in creating framework packages and building complex helpful in creating framework packages and building complex
toolchians/pipelines. toolchians/pipelines.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment