Skip to content

Commit 635c01a

Browse files
committed
Refresh docs
1 parent 2ec4c2a commit 635c01a

22 files changed

+989
-700
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Copyright CNRS 2019-2025
1111
**fairgraph** is a Python library for working with metadata
1212
in the EBRAINS Knowledge Graph, with a particular focus on data reuse,
1313
although it is also useful in metadata registration/curation.
14-
The API is not stable, and is subject to change.
1514

1615
## Installation
1716

@@ -161,14 +160,14 @@ For those users who have the necessary permissions to store and edit metadata in
161160
**fairgraph** objects can be created or edited in Python, and then saved back to the Knowledge Graph, e.g.:
162161

163162
```
164-
from datetime import datetime
163+
from datetime import date
165164
from fairgraph.openminds.core import Person, Organization, Affiliation
166165
167-
mgm = Organization(name="Metro-Goldwyn-Mayer", alias="MGM")
166+
mgm = Organization(full_name="Metro-Goldwyn-Mayer", short_name="MGM")
168167
mgm.save(client, space="myspace")
169168
170-
affiliation = Affiliation(organization=mgm, start_date=datetime(1942, 1, 1))
171-
author = Person(family_name="Laurel", given_name="Stan", affiliations=affiliation)
169+
affiliation = Affiliation(member_of=mgm, start_date=date(1941, 2, 23))
170+
author = Person(family_name="Laurel", given_name="Stan", affiliations=[affiliation])
172171
author.save(client, space="myspace")
173172
```
174173

codemeta.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@
3737
"givenName": "Andrew P.",
3838
"familyName": "Davison",
3939
"affiliation": {
40-
"@id": "https://ror.org/02feahw73"
40+
"@id": "https://ror.org/002v40q27"
4141
}
4242
},
4343
{
4444
"@type": "Person",
4545
"givenName": "Onur",
4646
"familyName": "Ates",
4747
"affiliation": {
48-
"@id": "https://ror.org/02feahw73"
48+
"@id": "https://ror.org/002v40q27"
4949
}
5050
},
5151
{
5252
"@type": "Person",
5353
"givenName": "Yann",
5454
"familyName": "Zerlaut",
5555
"affiliation": {
56-
"@id": "https://ror.org/02feahw73"
56+
"@id": "https://ror.org/002v40q27"
5757
}
5858
},
5959
{
@@ -69,15 +69,15 @@
6969
"givenName": "Glynis",
7070
"familyName": "Mattheisen",
7171
"affiliation": {
72-
"@id": "https://ror.org/02feahw73"
72+
"@id": "https://ror.org/002v40q27"
7373
}
7474
},
7575
{
7676
"@type": "Person",
7777
"givenName": "Peyman",
7878
"familyName": "Najafi",
7979
"affiliation": {
80-
"@id": "https://ror.org/02feahw73"
80+
"@id": "https://ror.org/002v40q27"
8181
}
8282
}
8383
]

doc/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ BUILDDIR = _build
1111
help:
1212
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1313

14+
authors.rst:
15+
python build_authors.py
16+
1417
.PHONY: help Makefile
1518

1619
# Catch-all target: route all unknown targets to Sphinx using the new
1720
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
18-
%: Makefile
21+
%: Makefile authors.rst
1922
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

doc/_static/custom.css

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#content ul:not(.search) {
2+
list-style-type: disc;
3+
margin-left: 1.5rem;
4+
margin-top: 0.8rem;
5+
}
6+
7+
#content ul:not(.search) p,
8+
#content ul:not(.search)>li {
9+
margin-top: 0.8rem
10+
}
11+
12+
#content section>p {
13+
line-height: 1.75rem;
14+
margin-top: 0.8rem
15+
}
16+
17+
.contents,
18+
.toctree-wrapper {
19+
font-size: 1rem;
20+
line-height: 1.25rem
21+
}
22+
23+
.contents ul li a.reference,
24+
.toctree-wrapper ul li a.reference {
25+
color: hsl(var(--foreground)) !important;
26+
display: inline-block;
27+
font-weight: 600 !important;
28+
text-decoration-line: none !important;
29+
transition-duration: .15s;
30+
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
31+
transition-timing-function: cubic-bezier(.4, 0, .2, 1)
32+
}

doc/api_reference.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
API reference
33
=============
44

5+
All Python classes that represent openMINDS metadata, such as :class:`~fairgraph.openminds.core.Dataset`,
6+
inherit from either :class:`~fairgraph.KGObject` (if the object has its own "id" attribute)
7+
or from :class:`~fairgraph.EmbeddedMetadata` (if the object should be embedded inside another object,
8+
without its own id.)
9+
10+
These base classes are documented here, along with :class:`~fairgraph.KGProxy`, :class:`~fairgraph.KGQuery`,
11+
:class:`~fairgraph.KGClient`, and various utility classes and functions.
12+
513
KGObject
614
========
715

@@ -10,6 +18,14 @@ KGObject
1018
:inherited-members:
1119
:show-inheritance:
1220

21+
LinkedMetadata
22+
==============
23+
24+
.. autoclass:: openminds.base.LinkedMetadata
25+
:members:
26+
:inherited-members:
27+
:show-inheritance:
28+
1329
EmbeddedMetadata
1430
================
1531

doc/authors.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
"@id": "http://orcid.org/0000-0002-4793-7541",
55
"givenName": "Andrew P.",
66
"familyName": "Davison",
7-
"affiliation": [{"@id": "https://ror.org/02feahw73"}]
7+
"affiliation": [{"@id": "https://ror.org/002v40q27"}]
88
},
99
{
1010
"@type": "Person",
1111
"givenName": "Onur",
1212
"familyName": "Ates",
13-
"affiliation": [{"@id": "https://ror.org/02feahw73"}]
13+
"affiliation": [{"@id": "https://ror.org/002v40q27"}]
1414
},
1515
{
1616
"@type": "Person",
1717
"givenName": "Yann",
1818
"familyName": "Zerlaut",
19-
"affiliation": [{"@id": "https://ror.org/02feahw73"}]
19+
"affiliation": [{"@id": "https://ror.org/002v40q27"}]
2020
},
2121
{
2222
"@type": "Person",
@@ -28,12 +28,12 @@
2828
"@type": "Person",
2929
"givenName": "Glynis",
3030
"familyName": "Mattheisen",
31-
"affiliation": [{"@id": "https://ror.org/02feahw73"}]
31+
"affiliation": [{"@id": "https://ror.org/002v40q27"}]
3232
},
3333
{
3434
"@type": "Person",
3535
"givenName": "Peyman",
3636
"familyName": "Najafi",
37-
"affiliation": [{"@id": "https://ror.org/02feahw73"}]
37+
"affiliation": [{"@id": "https://ror.org/002v40q27"}]
3838
}
3939
]

doc/authors.rst

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@ Authors / contributors
44

55
The following people have contributed to fairgraph. Their affiliations at the time of the contributions are shown below.
66

7-
- Andrew Davison [1]
7+
- Andrew P. Davison [1]
88
- Onur Ates [1]
99
- Yann Zerlaut [1]
1010
- Nico Feld [2]
11-
- Glynis Mattheisen[1]
11+
- Glynis Mattheisen [1]
1212
- Peyman Najafi [1]
1313

14-
1. Department of Integrative and Computational Neuroscience, Paris-Saclay Institute of Neuroscience, CNRS/Université Paris Saclay
15-
2. Human-Computer Interaction, Department IV, Computer Science, Universität Trier
16-
14+
1. Paris-Saclay Institute of Neuroscience, Université Paris-Saclay, Centre National de la Recherche Scientifique, Saclay, France
15+
2. Trier University, Trier, Germany
1716

1817
Acknowledgements
1918
================
@@ -25,5 +24,7 @@ Acknowledgements
2524
:align: right
2625

2726
This open source software code was developed in part or in whole in the Human Brain Project,
28-
funded from the European Union's Horizon 2020 Framework Programme for Research and Innovation
29-
under Specific Grant Agreements No. 720270, No. 785907 and No. 945539 (Human Brain Project SGA1, SGA2 and SGA3).
27+
funded from the European Union's Horizon 2020 Framework Programme for Research and Innovation under
28+
Specific Grant Agreements No. 720270, No. 785907 and No. 945539 (Human Brain Project SGA1, SGA2 and SGA3)
29+
and in the EBRAINS research infrastructure, funded from the European Union's Horizon Europe funding programme
30+
under grant agreement No. 101147319 (EBRAINS-2.0).

doc/authors.rst.tpl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
======================
2+
Authors / contributors
3+
======================
4+
5+
The following people have contributed to fairgraph. Their affiliations at the time of the contributions are shown below.
6+
7+
{authors}
8+
9+
{affiliations}
10+
11+
Acknowledgements
12+
================
13+
14+
.. image:: https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Flag_of_Europe.svg/320px-Flag_of_Europe.svg.png
15+
:alt: EU Logo
16+
:height: 100px
17+
:width: 150px
18+
:align: right
19+
20+
This open source software code was developed in part or in whole in the Human Brain Project,
21+
funded from the European Union's Horizon 2020 Framework Programme for Research and Innovation under
22+
Specific Grant Agreements No. 720270, No. 785907 and No. 945539 (Human Brain Project SGA1, SGA2 and SGA3)
23+
and in the EBRAINS research infrastructure, funded from the European Union's Horizon Europe funding programme
24+
under grant agreement No. 101147319 (EBRAINS-2.0).

doc/build_authors.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""
2+
Script to build the authors.rst file
3+
"""
4+
5+
import json
6+
import requests
7+
from pathlib import Path
8+
9+
def full_name(au):
10+
return f"{au['givenName']} {au['familyName']}"
11+
12+
with open("authors.json") as fp:
13+
author_data = json.load(fp)
14+
author_list = ", ".join(f"{full_name(au)}" for au in author_data)
15+
16+
with open("authors.rst.tpl") as fp:
17+
template = fp.read()
18+
19+
affiliation_ids = []
20+
for person in author_data:
21+
for affil in person["affiliation"]:
22+
if affil["@id"] not in affiliation_ids:
23+
affiliation_ids.append(affil["@id"])
24+
25+
cache_path = ".rorid_cache"
26+
27+
if not Path(cache_path).exists():
28+
affiliation_data = {}
29+
for affil_id in affiliation_ids:
30+
response = requests.get(f"https://api.ror.org/v2/organizations/{affil_id.split('/')[-1]}")
31+
if response.status_code == 200:
32+
affiliation_data[affil_id] = response.json()
33+
else:
34+
print(response)
35+
with open(cache_path, "w") as fp:
36+
json.dump(affiliation_data, fp, indent=2)
37+
else:
38+
with open(cache_path) as fp:
39+
affiliation_data = json.load(fp)
40+
41+
42+
def get_affiliation_text(org):
43+
name = [entry["value"] for entry in org["names"] if entry["lang"] == "en" and "label" in entry["types"]][0]
44+
location = org["locations"][0]["geonames_details"]
45+
city = location["name"]
46+
country = location["country_name"]
47+
parents = [rel["label"] for rel in org["relationships"] if rel["type"] == "parent"]
48+
if parents:
49+
return f"{name}, {', '.join(parents)}, {city}, {country}"
50+
else:
51+
return f"{name}, {city}, {country}"
52+
53+
def affiliation_number(au, affiliations):
54+
index = list(affiliations.keys()).index(au["affiliation"][0]["@id"]) # to do: handle people with multiple affiliations
55+
return index + 1
56+
57+
58+
affiliations_text = "\n".join(
59+
f"{i}. {get_affiliation_text(affiliation_data[org_id])}" for i, org_id in enumerate(affiliation_data, start=1)
60+
)
61+
62+
authors_text = "\n".join(
63+
[f"- {full_name(au)} [{affiliation_number(au, affiliation_data)}]" for au in author_data]
64+
)
65+
66+
with open("authors.rst", "w") as fp:
67+
fp.write(template.format(authors=authors_text, affiliations=affiliations_text))

0 commit comments

Comments
 (0)