Skip to content

Commit 68bfed5

Browse files
Add script to generate CITATION.cff from RelNotes
For that, require reformatting the author list in the relnotes to make it easier / more stable to parse. --------- Co-authored-by: Jonas Rembser <jonas.rembser@cern.ch>
1 parent 6ce64ed commit 68bfed5

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed

cmake/unix/makeCITATION.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Author: axel@cern.ch, 2021-07-08
2+
# License: LGPL2.1+, see file `LICENSE` in this folder.
3+
4+
import pypandoc
5+
import argparse
6+
import json
7+
import datetime
8+
import os, sys
9+
10+
import ROOT # for ROOT.__version__
11+
12+
"""
13+
Generate a CITATION.cff-style YAML block for the ROOT project based on a Markdown input file.
14+
15+
This script reads a Markdown file (e.g. `makeCITATION_example_input.md`, but
16+
typically the ROOT release notes) containing a bullet list of authors and
17+
optional ORCIDs, converts it to a Pandoc JSON AST using pypandoc, extracts
18+
author information.
19+
"""
20+
21+
22+
def printNames(nameBlock):
23+
# print(json.dumps(nameBlock))
24+
nameParts = [c for c in nameBlock]
25+
firstLastNames = [n["c"].replace("\u00a0", " ") for n in nameParts if n["t"] == "Str"]
26+
firstName = firstLastNames[0]
27+
lastName = firstLastNames[1]
28+
if lastName[-1] == ",":
29+
lastName = lastName[0:-1]
30+
print(" - family-names:", lastName)
31+
print(" given-names:", firstName)
32+
33+
34+
parser = argparse.ArgumentParser()
35+
parser.add_argument("releasenotes")
36+
parser.add_argument("--dump-ast", action="store_true")
37+
args = parser.parse_args()
38+
39+
jsonRN = json.loads(pypandoc.convert_file(args.releasenotes, "json"))
40+
if args.dump_ast:
41+
print(json.dumps(jsonRN, indent=1))
42+
sys.exit(0)
43+
44+
45+
print(
46+
"""cff-version: 1.1.0
47+
message: "If you use ROOT, please cite it as below."
48+
authors:"""
49+
)
50+
51+
for block in jsonRN["blocks"]:
52+
if "t" in block and block["t"] == "BulletList":
53+
for item in block["c"]:
54+
itemC = item[0]["c"]
55+
if itemC[0]["t"] == "Link":
56+
# 0th element is ["", [], []] ?
57+
printNames(itemC[0]["c"][1])
58+
orcid = itemC[0]["c"][2][0]
59+
print(" orcid:", orcid)
60+
elif itemC[0]["t"] == "Str":
61+
printNames(itemC)
62+
else:
63+
print('ERROR: expected "Link" or "Str" in', json.dumps(itemC[0], indent=1))
64+
sys.exit(1)
65+
break
66+
67+
print(
68+
f"""title: "ROOT: analyzing, storing and visualizing big data, scientifically"
69+
version: {ROOT.__version__}
70+
doi: 10.5281/zenodo.848818
71+
date-released: {datetime.datetime.now().strftime("%Y-%m-%d")}
72+
"""
73+
)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
% ROOT Version 6.26 Release Notes
2+
% 2021-03-03
3+
<a name="TopOfPage"></a>
4+
5+
## Introduction
6+
7+
ROOT version 6.26/00 is scheduled for release in May, 2021.
8+
9+
For more information, see:
10+
11+
[http://root.cern](http://root.cern)
12+
13+
The following people have contributed to this new version:
14+
15+
* [Sitong An](https://orcid.org/0000-0002-9740-1622), CERN/SFT
16+
* Bertrand Bellenot, CERN/SFT
17+
* Josh Bendavid, CERN/CMS
18+
* [Jakob Blomer](https://orcid.org/0000-0001-9750-6224), CERN/SFT
19+
* Rene Brun, CERN/SFT
20+
* [Will Buttinger](https://orcid.org/0000-0002-5116-1897), STFC/ATLAS
21+
* [Philippe Canal](https://orcid.org/0000-0002-7748-7887), FNAL
22+
* [Olivier Couet](https://orcid.org/0000-0002-7182-2621), CERN/SFT
23+
* [Gerardo Ganis](https://orcid.org/0000-0002-1175-206X), CERN/SFT
24+
* [Andrei Gheata](https://orcid.org/0000-0002-5449-8719), CERN/SFT
25+
* Enrico Guiraud, CERN/SFT
26+
* [Stephan Hageboeck](https://orcid.org/0000-0001-9359-2196), CERN/IT-SC
27+
* [Jonas Hahnfeld](https://orcid.org/0000-0001-7325-2485), CERN/SFT
28+
* Sergey Linev, GSI
29+
* [Pere Mato](https://orcid.org/0000-0002-3009-8948), CERN/SFT
30+
* Lorenzo Moneta, CERN/SFT
31+
* [Alja Mrak\ Tadel](https://orcid.org/0000-0002-3392-8345), UCSD/CMS
32+
* [Axel Naumann](https://orcid.org/0000-0002-4725-0766), CERN/SFT
33+
* Danilo Piparo, CERN/SFT
34+
* [Fons Rademakers](https://orcid.org/0000-0002-3571-9635), CERN/SFT
35+
* [Jonas Rembser](https://orcid.org/0000-0002-0632-2970), CERN/SFT
36+
* Enric Tejedor\ Saavedra, CERN/SFT
37+
* [Oksana Shadura](https://orcid.org/0000-0001-5356-2494), UNL/CMS
38+
* [Matevz Tadel](https://orcid.org/0000-0001-8800-0045), UCSD/CMS
39+
* Vassil Vassilev, Princeton/CMS
40+
* [Wouter Verkerke](https://orcid.org/0000-0001-5468-2025), NIKHEF/Atlas
41+
42+
## Body
43+
44+
The rest of the release notes.

0 commit comments

Comments
 (0)