Skip to content

Commit 8622e3e

Browse files
committed
Enable annotating contributor roles
1 parent 56f7446 commit 8622e3e

File tree

7 files changed

+179
-0
lines changed

7 files changed

+179
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
`Inara` uses [SemVer][] (semantic versioning).
44

5+
## Inara v1.2.0
6+
7+
- Support for annotating author roles with the Contribution Role Taxonomy (CRediT) (Charles Tapley Hoyt)
8+
59
## Inara v1.1.0
610

711
Released 2024-09-04.

data/defaults/pdf.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ filters:
1111
path: self-citation.lua
1212
- type: lua
1313
path: fix-bibentry-spacing.lua
14+
- type: lua
15+
path: prepare-credit.lua
1416
variables:
1517
# styling options
1618
colorlinks: true

data/defaults/preprint.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
to: latex
22
output-file: paper.preprint.tex
33
template: preprint.latex
4+
filters:
5+
- type: lua
6+
path: prepare-credit.lua
47
variables:
58
# styling options
69
colorlinks: true

data/filters/prepare-credit.lua

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
-- Checks if any contributor information is available
2+
3+
roles = pandoc.List {
4+
"conceptualization",
5+
"data-curation",
6+
"formal-analysis",
7+
"funding-acquisition",
8+
"investigation",
9+
"methodology",
10+
"project-administration",
11+
"resources",
12+
"software",
13+
"supervision",
14+
"validation",
15+
"visualization",
16+
"writing-original-draft",
17+
"writing-review-editing"
18+
}
19+
20+
degrees = pandoc.List {
21+
"Lead",
22+
"Supporting",
23+
"Equal"
24+
}
25+
26+
function invalidRole(str)
27+
return not roles:includes(str)
28+
end
29+
30+
function invalidDegree(str)
31+
return not degrees:includes(str)
32+
end
33+
34+
function join_with_commas_and(list)
35+
local len = #list
36+
if len == 0 then
37+
return ""
38+
elseif len == 1 then
39+
return list[1]
40+
elseif len == 2 then
41+
return list[1] .. " and " .. list[2]
42+
else
43+
local result = table.concat(list, ", ", 1, len - 1)
44+
return result .. ", and " .. list[len]
45+
end
46+
end
47+
48+
function capitalize_first_letter(str)
49+
return str:sub(1, 1):upper() .. str:sub(2)
50+
end
51+
52+
function clean_role_dict(d)
53+
if d.type then
54+
return d
55+
else
56+
return {["type"] = pandoc.utils.stringify(d)}
57+
end
58+
end
59+
60+
function Meta (meta)
61+
meta.hasRoles = false
62+
for _, author in ipairs(meta.authors or {}) do
63+
if author.roles then
64+
meta.hasRoles = true
65+
roleList = {}
66+
for _, roleDict in ipairs(author.roles) do
67+
roleDict = clean_role_dict(roleDict)
68+
role = pandoc.utils.stringify(roleDict.type)
69+
if invalidRole(role) then
70+
error("invalid role for author " .. author.name .. ": " .. role)
71+
end
72+
if roleDict.degree then
73+
degree = capitalize_first_letter(pandoc.utils.stringify(roleDict.degree))
74+
if invalidDegree(degree) then
75+
error("invalid degree for author " .. author.name .. ": " .. degree)
76+
end
77+
table.insert(roleList, role .. " (" .. degree .. ")")
78+
else
79+
table.insert(roleList, role)
80+
end
81+
end
82+
author.rolesString = join_with_commas_and(roleList)
83+
end
84+
end
85+
return meta
86+
end

data/templates/default.latex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,15 @@ $if(lof)$
557557
$endif$
558558
$body$
559559

560+
$if(hasRoles)$
561+
\section{Author Contributions}\label{author-contributions}
562+
\begin{enumerate}
563+
$for(authors)$
564+
\item $it.name$ - $it.rolesString$
565+
$endfor$
566+
\end{enumerate}
567+
$endif$
568+
560569
$if(natbib)$
561570
$if(bibliography)$
562571
$if(biblio-title)$

data/templates/preprint.latex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,15 @@ $if(has-frontmatter)$
438438
$endif$
439439
$body$
440440

441+
$if(hasRoles)$
442+
\section{Author Contributions}\label{author-contributions}
443+
\begin{enumerate}
444+
$for(authors)$
445+
\item $it.name$ - $it.rolesString$
446+
$endfor$
447+
\end{enumerate}
448+
$endif$
449+
441450
$if(has-frontmatter)$
442451
\backmatter
443452
$endif$

example/paper.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,72 @@ authors:
366366
<!-- given-names: 瀧 -->
367367
<!-- surname: 立花 -->
368368

369+
## Contributor Roles
370+
371+
The [Contribution Role Taxonomy (CRediT)](https://credit.niso.org/contributor-roles) defines
372+
fourteen standard roles of authors. Each author can be annotated with one or more contribution
373+
roles.
374+
375+
1. [conceptualization](https://credit.niso.org/contributor-roles/conceptualization)
376+
2. [data-curation](https://credit.niso.org/contributor-roles/data-curation)
377+
3. [formal-analysis](https://credit.niso.org/contributor-roles/formal-analysis)
378+
4. [funding-acquisition](https://credit.niso.org/contributor-roles/funding-acquisition)
379+
5. [investigation](https://credit.niso.org/contributor-roles/investigation)
380+
6. [methodology](https://credit.niso.org/contributor-roles/methodology)
381+
7. [project-administration](https://credit.niso.org/contributor-roles/project-administration)
382+
8. [resources](https://credit.niso.org/contributor-roles/resources)
383+
9. [software](https://credit.niso.org/contributor-roles/software)
384+
10. [supervision](https://credit.niso.org/contributor-roles/supervision)
385+
11. [validation](https://credit.niso.org/contributor-roles/validation)
386+
12. [visualization](https://credit.niso.org/contributor-roles/visualization)
387+
13. [writing-original-draft](https://credit.niso.org/contributor-roles/writing-original-draft)
388+
14. [writing-review-editing](https://credit.niso.org/contributor-roles/writing-review-editing)
389+
390+
JATS also specifies three degrees which can be used to quantify the impact of a contribution:
391+
392+
1. `Lead`
393+
2. `Supporting`
394+
3. `Equal` - for use if multiple equivalent leads
395+
396+
Together, these can be used to identify which authors materially contributed to the paper,
397+
such as through `formal-analysis` or `data-curation` and which authors contributed immaterially,
398+
such as through `supervision`. It also allows for saying if multiple people made the same
399+
kind of contribution, who took the lead.
400+
401+
```yaml
402+
authors:
403+
- name: John Doe
404+
affiliation: [ 1 ]
405+
roles:
406+
- type: 'formal-analysis'
407+
degree: 'lead'
408+
409+
- name: John Boss
410+
affiliation: [ 1 ]
411+
roles:
412+
- type: 'funding-acquisition'
413+
degree: 'lead'
414+
- type: 'supervision'
415+
degree: 'lead'
416+
```
417+
418+
Roles are optional, and within roles, degrees are optional. It's possible to shorthand
419+
roles by using strings directly:
420+
421+
```yaml
422+
authors:
423+
- name: John Doe
424+
affiliation: [ 1 ]
425+
roles:
426+
- 'formal-analysis'
427+
428+
- name: John Boss
429+
affiliation: [ 1 ]
430+
roles:
431+
- 'funding-acquisition'
432+
- 'supervision'
433+
```
434+
369435
## Affiliations
370436

371437
Each affiliation requires an `index` and `name`.

0 commit comments

Comments
 (0)