Skip to content
Merged
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
21 changes: 21 additions & 0 deletions dqgen/resources/asciidoc_templates/instance.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% raw %}
{% import "macros.adoc" as mc %}
{% endraw %}
{{ "{%" }} set content, error = from_endpoint(conf.default_endpoint).with_query_from_file(conf.query_files["{{ query_file }}"]).fetch_tabular() {{ "%}" }}
{% raw %}
{% if not content.empty %}
{% call mc.render_fetch_results(content, error) %}
{% set compress_uris = simplify_uri_columns_in_tabular(data_frame=content,namespace_inventory=namespaces,error_fail=False) %}
{% endraw %}
== {{ operation|title }} {{ class_name }}s

The table below lists the {{ operation }} *{{ cls }}*

*Query identifier:* {{ query_file }}

{{ "{{" }} mc.pandas_table(content, "{{ operation|title }} {{ class_name }}s") {{ "}}" }}
{% raw %}
{% endcall %}
{% endif %}
{% endraw %}

49 changes: 49 additions & 0 deletions dqgen/resources/asciidoc_templates/main.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{% raw %}
{% extends "layout.adoc" %}
{% import "macros.adoc" as mc %}
{% block content %}
{% endraw %}

This report is automatically generated from the {% raw %}{{ conf.dataset_name }}{% endraw %} RDF dataset on {% raw %}{{ conf.timestamp }}{% endraw %}
and aims at presenting the difference between two versions of an RDFS/OWL vocabulary following the {% raw %}{{ conf.application_profile }}{% endraw %} application profile.

== Report details

*Dataset ID:* {% raw %}{{ conf.dataset_name }}{% endraw %}

*Dataset name:* {% raw %}{{ conf.original_name }}{% endraw %}

*Old version file:* {% raw %}{{ conf.old_version_file }}{% endraw %}

*New version file:* {% raw %}{{ conf.new_version_file }}{% endraw %}

*Time:* {% raw %}{{ conf.timestamp }}{% endraw %}

*Application profile:* {% raw %}{{ conf.application_profile }}{% endraw %}

{% raw %}
{% set namespaces = namespace_inventory({}) %}
{% include "statistics.adoc" %}
{% endraw %}
{% for class_key , class_data in data_source.items() %}
== {{ class_data.label }}
{% if class_data.description is not undefined %}
{{ class_data.description }}
{% endif %}
{% for instance_change_file in class_data.instance_changes.files %}
{{ "{% include " }}"{{ instance_change_file }}"{{ " with context %}" }}
{% endfor %}
{% for prop_group, prop_group_data in class_data.prop_groups.items() %}
=== {{ prop_group_data.label }}
{% for prop_file in prop_group_data.query_template_file_paths %}
{{ "{% include " }}"{{ prop_file }}"{{ " with context %}" }}
{% endfor %}
{% endfor %}
{% endfor %}
{% raw %}
== Prefixes

{{ mc.render_namespaces(namespaces.namespaces_as_dict()) }}
{% endblock %}
{% endraw %}

21 changes: 21 additions & 0 deletions dqgen/resources/asciidoc_templates/property.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% raw %}
{% import "macros.adoc" as mc %}
{% endraw %}
{{ "{%" }} set content, error = from_endpoint(conf.default_endpoint).with_query_from_file(conf.query_files["{{ query_file }}"]).fetch_tabular() {{ "%}" }}
{% raw %}
{% if not content.empty %}
{% call mc.render_fetch_results(content, error) %}
{% set compress_uris = simplify_uri_columns_in_tabular(data_frame=content,namespace_inventory=namespaces,error_fail=False) %}
{% endraw %}
=== {{ operation|title }} {{ property_name }}

The table below lists the {{ operation }} *{{ property }}*

*Query identifier:* {{ query_file }}

{{ "{{" }} mc.pandas_table(content, "{{ operation|title }} {{ property_name }}") {{ "}}" }}
{% raw %}
{% endcall %}
{% endif %}
{% endraw %}

21 changes: 21 additions & 0 deletions dqgen/resources/asciidoc_templates/reified_property.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% raw %}
{% import "macros.adoc" as mc %}
{% endraw %}
{{ "{%" }} set content, error = from_endpoint(conf.default_endpoint).with_query_from_file(conf.query_files["{{ query_file }}"]).fetch_tabular() {{ "%}" }}
{% raw %}
{% if not content.empty %}
{% call mc.render_fetch_results(content, error) %}
{% set compress_uris = simplify_uri_columns_in_tabular(data_frame=content,namespace_inventory=namespaces,error_fail=False) %}
{% endraw %}
=== {{ operation|title }} reified {{ property_name }}

The table below lists the {{ operation }} *{{ property }} / {{ object_property }}*

*Query identifier:* {{ query_file }}

{{ "{{" }} mc.pandas_table(content, "{{ operation|title }} reified {{ property_name }}") {{ "}}" }}
{% raw %}
{% endcall %}
{% endif %}
{% endraw %}

7 changes: 7 additions & 0 deletions dqgen/resources/asciidoc_templates/static/layout.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% raw %}
= {{ conf.title }}

{% block content %}
{% endblock %}
{% endraw %}

80 changes: 80 additions & 0 deletions dqgen/resources/asciidoc_templates/static/macros.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{# Default way of showing errors #}
{% macro render_error(message) -%}
[NOTE]
====
*Error*

{{ message|e }}
====
{%- endmacro %}

{# Default macro for showing/wrapping the fetch results #}
{% macro render_fetch_results(content, error) -%}
{% if error %}
{{ render_error(error) }}
{% else %}
{% if content is undefined %}
{{ render_error("Some content expected but none was found.") }}
{% else %}
{{ caller() }}
{% endif %}
{% endif %}
{%- endmacro %}


{% macro pandas_table(df, caption, column_labels={}) -%}
{% if (df is defined) and (df is not none) %}
{% set df = df.fillna(value="") %}
[cols="{{ df.columns|length }}*", options="header"]
|===
{% for column in df.columns %}
{% if column in column_labels %}
|{{ column_labels[column] }}
{% else %}
|{{ column }}
{% endif %}
{% endfor %}

{% for idx, row in df.iterrows() %}
{% for colname in df.columns %}
{# handle decimal format: float, float64, float32 #}
{% if 'float' in (df.dtypes[colname] | string) %}
|{{ row[colname] | round(precision=2) }}
{% else %}
|{{ row[colname] }}
{% endif %}
{% endfor %}

{% endfor %}
|===

.{{ caption }}
{% else %}
{{ render_error("How did you get here? did you forget to use 'render_fetch_results' macro?") }}
{% endif %}
{%- endmacro %}

{% macro count_value(df) %}
{% for idx, row in df.iterrows() %}
{% for colname in df.columns %}
|{{ row[colname] }}
{% endfor %}
{% endfor %}
{% endmacro %}

{% macro render_namespaces(namesapces_dist) %}
[cols="1,3", options="header"]
|===
|Namespace
|URI

{% for prefix, uri in namesapces_dist|dictsort %}
|{{ prefix }}
|{{ uri }}

{% endfor %}
|===

.Prefixes
{% endmacro %}

57 changes: 57 additions & 0 deletions dqgen/resources/asciidoc_templates/statistics.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{% raw %}
{% import "macros.adoc" as mc %}
{% endraw %}
== Statistics

{% for class_key , class_data in data_source.items() %}
=== {{ class_data.label }}
{% if class_data.description is not undefined %}
{{ class_data.description }}
{% endif %}

[cols="1,1,1", options="header"]
|===
|Instance
|Added
|Deleted

|{{ class_data.label }}
{% for count_query in class_data.instance_changes.count_queries %}
{{ "{%" }} set content, error = from_endpoint(conf.default_endpoint).with_query_from_file(conf.query_files["{{ count_query }}"]).fetch_tabular() {{ "%}" }}
{% raw %}
{% call mc.render_fetch_results(content, error) %}
{{ mc.count_value(content) }}
{% endcall %}
{% endraw %}
{% endfor %}
|===

[cols="1,1,1,1,1,1,1", options="header"]
|===
|Property group
|Property
|Added
|Deleted
|Updated
|Moved
|Changed
{% for prop_group, prop_group_data in class_data.prop_groups.items() %}
{% set prop_group_name = prop_group_data.label %}
{% for index ,count_prop_section in prop_group_data.count_queries.items() %}

|{{ prop_group_name }}
|{{ count_prop_section.label }}
{% for query_file in count_prop_section.files %}
{{ "{%" }} set content, error = from_endpoint(conf.default_endpoint).with_query_from_file(conf.query_files["{{ query_file }}"]).fetch_tabular() {{ "%}" }}
{% raw %}
{% call mc.render_fetch_results(content, error) %}
{{ mc.count_value(content) }}
{% endcall %}
{% endraw %}
{% endfor %}
{% endfor %}
{% endfor %}
|===

{% endfor %}