From a7daf485efce48243169a83fbcbf248340e00465 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 26 Nov 2019 16:40:55 +0100 Subject: [PATCH] add basic hugo template --- ansibledoctor/templates/hugo/_meta.j2 | 12 +++++++ ansibledoctor/templates/hugo/_toc.j2 | 14 ++++++++ ansibledoctor/templates/hugo/_vars.j2 | 41 ++++++++++++++++++++++++ ansibledoctor/templates/hugo/index.md.j2 | 17 ++++++++++ 4 files changed, 84 insertions(+) create mode 100644 ansibledoctor/templates/hugo/_meta.j2 create mode 100644 ansibledoctor/templates/hugo/_toc.j2 create mode 100644 ansibledoctor/templates/hugo/_vars.j2 create mode 100644 ansibledoctor/templates/hugo/index.md.j2 diff --git a/ansibledoctor/templates/hugo/_meta.j2 b/ansibledoctor/templates/hugo/_meta.j2 new file mode 100644 index 0000000..c75c2fe --- /dev/null +++ b/ansibledoctor/templates/hugo/_meta.j2 @@ -0,0 +1,12 @@ +{% set meta = role.meta | default({}) %} +{% if meta %} +## Dependencies + +{% if meta | deep_get(meta, "dependencies.value") %} +{% for item in meta.dependencies.value %} +* {{ item }} +{% endfor %} +{% else %} +None. +{% endif %} +{% endif %} diff --git a/ansibledoctor/templates/hugo/_toc.j2 b/ansibledoctor/templates/hugo/_toc.j2 new file mode 100644 index 0000000..660519e --- /dev/null +++ b/ansibledoctor/templates/hugo/_toc.j2 @@ -0,0 +1,14 @@ +## Table of content + +{% set var = role.var | default({}) %} +{% if var %} +* [Default Variables](#default-variables) +{% for key, item in var | dictsort %} + * [{{ key }}](#{{ key }}) +{% endfor %} +{% endif %} +* [Dependencies](#dependencies) +* [License](#license) +* [Author](#author) + +--- diff --git a/ansibledoctor/templates/hugo/_vars.j2 b/ansibledoctor/templates/hugo/_vars.j2 new file mode 100644 index 0000000..43dfd67 --- /dev/null +++ b/ansibledoctor/templates/hugo/_vars.j2 @@ -0,0 +1,41 @@ +{% set var = role.var | default({}) %} +{% if var %} + +## Default Variables +{% for key, item in var | dictsort %} + +### {{ key }} +{% if item.description is defined and item.description %} + +{{ item.description | save_join(" ") | striptags }} +{% endif %} +{% if item.value is defined and item.value %} + +#### Default value + +```YAML +{% if item.value is mapping %} +{{ item.value | to_nice_yaml(indent=2) }} +{% else %} +{% for ve_line in item.value %} +{{ ve_line }} +{% endfor %} +{% endif %} +``` +{% endif %} +{% if item.example is defined and item.example %} + +#### Example usage + +```YAML +{% if item.example is mapping %} +{{ item.example | to_nice_yaml(indent=2) }} +{% else %} +{% for ex_line in item.example %} +{{ ex_line }} +{% endfor %} +{% endif %} +``` +{% endif %} +{% endfor %} +{% endif %} diff --git a/ansibledoctor/templates/hugo/index.md.j2 b/ansibledoctor/templates/hugo/index.md.j2 new file mode 100644 index 0000000..a31a1f1 --- /dev/null +++ b/ansibledoctor/templates/hugo/index.md.j2 @@ -0,0 +1,17 @@ +{% set meta = role.meta | default({}) %} +--- +title: {{ meta.name.value | save_join(" ") }} +--- + +{% if description | deep_get(meta, "description.value") %} +{{ meta.description.value | save_join(" ") }} +{% endif %} + +{# TOC #} +{% include '_toc.j2' %} + +{# Vars #} +{% include '_vars.j2' %} + +{# Meta #} +{% include '_meta.j2' %}