Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: ext: link-roles: allow non-default baseurl #28245

Merged
merged 1 commit into from
Sep 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions doc/extensions/zephyr/link-roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import re
from docutils import nodes
from local_util import run_cmd_get_output
try:
from west.manifest import Manifest as WestManifest
except ImportError:
WestManifest = None


def get_github_rev():
Expand All @@ -22,8 +26,17 @@ def get_github_rev():
def setup(app):
rev = get_github_rev()

# links to files or folders on the GitHub
baseurl = 'https://github.com/zephyrproject-rtos/zephyr'
# try to get url from West; this adds compatibility with repos
# located elsewhere
if WestManifest is not None:
baseurl = WestManifest.from_file().get_projects(['zephyr'])[0].url
else:
baseurl = None

# or fallback to default
if baseurl is None:
mbolivar-nordic marked this conversation as resolved.
Show resolved Hide resolved
baseurl = 'https://github.com/zephyrproject-rtos/zephyr'

app.add_role('zephyr_file', autolink('{}/blob/{}/%s'.format(baseurl, rev)))
app.add_role('zephyr_raw', autolink('{}/raw/{}/%s'.format(baseurl, rev)))

Expand Down