Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add doc-templates folder for jinja templates #13

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions {{cookiecutter.project_name}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ SRC = src
DEST = project
PYMODEL = $(SRC)/$(SCHEMA_NAME)/datamodel
DOCDIR = docs
DOCTEMPLATESDIR = doc-templates
EXAMPLEDIR = examples
SHEET_MODULE = {{cookiecutter.__google_sheet_module}}
SHEET_ID = $(shell sh ./utils/get-value.sh google_sheet_id)
Expand Down Expand Up @@ -126,9 +127,9 @@ $(PYMODEL):
$(DOCDIR):
mkdir -p $@

gendoc: $(DOCDIR)
gendoc: $(DOCDIR) $(DOCTEMPLATESDIR)
cp $(SRC)/docs/*md $(DOCDIR) ; \
$(RUN) gen-doc -d $(DOCDIR) $(SOURCE_SCHEMA_PATH)
$(RUN) gen-doc -d $(DOCDIR) $(SOURCE_SCHEMA_PATH) --template-directory $(DOCTEMPLATESDIR)

testdoc: gendoc serve

Expand Down
145 changes: 145 additions & 0 deletions {{cookiecutter.project_name}}/src/doc-templates/class.md.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Class: {{ gen.name(element) }}

{%- if header -%}
{{header}}
{%- endif -%}


{% if element.description %}
_{{ element.description }}_
{% endif %}

{% if element.abstract %}
* __NOTE__: this is an abstract class and should not be instantiated directly
{% endif %}
{% if element.mixin %}
* __NOTE__: this is a mixin class intended to be used in combination with other classes, and not used directly
{% endif %}

URI: {{ gen.uri_link(element) }}



{% if schemaview.class_parents(element.name) and schemaview.class_children(element.name) %}
```{{ gen.mermaid_directive() }}
classDiagram
class {{ gen.name(element) }}
{% for s in schemaview.class_parents(element.name)|sort(attribute='name') -%}
{{ gen.name(schemaview.get_element(s)) }} <|-- {{ gen.name(element) }}
{% endfor %}
{% for s in schemaview.class_induced_slots(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} : {{gen.name(s)}}
{% endfor %}

{% for s in schemaview.class_children(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} <|-- {{ gen.name(schemaview.get_element(s)) }}
{% endfor %}
{% for s in schemaview.class_induced_slots(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} : {{gen.name(s)}}
{% endfor %}
```
{% elif schemaview.class_parents(element.name) %}
```{{ gen.mermaid_directive() }}
classDiagram
class {{ gen.name(element) }}
{% for s in schemaview.class_parents(element.name)|sort(attribute='name') -%}
{{ gen.name(schemaview.get_element(s)) }} <|-- {{ gen.name(element) }}
{% endfor %}
{% for s in schemaview.class_induced_slots(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} : {{gen.name(s)}}
{% endfor %}
```
{% elif schemaview.class_children(element.name) %}
```{{ gen.mermaid_directive() }}
classDiagram
class {{ gen.name(element) }}
{% for s in schemaview.class_children(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} <|-- {{ gen.name(schemaview.get_element(s)) }}
{% endfor %}
{% for s in schemaview.class_induced_slots(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} : {{gen.name(s)}}
{% endfor %}
```
{% else %}
```{{ gen.mermaid_directive() }}
classDiagram
class {{ gen.name(element) }}
{% for s in schemaview.class_induced_slots(element.name)|sort(attribute='name') -%}
{{ gen.name(element) }} : {{gen.name(s)}}
{% endfor %}
```
{% endif %}


{% if schemaview.class_parents(element.name) or schemaview.class_children(element.name, mixins=False) %}

## Inheritance
{{ gen.inheritance_tree(element, mixins=True) }}
{% else %}
<!-- no inheritance hierarchy -->
{% endif %}

## Slots

| Name | Cardinality and Range | Description |
| --- | --- | --- |
{% for s in schemaview.class_induced_slots(element.name) -%}
| {{gen.link(s)}} | {{ gen.cardinality(s) }} <br/> {{gen.link(s.range)}} | {{s.description|enshorten}} |
{% endfor %}

## Usages

{% if schemaview.usage_index().get(element.name) %}
| used by | used in | type | used |
| --- | --- | --- | --- |
{% for usage in schemaview.usage_index().get(element.name) -%}
| {{gen.link(usage.used_by)}} | {{gen.link(usage.slot)}} | {{usage.metaslot}} | {{usage.used }} |
{% endfor %}
{% endif %}

{% include "common_metadata.md.jinja2" %}


{% if element.rules or element.classification_rules %}

## Rules

{% endif %}

{% if schemaview.get_mappings(element.name).items() -%}
## Mappings

| Mapping Type | Mapped Value |
| --- | --- |
{% for m, mt in schemaview.get_mappings(element.name).items() -%}
{% if mt|length > 0 -%}
| {{ m }} | {{ mt }} |
{% endif -%}
{% endfor %}

{% endif -%}


## LinkML Specification

<!-- TODO: investigate https://stackoverflow.com/questions/37606292/how-to-create-tabbed-code-blocks-in-mkdocs-or-sphinx -->

### Direct

<details>
```yaml
{{gen.yaml(element)}}
```
</details>

### Induced

<details>
```yaml
{{gen.yaml(element, inferred=True)}}
```
</details>

{%- if footer -%}
{{footer}}
{%- endif -%}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{% if element.comments -%}
## Comments

{% for x in element.comments -%}
* {{x}}
{% endfor %}
{% endif -%}

{% if element.todos -%}
## TODOs

{% for x in element.todos -%}
* {{x}}
{% endfor %}
{% endif -%}

## Identifier and Mapping Information

{% if element.id_prefixes %}
### Valid ID Prefixes

Instances of this class *should* have identifiers with one of the following prefixes:
{% for p in element.id_prefixes %}
* {{p}}
{% endfor %}

{% endif %}


{% if element.annotations %}
### Annotations

| property | value |
| --- | --- |
{% for a in element.annotations -%}
| {{a}} | {{ element.annotations[a].value }} |
{% endfor %}
{% endif %}

{% if element.from_schema or element.imported_from %}
### Schema Source

{% if element.from_schema %}
* from schema: {{ element.from_schema }}
{% endif %}
{% if element.imported_from %}
* imported from: {{ element.imported_from }}
{% endif %}
{% endif %}
28 changes: 28 additions & 0 deletions {{cookiecutter.project_name}}/src/doc-templates/enum.md.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# {{ gen.name(element) }}

{{ element.description }}

URI: {{ gen.uri(element) }}

{% if element.permissible_values -%}
## Permissible Values

| Value | Meaning | Description | Info |
| --- | --- | --- | --- |
{% for pv in element.permissible_values.values() -%}
| {{pv.text}} | {{pv.meaning}} | {{pv.description|enshorten}} | |
{% endfor %}
{% else %}
_This is a dynamic enum_
{% endif %}

{% include "common_metadata.md.jinja2" %}

## Schema

<details>
```yaml
{{gen.yaml(element)}}
```
</details>

46 changes: 46 additions & 0 deletions {{cookiecutter.project_name}}/src/doc-templates/index.md.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# {% if schema.title %}{{ schema.title }}{% else %}{{ schema.name }}{% endif %}

{{ schema.description }}

URI: {{ schema.id }}
Name: {{ schema.name }}

## Classes

| Class | Description |
| --- | --- |
{% for c in gen.all_class_objects()|sort(attribute=sort_by) -%}
| {{gen.link(c)}} | {{c.description|enshorten}} |
{% endfor %}

## Slots

| Slot | Description |
| --- | --- |
{% for s in gen.all_slot_objects()|sort(attribute=sort_by) -%}
| {{gen.link(s)}} | {{s.description|enshorten}} |
{% endfor %}

## Enumerations

| Enumeration | Description |
| --- | --- |
{% for e in gen.all_enum_objects()|sort(attribute=sort_by) -%}
| {{gen.link(e)}} | {{e.description|enshorten}} |
{% endfor %}

## Types

| Type | Description |
| --- | --- |
{% for t in gen.all_type_objects()|sort(attribute=sort_by) -%}
| {{gen.link(t)}} | {{t.description|enshorten}} |
{% endfor %}

## Subsets

| Subset | Description |
| --- | --- |
{% for ss in schemaview.all_subsets().values()|sort(attribute='name') -%}
| {{gen.link(ss)}} | {{ss.description|enshorten}} |
{% endfor %}
26 changes: 26 additions & 0 deletions {{cookiecutter.project_name}}/src/doc-templates/index.tex.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
\documentclass{article}
\usepackage[utf8]{inputenc}

\title{ {{gen.latex(gen.schema_title())}} }

\begin{document}

{{ schema.description }}

URI: {{ gen.latex(schema.id) }}
Name: {{ gen.latex(schema.name) }}

\subsection{Classes}\label{classes}

\begin{tabular}{ |c|c| }
\hline
Class & Description \\\\
\hline

{% for c in schemaview.all_classes().values()|sort(attribute='name') -%}
{{ gen.latex(c.name) }} & {{ gen.latex(c.description) }} \\\\
{% endfor %}
\hline
\end{tabular}

\end{document}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# {{ schema.name }}

{{ schema.description }}

URI: {{ schema.id }}


Loading