Skip to content

Commit e6ea96a

Browse files
authored
Merge pull request #19 from nipreps/enh/community-members-table
ENH: Render a list of community members
2 parents 544b29c + da62064 commit e6ea96a

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
- name: Build
3535
run: |
3636
cd mkdocs/
37+
python scripts/generate_members_grid.py
3738
mkdocs build -d ../www/
3839
3940
- name: Deploy

docs/community/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@ to efficiently evaluate the validity of new features (even to exercise a minuscu
3636
of the domain of inputs).
3737
The redundancy of expert eyes looking at our code has only helped make it better.
3838

39-
[Neurostars.org]: https://neurostars.org
39+
## Members
40+
4041

42+
[Neurostars.org]: https://neurostars.org

docs/stylesheets/extra.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11

22
div.recommended.highlight span.hll {
33
background-color: #a7e8c8;
4+
}
5+
6+
.avatar {
7+
vertical-align: middle;
8+
width: 50px;
9+
height: 50px;
10+
border-radius: 50%;
411
}

scripts/generate_members_grid.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2+
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
#
4+
# Copyright 2021 The NiPreps Developers <[email protected]>
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
# We support and encourage derived works from this project, please read
19+
# about our expectations at
20+
#
21+
# https://www.nipreps.org/community/licensing/
22+
#
23+
"""Query the GitHub API to retrieve the list of members."""
24+
25+
import os
26+
import requests
27+
from pathlib import Path
28+
29+
30+
def main(argv=None):
31+
gh_token = os.getenv("GITHUB_TOKEN", None)
32+
33+
if not gh_token:
34+
raise RuntimeError("No token")
35+
36+
response = requests.get(
37+
"https://api.github.com/orgs/nipreps/members?per_page=100",
38+
headers={
39+
"Accept": "application/vnd.github+json",
40+
"Authorization": f"Bearer {gh_token}",
41+
}
42+
)
43+
44+
if not response.ok:
45+
raise RuntimeError(f"Response failed ({response.code})")
46+
47+
members = [
48+
f'<img class=".avatar" src="{item["avatar_url"}" />'
49+
for item in response.json()
50+
]
51+
52+
target_file = Path(__file__).parent.parent / "docs" / "community" / "index.md"
53+
54+
lines = target_file.read_text().splitlines()
55+
insert_line = len(lines)
56+
57+
for line in reversed(lines):
58+
if line.strip().startswith("## Members"):
59+
break
60+
insert_line -= 1
61+
62+
lines = lines[:insert_line] + members + lines[insert_line:]
63+
target_file.write_text("\n".join(lines))
64+
65+
66+
if __name__ == "__main__":
67+
main()

0 commit comments

Comments
 (0)