]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Doc: building singlepage version with the appropriate template
authorMaria Matejka <mq@ucw.cz>
Sat, 25 Jan 2025 22:01:11 +0000 (23:01 +0100)
committerMaria Matejka <mq@ucw.cz>
Thu, 8 May 2025 19:36:58 +0000 (21:36 +0200)
This change caters for the new website automation and allows for
future online display of documentation even for development versions.

doc/Makefile
tools/doc-template.html [new file with mode: 0644]

index c176488774706aaf1070cbf9f488b20026fe7056..8545472b9f823d3e4181f81d9ed48b813468a9b9 100644 (file)
@@ -31,11 +31,12 @@ $(o)%.md: $(s)%.sgml
        @false
 else
 LINUXDOC_PANDOC_PARSER := $(srcdir)/tools/linuxdoc.lua
+SINGLEPAGE_HTML_TEMPLATE := $(srcdir)/tools/doc-template.html
 $(o)%.md: $(s)%.sgml $(LINUXDOC_PANDOC_PARSER) $(objdir)/.dir-stamp
        $(PANDOC) -f $(LINUXDOC_PANDOC_PARSER) -s -t markdown -o $@ $<
 
-$(o)%-singlepage.html: $(o)%.md
-       $(PANDOC) -f markdown -t html5 -s -o $@ $<
+$(o)%-singlepage.html: $(o)%.sgml $(SINGLEPAGE_HTML_TEMPLATE) $(LINUXDOC_PANDOC_PARSER) $(objdir)/.dir-stamp
+       $(PANDOC) -f $(LINUXDOC_PANDOC_PARSER) -t html5 --shift-heading-level-by=1 --section-divs --table-of-contents --toc-depth=3 -M bird_version="$(VERSION)" --template=$(SINGLEPAGE_HTML_TEMPLATE) -o $@ $<
 
 endif
 
diff --git a/tools/doc-template.html b/tools/doc-template.html
new file mode 100644 (file)
index 0000000..25f63c5
--- /dev/null
@@ -0,0 +1,58 @@
+{%- set title = "$pagetitle$" %}
+{%- set is_docs = True %}
+{%- set template_part = "header" %}
+{%- set authors = [ $for(author-meta)$ "$author-meta$", $endfor$ ] %}
+{%- set meta_additional = { "author": authors, } %}
+{%- include "main.html.j2" %}
+<!--<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>-->
+      <section class="bg-light bird-documentation">
+       <div class="pt-60 container">
+         <div class="row">
+           <div class="col d-none d-lg-block"></div>
+           <div class='col-12 col-xl-3 col-lg-4'></div>
+           <div class="col-12 col-xl-6 col-lg-7">
+             <h1 class="title">{{ title }}</h1>
+             <div class="version-info pb-20 mb-20 border-bottom border-primary">
+               <h4>Version $bird_version$ | <a href="/download/bird-doc-$bird_version$.tar.gz">TGZ</a></h4>
+               Available versions:
+               {% for v in releases | reverse -%}
+                 {% if (v.type == 'current') or 'show_doc' in v %}
+                   <a href="
+                     {%- if "$bird_version$" == v.version -%}
+                     #
+                     {%- else -%}
+                     /doc/bird-{{ v.version }}.html
+                     {%- endif -%}
+                     " style="{% if v.type == 'current' %}font-weight: bold;{% endif %}">
+                     {{- v.version -}}
+                   </a>
+                   {%- if not loop.last %} | {% endif -%}
+                 {%- endif -%}
+               {%- endfor %}
+             </div>
+             <p class="authors">Authors: 
+             {%- for a in authors %}
+             <a href="mailto:{{ a.split('&lt;')[1][:-4] }}">{{ a.split('&lt;')[0][:-1] }}</a>{% if not loop.last %}, {% endif %}
+             {%- endfor %}
+             </p>
+             <p class="abstract">$abstract$</p>
+           </div>
+           <div class="col d-none d-lg-block"></div>
+         </div>
+         <div class="row">
+           <div class="col d-none d-lg-block"></div>
+           <aside class='col-12 col-xl-3 col-lg-4'>
+             <nav class='pt-lg-120 pb-lg-20 sticky-lg-top overflow-scroll' >
+               $table-of-contents$
+               {# TODO: make the TOC collapsible #}
+             </nav>
+           </aside>
+           <div class="col-12 col-xl-6 col-lg-7">
+             $body$
+           </div>
+           <div class="col d-none d-lg-block"></div>
+         </div>
+       </div>
+      </section>
+{% set template_part = "footer" %}
+{% include "main.html.j2" %}