Skip to content

Skip archived repo & add GitHub badge #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# List all organization extensions
import os
import pathlib
import re
import recommonmark
import requests
from datetime import datetime
Expand All @@ -25,6 +26,7 @@
HERE = pathlib.Path(__file__).parent
GET_REPOS = "https://api.github.com/orgs/jupyterlab-contrib/repos"
GET_REPO = "https://api.github.com/repos/jupyterlab-contrib/"
REPO_BADGE = "[![GitHub Repo stars](https://img.shields.io/github/stars/jupyterlab-contrib/{name}?style=social)]({html_url})"
TOKEN = os.getenv("GITHUB_TOKEN")

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

if "github" in repo["name"]:
continue # Skip special repositories
if "github" in repo["name"] or repo["archived"]:
continue # Skip special repositories and archived ones

try:
response = requests.get(
Expand All @@ -69,7 +71,9 @@
},
)
filename = repo["name"]
(HERE / (filename + ".md")).write_text(readme.text)
badge = REPO_BADGE.format(name=repo["name"], html_url=repo["html_url"])
readme_content = re.sub(r"\n\n", f"\n\n{badge}", readme.text, count=1)
(HERE / (filename + ".md")).write_text(readme_content)
extensions += f"\n* [{filename.replace('_', ' ')}]({filename}.md): {description}"
except BaseException as err:
print(err)
Expand Down