mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
create static docs site with module options
This commit is contained in:
parent
e3127e8c14
commit
e75b801a31
24 changed files with 448 additions and 19 deletions
40
docs/layouts/partials/details.html
Normal file
40
docs/layouts/partials/details.html
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{{ $name := index . "name" }}
|
||||
{{ $option := index . "option" }}
|
||||
{{ $repo := index . "repo" }}
|
||||
|
||||
{{ $path := path.Join (after 2 (split (index $option.declarations 0) "/")) }}
|
||||
|
||||
<details id="{{ $name }}">
|
||||
<summary>
|
||||
<pre>{{ $name }}</pre>
|
||||
</summary>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Description</td>
|
||||
<td>{{ $option.description }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Type</td>
|
||||
<td><pre>{{ $option.type }}</pre></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Default</td>
|
||||
<td>{{ partial "highlight" $option.default }}</td>
|
||||
</tr>
|
||||
|
||||
{{ with $option.example }}
|
||||
<tr>
|
||||
<td>Example</td>
|
||||
<td>{{ partial "highlight" . }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
|
||||
<tr>
|
||||
<td>Declared in</td>
|
||||
<td><a href="{{ $repo }}/blob/main/{{ $path }}" target="_blank">{{ $path }}</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</details>
|
||||
24
docs/layouts/partials/docs/inject/body.html
Normal file
24
docs/layouts/partials/docs/inject/body.html
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<script>
|
||||
window.onload = function(){
|
||||
// open details of option in URL fragment
|
||||
document.getElementById(decodeURI(window.location.hash.substring(1)))?.setAttribute("open", "");
|
||||
|
||||
var options = document.getElementsByTagName('details');
|
||||
for(var i = 0; i < options.length; i++) {
|
||||
options[i].getElementsByTagName("summary")[0].onclick = function() {
|
||||
|
||||
// set URL fragment to option id
|
||||
window.location.hash = this.parentElement.id;
|
||||
|
||||
// is current panel open, return immediately as it's just being closed
|
||||
if (this.parentElement.hasAttribute("open")) return;
|
||||
|
||||
// collapse all other options
|
||||
for(var j = 0; j < options.length; j++) {
|
||||
options[j].removeAttribute("open");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
</script>
|
||||
1
docs/layouts/partials/docs/inject/head.html
Normal file
1
docs/layouts/partials/docs/inject/head.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
<link rel="icon" href="/logo.svg">
|
||||
10
docs/layouts/partials/highlight.html
Normal file
10
docs/layouts/partials/highlight.html
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{{ $text := . }}
|
||||
|
||||
{{/* if text is a multiline string add nix's double single-quotes */}}
|
||||
{{ if in $text "\n" }}
|
||||
{{ $text = print "''\n " (strings.TrimSuffix " " (replace $text "\n" "\n ") ) "''" }}
|
||||
{{ else }}
|
||||
{{ $text = jsonify $text }}
|
||||
{{ end }}
|
||||
|
||||
<pre class="highlight"><code>{{ $text }}</code></pre>
|
||||
22
docs/layouts/shortcodes/options.html
Normal file
22
docs/layouts/shortcodes/options.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{{ $module := $.Page.File.BaseFileName }}
|
||||
{{ $repo := $.Site.Params.BookRepo }}
|
||||
{{ range $name, $option := .Site.Data.options }}
|
||||
|
||||
{{/* some module options are nested under others */}}
|
||||
{{ if and (hasPrefix $name "kubernetes.helm.") }}
|
||||
{{ if (eq $module "helm") }}
|
||||
{{ partial "details" (dict "name" $name "option" $option "repo" $repo) }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
|
||||
{{/* only show options for the current module */}}
|
||||
{{/* but don't list _all_ kubernetes resources */}}
|
||||
{{ if and
|
||||
(not (hasPrefix $name "kubernetes.api.resources."))
|
||||
(hasPrefix $name (print $module "."))
|
||||
}}
|
||||
{{ partial "details" (dict "name" $name "option" $option "repo" $repo) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue