mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 18:56:19 +08:00
Added new mkdocs based documentation to the project (#261)
Co-authored-by: Awais Mirza <47096947+awaismirza92@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
co-authored by
Awais Mirza
github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions
parent
efbfd65c81
commit
7a7b58f25c
@@ -0,0 +1,133 @@
|
||||
from pathlib import Path
|
||||
import re
|
||||
from jinja2 import Template
|
||||
from mkdocs.config import Config
|
||||
|
||||
from mkdocs.structure.files import Files
|
||||
from mkdocs.structure.pages import Page
|
||||
import yaml
|
||||
|
||||
THIS_DIR = Path(__file__).parent
|
||||
|
||||
|
||||
def on_page_markdown(markdown: str, page: Page, config: Config, files: Files) -> str:
|
||||
"""
|
||||
Called on each file after it is read and before it is converted to HTML.
|
||||
"""
|
||||
|
||||
if md := populate_people(markdown, page):
|
||||
return md
|
||||
return markdown
|
||||
|
||||
|
||||
experts_template = Template(
|
||||
"""
|
||||
<div class="user-list user-list-center">
|
||||
{% for user in people.experts %}
|
||||
<div class="user">
|
||||
<a href="{{ user.url }}" target="_blank">
|
||||
<div class="avatar-wrapper">
|
||||
<img src="{{ user.avatarUrl }}"/>
|
||||
</div>
|
||||
<div class="title">@{{ user.login }}</div>
|
||||
</a>
|
||||
<div class="count">Questions replied: {{ user.count }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
"""
|
||||
)
|
||||
|
||||
most_active_users_template = Template(
|
||||
"""
|
||||
|
||||
<div class="user-list user-list-center">
|
||||
{% for user in people.last_month_active %}
|
||||
<div class="user">
|
||||
<a href="{{ user.url }}" target="_blank">
|
||||
<div class="avatar-wrapper">
|
||||
<img src="{{ user.avatarUrl }}"/>
|
||||
</div>
|
||||
<div class="title">@{{ user.login }}</div>
|
||||
</a>
|
||||
<div class="count">Questions replied: {{ user.count }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
"""
|
||||
)
|
||||
|
||||
top_contributors_template = Template(
|
||||
"""
|
||||
<div class="user-list user-list-center">
|
||||
{% for user in people.top_contributors %}
|
||||
<div class="user">
|
||||
<a href="{{ user.url }}" target="_blank">
|
||||
<div class="avatar-wrapper">
|
||||
<img src="{{ user.avatarUrl }}"/>
|
||||
</div>
|
||||
<div class="title">@{{ user.login }}</div>
|
||||
</a>
|
||||
<div class="count">Contributions: {{ user.count }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
"""
|
||||
)
|
||||
|
||||
top_reviewers_template = Template(
|
||||
"""
|
||||
<div class="user-list user-list-center">
|
||||
{% for user in people.top_reviewers %}
|
||||
<div class="user">
|
||||
<a href="{{ user.url }}" target="_blank">
|
||||
<div class="avatar-wrapper">
|
||||
<img src="{{ user.avatarUrl }}"/>
|
||||
</div>
|
||||
<div class="title">@{{ user.login }}</div>
|
||||
</a>
|
||||
<div class="count">Reviews: {{ user.count }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
"""
|
||||
)
|
||||
|
||||
maintainers_template = Template(
|
||||
"""
|
||||
<div class="user-list user-list-center">
|
||||
{% for user in people.maintainers %}
|
||||
<div class="user">
|
||||
<a href="{{ user.url }}" target="_blank">
|
||||
<div class="avatar-wrapper">
|
||||
<img src="{{ user.avatarUrl }}"/>
|
||||
</div>
|
||||
<div class="title">@{{ user.login }}</div>
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def populate_people(markdown: str, page: Page) -> str | None:
|
||||
if page.file.src_uri != "people.md":
|
||||
return None
|
||||
|
||||
# read people.yml file data
|
||||
with (THIS_DIR / "people.yml").open("rb") as f:
|
||||
people = yaml.load(f, Loader=yaml.FullLoader)
|
||||
|
||||
# Render the templates
|
||||
for name, template in [
|
||||
("experts", experts_template),
|
||||
("most_active_users", most_active_users_template),
|
||||
("top_contributors", top_contributors_template),
|
||||
("top_reviewers", top_reviewers_template),
|
||||
("maintainers", maintainers_template),
|
||||
]:
|
||||
rendered = template.render(people=people)
|
||||
markdown = re.sub(f"{{{{ {name} }}}}", rendered, markdown)
|
||||
|
||||
return markdown
|
||||
@@ -0,0 +1,147 @@
|
||||
maintainers:
|
||||
- login: liuzicheng1987
|
||||
answers: 0
|
||||
prs: 61
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/19538706?u=1ca794b4e5aa9bbe50277f249e701eea86b0fdd3&v=4
|
||||
url: https://github.com/liuzicheng1987
|
||||
- login: Urfoex
|
||||
answers: 0
|
||||
prs: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1561354?v=4
|
||||
url: https://github.com/Urfoex
|
||||
experts: []
|
||||
last_month_active: []
|
||||
top_contributors:
|
||||
- login: hlewin
|
||||
count: 6
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/25082820?v=4
|
||||
url: https://github.com/hlewin
|
||||
- login: ChemiCalChems
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9658223?u=dee2c0ee7e74b1a709d814f1944bd15ba9ca022e&v=4
|
||||
url: https://github.com/ChemiCalChems
|
||||
- login: grandseiken
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/6506599?v=4
|
||||
url: https://github.com/grandseiken
|
||||
- login: Lazrius
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/16494336?u=d1c359b2b9f7c1898811de4840020778dc891ea6&v=4
|
||||
url: https://github.com/Lazrius
|
||||
- login: Altren
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1607435?v=4
|
||||
url: https://github.com/Altren
|
||||
- login: lixin-wei
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/19600697?u=539692f60ba009b3e2a6a66db90b1fa47be6b0bc&v=4
|
||||
url: https://github.com/lixin-wei
|
||||
- login: tim-lyon
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/45316507?u=075a847179fd6a792be9559cab7c5c951a911e5d&v=4
|
||||
url: https://github.com/tim-lyon
|
||||
- login: BjornSAIM
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/171575293?v=4
|
||||
url: https://github.com/BjornSAIM
|
||||
- login: Harry-Chen
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/2819727?v=4
|
||||
url: https://github.com/Harry-Chen
|
||||
- login: eel76
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/16246891?v=4
|
||||
url: https://github.com/eel76
|
||||
- login: zerolfx
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/20219056?u=cd774858edd6a4185c0634aa88fa93457fd8b017&v=4
|
||||
url: https://github.com/zerolfx
|
||||
- login: ecatmur
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/801922?v=4
|
||||
url: https://github.com/ecatmur
|
||||
- login: hazby2002
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/45712321?v=4
|
||||
url: https://github.com/hazby2002
|
||||
- login: GregTheMadMonk
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/25012039?u=2bb30375da7ba8640c208910227e028edf2c0d08&v=4
|
||||
url: https://github.com/GregTheMadMonk
|
||||
- login: melton1968
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/976548?v=4
|
||||
url: https://github.com/melton1968
|
||||
- login: toge
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/465629?u=fc95d16a396044be5625091463f1f89711bdc05e&v=4
|
||||
url: https://github.com/toge
|
||||
- login: JoshBurrell
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8190704?v=4
|
||||
url: https://github.com/JoshBurrell
|
||||
- login: jkeiser
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/654882?v=4
|
||||
url: https://github.com/jkeiser
|
||||
- login: Knyukua
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/74075239?u=245ee84b8dc7e7a448734f78ff0c3d112ca381e4&v=4
|
||||
url: https://github.com/Knyukua
|
||||
- login: m-mcgowan
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/2465470?v=4
|
||||
url: https://github.com/m-mcgowan
|
||||
- login: RyanDraves
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/19778373?u=ea124dd87fef0431bb3acd9f22acac5571d5d0d9&v=4
|
||||
url: https://github.com/RyanDraves
|
||||
- login: AnsiV01
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/129291956?u=cf6d5127cc3d2803b3046b63381b0c9edb9304ec&v=4
|
||||
url: https://github.com/AnsiV01
|
||||
- login: dmikushin
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/5672874?u=784bed75072206acd9aaf304de65ea94b6d0c0a5&v=4
|
||||
url: https://github.com/dmikushin
|
||||
- login: danielmohansahu
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/17955351?v=4
|
||||
url: https://github.com/danielmohansahu
|
||||
- login: BestITUserEUW
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/56920372?u=819964193b010021236df083f5275bfe9a1e7b73&v=4
|
||||
url: https://github.com/BestITUserEUW
|
||||
- login: dcorbeil
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8996584?u=c44b58e17208d597665b97e2e3fd774245996ae7&v=4
|
||||
url: https://github.com/dcorbeil
|
||||
- login: jowillianto
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/26686080?v=4
|
||||
url: https://github.com/jowillianto
|
||||
- login: xiaoyaodid
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10734750?u=ae63ba0fcbc4761ec1dcae0c6a94afe14ca50589&v=4
|
||||
url: https://github.com/xiaoyaodid
|
||||
- login: TomCC7
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/55869557?u=050e5d34b97fab0461815215abdce175e40af951&v=4
|
||||
url: https://github.com/TomCC7
|
||||
top_reviewers:
|
||||
- login: schaumb
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/6457941?u=542743f214f2197bd08b7b7112a2ba1b1e6e73ac&v=4
|
||||
url: https://github.com/schaumb
|
||||
- login: lixin-wei
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/19600697?u=539692f60ba009b3e2a6a66db90b1fa47be6b0bc&v=4
|
||||
url: https://github.com/lixin-wei
|
||||
- login: StephanTLavavej
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4231088?u=fd10ba4ada8f71ecd4a6be3f4b3cb9993528babc&v=4
|
||||
url: https://github.com/StephanTLavavej
|
||||
- login: bryceschober
|
||||
count: 1
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/918614?v=4
|
||||
url: https://github.com/bryceschober
|
||||
Reference in New Issue
Block a user