docs: add versions target to produce multi-version docs

ci-kbs-docs-build-full
This commit is contained in:
InsanePrawn 2022-12-15 07:07:53 +01:00
parent dc59378243
commit c7084895d6
8 changed files with 271 additions and 12 deletions

58
docs/versjon/footer.html Normal file
View file

@ -0,0 +1,58 @@
{# FORMAT_VERSION #}
{% macro format_version(version) %}
{% if page in version.html_files %}
{% set version_path = page_root + docs_path[version.name] + "/" + page %}
{% else %}
{% set version_path = page_root + docs_path[version.name] %}
{% endif %}
{% if current == version.name %}
<strong>
<dd><a href="{{ version_path }}">{{ version.name }}</a></dd>
</strong>
{% else %}
<dd><a href="{{ version_path }}">{{ version.name }}</a></dd>
{% endif %}
{% endmacro %}
<div id="versjon-overlay">
<button type="button" class="versjon">
<svg xmlns="http://www.w3.org/2000/svg" id="branch-icon" class="ionicon" viewBox="0 0 512 512">
<!-- Taken from Ionic, MIT licensed. Copyright (c) 2015-present Ionic (http://ionic.io/) -->
<title>Git Branch</title><circle cx="160" cy="96" r="48" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/><circle cx="160" cy="416" r="48" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32" d="M160 368V144"/><circle cx="352" cy="160" r="48" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/><path d="M352 208c0 128-192 48-192 160" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="32"/>
</svg>
Version: {{current}}
</button>
<div class="versjon-content">
<div class="versjon-content-inner">
<dl>
<dl>
<dt>Branches</dt>
{% for version in other %}
{{ format_version(version) | indent(16) }}
{% endfor %}
</dl>
<dt>Versions</dt>
{% for version in semver %}
{{ format_version(version) | indent(16) }}
{% endfor %}
</dl>
</div>
</div>
</div>
<script>
var coll = document.getElementsByClassName("versjon");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function () {
this.classList.toggle("active");
var content = this.nextElementSibling;
if (content.style.maxHeight) {
content.style.maxHeight = null;
} else {
content.style.maxHeight = content.scrollHeight + "px";
}
});
}
</script>

1
docs/versjon/head.html Normal file
View file

@ -0,0 +1 @@
<link href="{{ page_root }}versions.css" rel="stylesheet" type="text/css">

11
docs/versjon/header.html Normal file
View file

@ -0,0 +1,11 @@
{% if stable and (stable.name|default("")) != current %}
{% if page in stable.html_files %}
{% set stable_path = page_root + docs_path[stable.name] + "/" + page %}
{% else %}
{% set stable_path = page_root + docs_path[stable.name] %}
{% endif %}
<p class="versjon-{% if is_semver %}old{% else %}dev{% endif %}-warning">
<strong>Warning:</strong> These docs are for version <b>{{current}}</b>. The docs for the latest stable version are at
<b> <a href="{{ stable_path }}">{{ stable.name }}</a> </b>.
</p>
{% endif %}

96
docs/versjon/versions.css Normal file
View file

@ -0,0 +1,96 @@
.versjon {
cursor: pointer;
padding: 10px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
background: var(--color-code-background);
color: var(--color-code-foreground);
transition: background-color 0.1s linear;
}
.versjon:hover {
background-color: var(--color-highlighted-background);
}
.versjon:after {
content: '\002B';
font-weight: bold;
float: right;
margin-left: 5px;
}
.versjon:active:after {
content: "\2212";
}
.versjon-content {
max-height: 0;
overflow: hidden;
transition: max-height 0.2s ease-out;
}
.versjon-content-inner {
padding: 10px 18px
}
#versjon-overlay {
position: fixed;
bottom: 0px;
right: 0px;
width: 250px;
background: var(--color-code-background);
}
p.versjon-old-warning {
margin: 10px 0;
padding: 5px 10px;
border-radius: 4px;
letter-spacing: 1px;
color: #fff;
text-shadow: 0 0 2px #000;
text-align: center;
background: #d40 repeating-linear-gradient(135deg,
transparent,
transparent 56px,
rgba(255, 255, 255, 0.2) 56px,
rgba(255, 255, 255, 0.2) 112px);
}
p.versjon-old-warning a {
color: #fff;
border-color: #fff;
}
p.versjon-dev-warning {
margin: 10px 0;
padding: 5px 10px;
border-radius: 4px;
letter-spacing: 1px;
color: #fff;
text-shadow: 0 0 2px #000;
text-align: center;
background: #E67300 repeating-linear-gradient(135deg,
transparent,
transparent 56px,
rgba(255, 255, 255, 0.2) 56px,
rgba(255, 255, 255, 0.2) 112px);
}
p.versjon-dev-warning a {
color: #fff;
border-color: #fff;
}
#branch-icon {
width: 1em;
height: 1em;
background-size: contain;
background-repeat: no-repeat;
}