Commit 40a2ca72 authored by Adrian DC's avatar Adrian DC
Browse files

docs(mkdocs): implement 'Table of contents' injection for PDF results

Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent 7feda913
Loading
Loading
Loading
Loading
Loading
+16 −0
Changes for docs/prepare.sh: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -54,6 +54,22 @@ sed -i \
  -e '/<div style="padding-left: 30px"/{ n; /<br/d; }' \
  $(find "${docs_path}/" -name '*.md')

# Inject 'toc' section (PDF only)
find "${docs_path}/" -name '*.md' \
  | while read -r file_path; do
    if ! grep -q '\[TOC\]' "${file_path}"; then
      sed -E -i '
        0,/^---$/ {
          s/^---$/---\
\
[TOC]\
\
<div class="page-break"><\/div>/
        }
      ' "${file_path}"
    fi
  done

# Export about/changelog
rm -rf "${docs_path}/about"
mkdir -p "${docs_path}/about/"
+15 −0
Changes for docs/stylesheets/custom.css: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
.md-header {
  background-color: #004f73;
}

.md-sidebar--secondary {
  .md-nav .md-nav {
    display: none;
  }
}

.toc {
  display: none;
}

.toc-title {
  font-size: 1.5625em;
  font-weight: 300;
}
+6 −1
Changes for docs/stylesheets/pdf.scss: 6 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -95,7 +95,8 @@
  border: 1px solid #ddd;
}

hr:has(+ div.md-source-file), .md-source-file {
hr:has(+ div.md-source-file),
.md-source-file {
  display: none !important;
}

@@ -159,3 +160,7 @@ body {
  display: none;
  page-break-after: always;
}

.toc {
  display: initial;
}
+3 −1
Changes for mkdocs.yml: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -57,7 +57,9 @@ markdown_extensions:
  - pymdownx.superfences
  - toc:
      permalink: true
      toc_depth: 2
      title: Table of contents
      title_class: toc-title
      toc_depth: 2-3

# Pages plugins
plugins: