-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOC] render library listing in doc (#505)
* [DATALAD] Added subdataset * lib in doc
- Loading branch information
Showing
13 changed files
with
145 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
activities/.DS_Store | ||
protocols/.DS_Store | ||
|
||
__pycache__ | ||
|
||
.idea/ | ||
|
||
node_modules | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |