|
20 | 20 |
|
21 | 21 | import sys |
22 | 22 | import os |
| 23 | +import re |
23 | 24 | import importlib |
24 | 25 | import dateutil.parser |
25 | 26 | import sphinx |
@@ -441,11 +442,24 @@ def linkcode_resolve(domain, info): |
441 | 442 | } |
442 | 443 |
|
443 | 444 | if not version.split('.')[-1].isnumeric(): # develop version |
444 | | - html_theme_options.update({ |
445 | | - "announcement": f'This is documentation for Sage development version {version}. ' |
446 | | - 'The documentation for the latest stable version is available ' |
447 | | - '<a href="https://doc.sagemath.org/html/en/index.html">here</a>.' |
448 | | -}) |
| 445 | + ver = f'<a href="https://livedoc--sagemath.netlify.app/html/en/index.html">{version}</a>' |
| 446 | + github_ref = os.environ.get('GITHUB_REF', '') |
| 447 | + if github_ref: |
| 448 | + match = re.search(r'refs/pull/(\d+)/merge', github_ref) |
| 449 | + if match: |
| 450 | + # As this doc is built for a GitHub PR, we plant a link |
| 451 | + # to the PR in the announcement banner. |
| 452 | + pr_number = match.group(1) |
| 453 | + pr_url = f'https://github.com/sagemath/sage/pull/{pr_number}' |
| 454 | + pr_sha = os.environ.get('GITHUB_SHA', '') |
| 455 | + pr_commit = pr_url + f'/commits/{pr_sha}' |
| 456 | + ver += f' built with GitHub PR <a href="{pr_url}">#{pr_number}</a>' \ |
| 457 | + f' on <a href="{pr_commit}">{pr_sha[:7]}</a>' \ |
| 458 | + f' [<a href="/changes.html">changes</a>]' |
| 459 | + banner = f'This is documentation for Sage development version {ver}. ' \ |
| 460 | + 'Documentation for the latest stable version is ' \ |
| 461 | + '<a href="https://doc.sagemath.org/html/en/index.html">here</a>.' |
| 462 | + html_theme_options.update({ "announcement": banner }) |
449 | 463 |
|
450 | 464 | # The name of the Pygments (syntax highlighting) style to use. This |
451 | 465 | # overrides a HTML theme's corresponding setting. |
|
0 commit comments