Published releases, newest first; None when the API is unreachable. Drafts are excluded so an unpublished release skeleton never leaks into the docs. GITHUB_TOKEN (set in CI) only lifts the anonymous rate limit; the data is public. Offline builds fall back to a link, never fail.
()
| 22 | |
| 23 | |
| 24 | def _fetch_releases(): |
| 25 | """Published releases, newest first; None when the API is unreachable. |
| 26 | |
| 27 | Drafts are excluded so an unpublished release skeleton never leaks into |
| 28 | the docs. GITHUB_TOKEN (set in CI) only lifts the anonymous rate limit; |
| 29 | the data is public. Offline builds fall back to a link, never fail. |
| 30 | """ |
| 31 | global _RELEASES_CACHE |
| 32 | if _RELEASES_CACHE is not None: |
| 33 | return _RELEASES_CACHE or None |
| 34 | headers = { |
| 35 | "Accept": "application/vnd.github+json", |
| 36 | "User-Agent": "dashscope-sdk-docs-build", |
| 37 | } |
| 38 | token = os.environ.get("GITHUB_TOKEN") |
| 39 | if token: |
| 40 | headers["Authorization"] = "Bearer " + token |
| 41 | try: |
| 42 | request = urllib.request.Request(_RELEASES_URL, headers=headers) |
| 43 | with urllib.request.urlopen(request, timeout=10) as response: |
| 44 | releases = json.load(response) |
| 45 | releases = [r for r in releases if not r.get("draft")] |
| 46 | releases.sort(key=lambda r: r.get("published_at") or "", reverse=True) |
| 47 | _RELEASES_CACHE = releases |
| 48 | return releases or None |
| 49 | except Exception: |
| 50 | _RELEASES_CACHE = [] |
| 51 | return None |
| 52 | |
| 53 | |
| 54 | def _render_release_notes(lang): |
no test coverage detected