MCPcopy Create free account
hub / github.com/dashscope/dashscope-sdk-java / _fetch_releases

Function _fetch_releases

docs/main.py:24–51  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

22
23
24def _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
54def _render_release_notes(lang):

Callers 1

_render_release_notesFunction · 0.85

Calls 3

RequestMethod · 0.80
getMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected