Skip to content

Commit f0eb3b0

Browse files
authored
[DOC] render library listing in doc (#505)
* [DATALAD] Added subdataset * lib in doc
1 parent 0d35c95 commit f0eb3b0

13 files changed

+145
-164
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
activities/.DS_Store
33
protocols/.DS_Store
44

5+
__pycache__
6+
57
.idea/
68

79
node_modules

.gitmodules

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "library"]
2+
path = library
3+
url = https://github.com/ReproNim/reproschema-library.git
4+
datalad-url = https://github.com/ReproNim/reproschema-library.git

docs/FAQ.md

-11
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,6 @@ once you have opened that page on github that will open this URL:
5353
If you want to visualize the graph represented by the JSON-LD file,
5454
we explain how to do this in [From JSON to JSON-LD](#from-json-to-json-ld).
5555

56-
57-
### Which assessments tools will/are supporting this standard?
58-
59-
At the moment, all the assessments that support this standard are listed in [this folder](https://github.com/ReproNim/reproschema-library/tree/master/activities) or the [reproschema-library repository](https://github.com/ReproNim/reproschema-library).
60-
61-
If you want to see those different tools in action using our user interface,
62-
you can explore them on [schema.repronim.org/](https://schema.repronim.org/rl/).
63-
64-
The ReproSchema is also used to develop a checklist to [improve methods and results reporting in neuroimaging](https://github.com/ohbm/cobidas).
65-
66-
6756
## Linked data and semantic web
6857

6958
## What is the semantic web?

docs/library.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
hide:
3+
- toc
4+
---
5+
# Reproschema library
6+
7+
At the moment, all the assessments that support this standard are listed in [this folder](https://github.com/ReproNim/reproschema-library/tree/master/activities) of the [reproschema-library repository](https://github.com/ReproNim/reproschema-library).
8+
9+
For convenience we are listing them in the table below.
10+
11+
If you want to see those different tools in action using our user interface,
12+
you can explore them on [schema.repronim.org/](https://schema.repronim.org/rl/).
13+
14+
{{ MACROS___library_table() }}

docs/project-structure.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ questionnaire for your next participant or patient. Also you can mix and match
5151
items from this library, knowing that the information is tracked in your protocol.
5252

5353
All assessments are listed in [the `activity` folder](https://github.com/ReproNim/reproschema-library/tree/master/activities)
54-
and are served [here](https://schema.repronim.org/rl/) if you want to visualize
55-
them.
54+
and are served [here](https://schema.repronim.org/rl/) if you want to visualize them.
5655

5756
- **Standard Alignment:** Each element in the library aligns with the ReproSchema framework, ensuring uniformity in terms and structure and upholding validation protocols for consistency across the ecosystem.
5857
- **Research Protocol Integration:** Researchers can utilize these assessments in various combinations to align with specific protocol needs, customizing their application per study objectives. This process can be integrated using the reproschema-protocol-cookiecutter for constructing user interfaces.

docs/tutorials/collecting-demographics-information.md

-148
This file was deleted.

library

Submodule library added at 9be140d

macros/__init__.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from .macros import (
2+
library_table,
3+
)
4+
from .main import define_env
5+
6+
__all__ = [
7+
"define_env",
8+
"library_table",
9+
]

macros/macros.py

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from pathlib import Path
2+
import json
3+
4+
import ruamel.yaml
5+
from jinja2 import Environment, FileSystemLoader, select_autoescape
6+
7+
yaml = ruamel.yaml.YAML()
8+
yaml.indent(mapping=2, sequence=4, offset=2)
9+
10+
ROOT = Path(__file__).parents[1]
11+
12+
TEMPLATES_DIR = ROOT / "templates"
13+
14+
LIBRARY_DIR = ROOT / "library"
15+
16+
SCHEMA_DIR = ROOT / "linkml-schema"
17+
18+
19+
def return_jinja_env() -> Environment:
20+
return Environment(
21+
loader=FileSystemLoader(TEMPLATES_DIR),
22+
autoescape=select_autoescape(),
23+
lstrip_blocks=True,
24+
trim_blocks=True,
25+
)
26+
27+
28+
def library_table() -> str:
29+
30+
LIBRARY_URL = "https://github.com/ReproNim/reproschema-library"
31+
32+
activities = []
33+
34+
for activity_path in (LIBRARY_DIR / "activities").iterdir():
35+
36+
if not activity_path:
37+
continue
38+
39+
for file in activity_path.glob("*"):
40+
41+
if file.is_dir() or file is None or "valueConstraints" in file.stem:
42+
continue
43+
44+
with open(file) as f:
45+
content = json.load(f)
46+
47+
activities.append(
48+
{
49+
"name": content["@id"],
50+
"description": (
51+
content["description"] if "description" in content else ""
52+
),
53+
"uri": f"{LIBRARY_URL}/tree/master/activities/{activity_path.stem}/{file.stem}{file.suffix}",
54+
}
55+
)
56+
57+
env = return_jinja_env()
58+
template = env.get_template("library_table.jinja")
59+
60+
return template.render(activities=activities)
61+
62+
63+
def main():
64+
print(library_table())
65+
66+
67+
if __name__ == "__main__":
68+
main()

macros/main.py

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""This package is used to build elements from data into
2+
MarkDown format for the specification text.
3+
4+
Functions decorated in "define_env()" are callable throughout the
5+
specification and are run/rendered with the mkdocs plugin "macros".
6+
"""
7+
8+
import os
9+
import sys
10+
11+
code_path = os.path.abspath(os.path.join(os.path.dirname(__file__)))
12+
sys.path.append(code_path)
13+
14+
import macros # noqa E402
15+
16+
17+
def define_env(env):
18+
"""Define variables, macros and filters for the mkdocs-macros plugin.
19+
20+
Parameters
21+
----------
22+
env : :obj:`macros.plugin.MacrosPlugin`
23+
An object in which to inject macros, variables, and filters.
24+
25+
Notes
26+
-----
27+
"variables" are the dictionary that contains the environment variables
28+
"macro" is a decorator function, to declare a macro.
29+
30+
Macro aliases must start with "MACROS___"
31+
"""
32+
env.macro(macros.library_table, "MACROS___library_table")

mkdocs.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ nav:
5454
- Create new items: "tutorials/create-new-items.md"
5555
- Finalize the protocol: "tutorials/finalizing-the-protocol.md"
5656
- Translate a questionnaire: "tutorials/translating-an-activity.md"
57-
- Demographic information : "tutorials/collecting-demographics-information.md"
58-
- Tips to make your life easier: "tutorials/tips-to-make-your-life-easier.md"
57+
- Tips: tutorials/tips-to-make-your-life-easier.md
58+
- Library: library.md
5959
- FAQ: "FAQ.md"
6060
- Contributing: "CONTRIBUTING.md"
6161

@@ -75,12 +75,16 @@ markdown_extensions:
7575
- pymdownx.snippets:
7676
auto_append:
7777
- includes/abbreviations.md
78+
- tables
7879
- toc:
7980
anchorlink: true
8081

8182
watch:
8283
- includes
84+
- linkml-schema
8385

8486
plugins:
8587
- search
8688
- tags
89+
- macros:
90+
module_name: macros/main

requirements.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
rdflib==5.0.0
1+
mkdocs-macros-plugin
22
mkdocs-material
33
pymdown-extensions
4+
rdflib==5.0.0
5+
ruamel.yaml

templates/library_table.jinja

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
| Activity | Description | URI |
2+
| :------ | :---------- | :-- |
3+
{% for activity in activities %}
4+
| {{ activity.name }} | {{ activity.description }} | [link]({{ activity.uri }}) |
5+
{% endfor %}

0 commit comments

Comments
 (0)