-
Notifications
You must be signed in to change notification settings - Fork 75
Render authors from YAML front matter #552
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
Draft
lubianat
wants to merge
16
commits into
ome:main
Choose a base branch
from
lubianat:rfc_yaml_header
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 2 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
22e192e
feat: build authors from yaml header
lubianat 6bac583
test setup for rfc 9 comment 5
lubianat 89fb3ec
chore: use short ORCID version
lubianat f056f6c
rename directive to document_authors
lubianat a5bc52c
add YML front to rfc 9 docs
lubianat cb549e4
fix build for the rfc status page
lubianat 462ff21
start draft on representation of reviews
lubianat 538195a
merge main, add rfc 9 - 6
lubianat f698b99
Merge branch 'main' into rfc_yaml_header
lubianat cf12dec
merge main into branch
lubianat 9fe3106
Add frontmatter and anchor recommendations to templates
lubianat e6ddd01
Update again review templates and start work on RFC 4
lubianat d3b6919
Update RFC 4 comment2; add support for e-mail rendering
lubianat 5eea111
Add authors to reviews and responses for RFC 4
lubianat f7b8b94
update the rfc_status directive
lubianat 4e08ef9
update metadata for rfc3
lubianat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| import yaml | ||
| from docutils import nodes | ||
| from docutils.parsers.rst import Directive | ||
|
|
||
| ORCID_ICON = "https://orcid.org/assets/vectors/orcid.logo.icon.svg" | ||
| GITHUB_ICON = "https://github.githubassets.com/favicons/favicon.svg" | ||
|
|
||
|
|
||
| def _icon_link(uri, src, alt): | ||
| """A hyperlink wrapping a small inline image.""" | ||
| ref = nodes.reference("", "", refuri=uri) | ||
| img = nodes.image( | ||
| uri=src, | ||
| alt=alt, | ||
| classes=["rfc-author-icon"], | ||
| ) | ||
| ref += img | ||
| return ref | ||
|
|
||
|
|
||
| class RFCAuthors(Directive): | ||
| def run(self): | ||
| env = self.state.document.settings.env | ||
| src = env.doc2path(env.docname) | ||
| with open(src, encoding="utf-8") as f: | ||
| text = f.read() | ||
|
|
||
| parts = text.split("---", 2) | ||
| if len(parts) < 3: | ||
| raise self.error("rfc-authors: no YAML front matter found") | ||
| meta = yaml.safe_load(parts[1]) or {} | ||
|
|
||
| authors = meta.get("authors", []) | ||
| if not authors: | ||
| raise self.error("rfc-authors: no 'authors' in front matter") | ||
|
|
||
| # Number unique affiliations in first-seen order | ||
| affils, order = {}, [] | ||
| for a in authors: | ||
| aff = a.get("affiliation") | ||
| if aff and aff not in affils: | ||
| order.append(aff) | ||
| affils[aff] = len(order) | ||
|
|
||
| para = nodes.paragraph(classes=["rfc-authors"]) | ||
| for i, a in enumerate(authors): | ||
| if i: | ||
| para += nodes.Text(" and " if i == len(authors) - 1 else ", ") | ||
|
|
||
| para += nodes.Text(a["name"]) | ||
|
|
||
| aff = a.get("affiliation") | ||
| if aff: | ||
| para += nodes.superscript(text=str(affils[aff])) | ||
|
|
||
| orcid = a.get("orcid") | ||
| if orcid: | ||
| uri = ( | ||
| orcid | ||
| if str(orcid).startswith("http") | ||
| else f"https://orcid.org/{orcid}" | ||
| ) | ||
| para += nodes.Text(" ") | ||
| para += _icon_link(uri, ORCID_ICON, "ORCID") | ||
|
|
||
| gh = a.get("github") | ||
| if gh: | ||
| uri = gh if str(gh).startswith("http") else f"https://github.com/{gh}" | ||
| para += nodes.Text(" ") | ||
| para += _icon_link(uri, GITHUB_ICON, "GitHub") | ||
|
|
||
| result = [para] | ||
|
|
||
| for aff in order: | ||
| p = nodes.paragraph(classes=["rfc-affiliation"]) | ||
| p += nodes.superscript(text=str(affils[aff])) | ||
| p += nodes.Text(" " + aff) | ||
| result.append(p) | ||
|
|
||
| return result | ||
|
|
||
|
|
||
| def setup(app): | ||
| app.add_directive("rfc-authors", RFCAuthors) | ||
| return {"parallel_read_safe": True, "parallel_write_safe": True} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| .rfc-author-icon { | ||
| height: 1em; | ||
| width: 1em; | ||
| vertical-align: -0.15em; | ||
| margin: 0 0.05em; | ||
| display: inline; | ||
| } | ||
|
|
||
| .rfc-authors { | ||
| font-size: 1.05em; | ||
| } | ||
|
|
||
| .rfc-affiliation { | ||
| font-size: 0.85em; | ||
| color: var(--pst-color-text-muted, #666); | ||
| margin: 0.1em 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ testresources | |
| sphinx-reredirects | ||
| sphinxcontrib-bibtex | ||
| sphinx-design | ||
| pyyaml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.