|
23 | 23 |
|
24 | 24 | HERE = pathlib.Path(__file__).parent
|
25 | 25 | GET_REPOS = "https://api.github.com/orgs/jupyterlab-contrib/repos"
|
| 26 | +GET_REPO = "https://api.github.com/repos/jupyterlab-contrib/" |
26 | 27 | TOKEN = os.getenv("GITHUB_TOKEN")
|
27 | 28 |
|
28 |
| -extensions = (HERE / "extensions.tpl").read_text() |
| 29 | +footer = (HERE / "extensions.tpl").read_text() |
| 30 | +header = """# List of extensions and tools |
| 31 | +
|
| 32 | +## Extensions in this organization |
| 33 | +
|
| 34 | +The extensions hosted in this organization. |
| 35 | +
|
| 36 | +""" |
29 | 37 | default_headers = {}
|
30 | 38 | if TOKEN is not None:
|
31 | 39 | default_headers["authorization"] = f"Bearer {TOKEN}"
|
|
37 | 45 | params={"per_page": 100},
|
38 | 46 | )
|
39 | 47 | data = repos.json()
|
| 48 | + extensions = "" |
40 | 49 | for repo in data:
|
41 | 50 | if isinstance(repo, str):
|
42 | 51 | raise ValueError(data["message"])
|
|
45 | 54 | continue # Skip special repositories
|
46 | 55 |
|
47 | 56 | try:
|
| 57 | + response = requests.get( |
| 58 | + GET_REPO + repo["name"], |
| 59 | + headers={**default_headers, "Accept": "application/vnd.github.v3+json"} |
| 60 | + ) |
| 61 | + repo_attributes = response.json() |
| 62 | + description = repo_attributes.get("description", "") |
48 | 63 | readme = requests.get(
|
49 | 64 | repo["contents_url"].replace("{+path}", "README.md"),
|
50 | 65 | headers={
|
|
54 | 69 | )
|
55 | 70 | filename = repo["name"]
|
56 | 71 | (HERE / (filename + ".md")).write_text(readme.text)
|
57 |
| - extensions += f"\n* [{filename.replace('_', ' ')}]({filename}.md)" |
| 72 | + extensions += f"\n* [{filename.replace('_', ' ')}]({filename}.md): {description}" |
58 | 73 | except BaseException as err:
|
59 | 74 | print(err)
|
60 | 75 | print(f"Fail to get README for {filename}.")
|
61 | 76 | except BaseException as err:
|
62 | 77 | print(err)
|
63 | 78 | print("Fail to get organization repositories")
|
64 | 79 | finally:
|
65 |
| - (HERE / "extensions.md").write_text(extensions) |
| 80 | + (HERE / "extensions.md").write_text(header + extensions + footer) |
66 | 81 |
|
67 | 82 |
|
68 | 83 | # -- Project information -----------------------------------------------------
|
|
0 commit comments