diff --git a/source/contrib/automated_contributors.py b/source/contrib/automated_contributors.py new file mode 100644 index 00000000..633278a9 --- /dev/null +++ b/source/contrib/automated_contributors.py @@ -0,0 +1,47 @@ +from github import Github +from github import Auth + +access_token = "YOUR_ACCESS_TOKEN" + +auth = Auth.Token(access_token) + +g = Github(auth=auth) + +repositories = [ + "openchemistry/avogadrolibs", + "openchemistry/avogadroapp", + "openchemistry/fragments", + "openchemistry/molecules", + "openchemistry/crystals", + "openchemistry/avogenerators", + "openchemistry/avogadro-commands", + "openchemistry/avogadro-cclib", + "cryos/avogadro", +] + +unique_contributors = set() + +with open("contributors.md", "w") as contributors_file: + for repo_name in repositories: + repo = g.get_repo(repo_name) + contributors = repo.get_contributors() + + for contributor in contributors: + username = contributor.login + unique_contributors.add(username) + contributors_file.write(f"- {username}\n") + +sorted_contributors = sorted(unique_contributors) + +with open("credits.md", "r") as credits_file: + credits_content = credits_file.read() + +updated_credits_content = credits_content.replace( + "```{include} contributors.md```", + f"```{{include}} contributors.md\n\n" + "\n".join(sorted_contributors) + "\n```" +) + +with open("credits.md", "w") as credits_file: + credits_file.write(updated_credits_content) + +print("Contributors have been updated in contributors.md and credits.md.") diff --git a/source/contrib/contributors.md b/source/contrib/contributors.md index 81957d6e..94134183 100644 --- a/source/contrib/contributors.md +++ b/source/contrib/contributors.md @@ -138,3 +138,4 @@ - yavgech - yuri@FreeBSD - Ondřej Čertík +- Kailin Xing \ No newline at end of file diff --git a/source/requirements.txt b/source/requirements.txt index cf44fbec..1344f439 100644 --- a/source/requirements.txt +++ b/source/requirements.txt @@ -5,3 +5,4 @@ pydata-sphinx-theme sphinx-design sphinx-copybutton linkify-it-py +PyGithub \ No newline at end of file