Skip to content
Open
Show file tree
Hide file tree
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
15 changes: 13 additions & 2 deletions .config/hooks/authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from mkdocs.structure.files import File

AUTHORS_FILE = "authors.yml"
ORCID_ICON = "assets/orcid-id.svg"
CONTRIB_HEADING_RE = re.compile(
r"^##\s+Contributors\s*&\s*Acknowledg\w*\s*$",
re.MULTILINE,
Expand All @@ -28,6 +29,16 @@
HEADING_RE = re.compile(r"^#+\s", re.MULTILINE)


def _orcid_markdown(orcid: str, asset_prefix: str) -> str:
"""Render an ORCID iD with the official icon, wrapped in a link.

``asset_prefix`` is "" for source pages at the docs root and "../" for
generated pages under ``authors/``.
"""
icon = f"![ORCID iD icon]({asset_prefix}{ORCID_ICON})"
return f"[{icon} {orcid}](https://orcid.org/{orcid})"


def _load_authors(docs_dir: str) -> dict:
path = Path(docs_dir) / AUTHORS_FILE
if not path.exists():
Expand Down Expand Up @@ -90,7 +101,7 @@ def _render_author_page(slug: str, record: dict, patterns: list[tuple[str, str]]
if affiliation:
lines += [f"**Affiliation:** {affiliation}", ""]
if orcid:
lines += [f"**ORCID:** [{orcid}](https://orcid.org/{orcid})", ""]
lines += [f"**ORCID:** {_orcid_markdown(orcid, '../')}", ""]

lines += ["## Patterns", ""]
if patterns:
Expand Down Expand Up @@ -135,7 +146,7 @@ def _render_pattern_bullets(slugs: list[str], authors_map: dict) -> str:
if aff:
extras.append(aff)
if orcid:
extras.append(f"[ORCID](https://orcid.org/{orcid})")
extras.append(_orcid_markdown(orcid, ""))
if extras:
line += " — " + ", ".join(extras)
bullets.append(line)
Expand Down
9 changes: 9 additions & 0 deletions assets/orcid-id.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.