Skip to content

Commit f52561a

Browse files
authored
Skip archived repo & add GitHub badge (jupyterlab-contrib#39)
1 parent 45c1499 commit f52561a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

conf.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# List all organization extensions
1818
import os
1919
import pathlib
20+
import re
2021
import recommonmark
2122
import requests
2223
from datetime import datetime
@@ -25,6 +26,7 @@
2526
HERE = pathlib.Path(__file__).parent
2627
GET_REPOS = "https://api.github.com/orgs/jupyterlab-contrib/repos"
2728
GET_REPO = "https://api.github.com/repos/jupyterlab-contrib/"
29+
REPO_BADGE = "[![GitHub Repo stars](https://img.shields.io/github/stars/jupyterlab-contrib/{name}?style=social)]({html_url})"
2830
TOKEN = os.getenv("GITHUB_TOKEN")
2931

3032
footer = (HERE / "extensions.tpl").read_text()
@@ -51,8 +53,8 @@
5153
if isinstance(repo, str):
5254
raise ValueError(data["message"])
5355

54-
if "github" in repo["name"]:
55-
continue # Skip special repositories
56+
if "github" in repo["name"] or repo["archived"]:
57+
continue # Skip special repositories and archived ones
5658

5759
try:
5860
response = requests.get(
@@ -69,7 +71,9 @@
6971
},
7072
)
7173
filename = repo["name"]
72-
(HERE / (filename + ".md")).write_text(readme.text)
74+
badge = REPO_BADGE.format(name=repo["name"], html_url=repo["html_url"])
75+
readme_content = re.sub(r"\n\n", f"\n\n{badge}", readme.text, count=1)
76+
(HERE / (filename + ".md")).write_text(readme_content)
7377
extensions += f"\n* [{filename.replace('_', ' ')}]({filename}.md): {description}"
7478
except BaseException as err:
7579
print(err)

0 commit comments

Comments
 (0)