Skip to content

Commit

Permalink
[DOC] render library listing in doc (#505)
Browse files Browse the repository at this point in the history
* [DATALAD] Added subdataset

* lib in doc
  • Loading branch information
Remi-Gau authored Jun 20, 2024
1 parent 0d35c95 commit f0eb3b0
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 164 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
activities/.DS_Store
protocols/.DS_Store

__pycache__

.idea/

node_modules
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "library"]
path = library
url = https://github.com/ReproNim/reproschema-library.git
datalad-url = https://github.com/ReproNim/reproschema-library.git
11 changes: 0 additions & 11 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@ once you have opened that page on github that will open this URL:
If you want to visualize the graph represented by the JSON-LD file,
we explain how to do this in [From JSON to JSON-LD](#from-json-to-json-ld).


### Which assessments tools will/are supporting this standard?

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).

If you want to see those different tools in action using our user interface,
you can explore them on [schema.repronim.org/](https://schema.repronim.org/rl/).

The ReproSchema is also used to develop a checklist to [improve methods and results reporting in neuroimaging](https://github.com/ohbm/cobidas).


## Linked data and semantic web

## What is the semantic web?
Expand Down
14 changes: 14 additions & 0 deletions docs/library.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
hide:
- toc
---
# Reproschema library

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).

For convenience we are listing them in the table below.

If you want to see those different tools in action using our user interface,
you can explore them on [schema.repronim.org/](https://schema.repronim.org/rl/).

{{ MACROS___library_table() }}
3 changes: 1 addition & 2 deletions docs/project-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ questionnaire for your next participant or patient. Also you can mix and match
items from this library, knowing that the information is tracked in your protocol.

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

- **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.
- **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.
Expand Down
148 changes: 0 additions & 148 deletions docs/tutorials/collecting-demographics-information.md

This file was deleted.

1 change: 1 addition & 0 deletions library
Submodule library added at 9be140
9 changes: 9 additions & 0 deletions macros/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .macros import (
library_table,
)
from .main import define_env

__all__ = [
"define_env",
"library_table",
]
68 changes: 68 additions & 0 deletions macros/macros.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from pathlib import Path
import json

import ruamel.yaml
from jinja2 import Environment, FileSystemLoader, select_autoescape

yaml = ruamel.yaml.YAML()
yaml.indent(mapping=2, sequence=4, offset=2)

ROOT = Path(__file__).parents[1]

TEMPLATES_DIR = ROOT / "templates"

LIBRARY_DIR = ROOT / "library"

SCHEMA_DIR = ROOT / "linkml-schema"


def return_jinja_env() -> Environment:
return Environment(
loader=FileSystemLoader(TEMPLATES_DIR),
autoescape=select_autoescape(),
lstrip_blocks=True,
trim_blocks=True,
)


def library_table() -> str:

LIBRARY_URL = "https://github.com/ReproNim/reproschema-library"

activities = []

for activity_path in (LIBRARY_DIR / "activities").iterdir():

if not activity_path:
continue

for file in activity_path.glob("*"):

if file.is_dir() or file is None or "valueConstraints" in file.stem:
continue

with open(file) as f:
content = json.load(f)

activities.append(
{
"name": content["@id"],
"description": (
content["description"] if "description" in content else ""
),
"uri": f"{LIBRARY_URL}/tree/master/activities/{activity_path.stem}/{file.stem}{file.suffix}",
}
)

env = return_jinja_env()
template = env.get_template("library_table.jinja")

return template.render(activities=activities)


def main():
print(library_table())


if __name__ == "__main__":
main()
32 changes: 32 additions & 0 deletions macros/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""This package is used to build elements from data into
MarkDown format for the specification text.
Functions decorated in "define_env()" are callable throughout the
specification and are run/rendered with the mkdocs plugin "macros".
"""

import os
import sys

code_path = os.path.abspath(os.path.join(os.path.dirname(__file__)))
sys.path.append(code_path)

import macros # noqa E402


def define_env(env):
"""Define variables, macros and filters for the mkdocs-macros plugin.
Parameters
----------
env : :obj:`macros.plugin.MacrosPlugin`
An object in which to inject macros, variables, and filters.
Notes
-----
"variables" are the dictionary that contains the environment variables
"macro" is a decorator function, to declare a macro.
Macro aliases must start with "MACROS___"
"""
env.macro(macros.library_table, "MACROS___library_table")
8 changes: 6 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ nav:
- Create new items: "tutorials/create-new-items.md"
- Finalize the protocol: "tutorials/finalizing-the-protocol.md"
- Translate a questionnaire: "tutorials/translating-an-activity.md"
- Demographic information : "tutorials/collecting-demographics-information.md"
- Tips to make your life easier: "tutorials/tips-to-make-your-life-easier.md"
- Tips: tutorials/tips-to-make-your-life-easier.md
- Library: library.md
- FAQ: "FAQ.md"
- Contributing: "CONTRIBUTING.md"

Expand All @@ -75,12 +75,16 @@ markdown_extensions:
- pymdownx.snippets:
auto_append:
- includes/abbreviations.md
- tables
- toc:
anchorlink: true

watch:
- includes
- linkml-schema

plugins:
- search
- tags
- macros:
module_name: macros/main
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
rdflib==5.0.0
mkdocs-macros-plugin
mkdocs-material
pymdown-extensions
rdflib==5.0.0
ruamel.yaml
5 changes: 5 additions & 0 deletions templates/library_table.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
| Activity | Description | URI |
| :------ | :---------- | :-- |
{% for activity in activities %}
| {{ activity.name }} | {{ activity.description }} | [link]({{ activity.uri }}) |
{% endfor %}

0 comments on commit f0eb3b0

Please sign in to comment.