From ff9706d039becee9e7deda02044a07a4a809590a Mon Sep 17 00:00:00 2001 From: Anastasia Alexadrova Date: Fri, 4 Apr 2025 08:33:51 +0200 Subject: [PATCH 1/2] Added a new PDF builder new file: _resourcepdf/Dockerfile.build new file: _resourcepdf/overrides/404.html new file: _resourcepdf/overrides/main.html new file: _resourcepdf/overrides/partials/banner.html new file: _resourcepdf/overrides/partials/copyright.html new file: _resourcepdf/overrides/partials/header.html new file: _resourcepdf/overrides/partials/source-file.html new file: _resourcepdf/templates/index.html new file: _resourcepdf/templates/styles.scss new file: _resourcepdf/theme/main.html new file: docs/assets/templates/pdf_cover_page.tpl modified: mkdocs-base.yml deleted: mkdocs-percona.yml modified: mkdocs.yml deleted: mkdocs-pdf.yml --- __pycache__/main.cpython-311.pyc | Bin 1705 -> 0 bytes _resourcepdf/Dockerfile.build | 17 ++ _resourcepdf/overrides/404.html | 9 + _resourcepdf/overrides/main.html | 73 ++++++ _resourcepdf/overrides/partials/banner.html | 9 + .../overrides/partials/copyright.html | 15 ++ _resourcepdf/overrides/partials/header.html | 118 ++++++++++ .../overrides/partials/source-file.html | 20 ++ _resourcepdf/templates/index.html | 11 + _resourcepdf/templates/styles.scss | 110 +++++++++ _resourcepdf/theme/main.html | 222 ++++++++++++++++++ docs/assets/templates/pdf_cover_page.tpl | 10 + mkdocs-base.yml | 57 +++-- mkdocs-pdf.yml | 12 - mkdocs-percona.yml | 16 -- mkdocs.yml | 7 +- 16 files changed, 655 insertions(+), 51 deletions(-) delete mode 100644 __pycache__/main.cpython-311.pyc create mode 100644 _resourcepdf/Dockerfile.build create mode 100644 _resourcepdf/overrides/404.html create mode 100644 _resourcepdf/overrides/main.html create mode 100644 _resourcepdf/overrides/partials/banner.html create mode 100644 _resourcepdf/overrides/partials/copyright.html create mode 100644 _resourcepdf/overrides/partials/header.html create mode 100644 _resourcepdf/overrides/partials/source-file.html create mode 100644 _resourcepdf/templates/index.html create mode 100644 _resourcepdf/templates/styles.scss create mode 100644 _resourcepdf/theme/main.html create mode 100644 docs/assets/templates/pdf_cover_page.tpl delete mode 100644 mkdocs-pdf.yml delete mode 100644 mkdocs-percona.yml diff --git a/__pycache__/main.cpython-311.pyc b/__pycache__/main.cpython-311.pyc deleted file mode 100644 index 7ca444f13de0ee776cf1836f2afdf89010b29c18..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1705 zcmcgsO>7%Q6rR~#|2C5qq7((S;HGMbY3)^2A+^MWLo38j6_U8&C!wV4ops{G-nC}e zZCIQtha5O?C{j^_1jrWxRW2Mka_n&@O4Vp3q)ME)8Rg~^Z+30xhe*9K)_(Ke``*mF zdGnrsAta4py!rD_^nrxXUqa~((8IBJ5~hcUB8sbM7Ex&(&0>m+C@cRh93~7L`b8ka zB)+{xfQP7wmLfYK#p`Gj=B>VE6(8bZ=Oesyh>ufc9Ut+KX$&Gsc;r3XUe1&omf==x z>rhAvocAJpd(!}L5$qlaxQRAF+v;09@S&2x=X%M)3l3K%yyV=6SBjILUdwseTceAv zTX){lw51Bu^L3LMwx#C{yQYbXmgL|Bu_eUlkbdeXDO< zm716;%c0I}U+gLB@%NYx$7zwyq< zf;*ODDzILvpl2+-X1+b_C5Oignm(SH^W!O*(@?ap6>kNu{B}i5)*0QiW;s%*aCVJBD0zn>M_R%JS7mwq71psBQ4n0-R zZmVZo=UNU|FYKrno~oC&)k|ExyrW)TTl`af;hQ`6tybyR(Vl5HeQINPJAK+upWaQL zyl?R2(ANXIWN70ebWUr96YaMXoQ(bc0VnVN(ct99^dL)dmyO8_!0uyzhka8-hj++I>?JrmjN}mtP2q!dl7*U0 i8&z|hy#~CfVdo-1TgDjgqSRXWYbz=iryY;sZvO(0NQ_qi diff --git a/_resourcepdf/Dockerfile.build b/_resourcepdf/Dockerfile.build new file mode 100644 index 00000000..dd04c50f --- /dev/null +++ b/_resourcepdf/Dockerfile.build @@ -0,0 +1,17 @@ +FROM ubuntu:20.04 + +RUN apt-get update +RUN apt-get install -y software-properties-common +RUN add-apt-repository universe && apt-get update +RUN apt-get install -y git wget unzip python3 python3-pip python3-dev fontconfig fonts-noto fonts-inconsolata python3-cairocffi + +COPY requirements.txt ./requirements.txt +RUN pip3 install -r requirements.txt + +RUN mkdir -p /usr/share/fonts/chivo && cd /usr/share/fonts/chivo && wget -O Chivo.zip https://fonts.google.com/download?family=Chivo && unzip Chivo.zip +RUN rm /usr/share/fonts/chivo/Chivo.zip && fc-cache -f && apt-get clean + +WORKDIR /docs + +EXPOSE 8000 +CMD ["mkdocs","build"] diff --git a/_resourcepdf/overrides/404.html b/_resourcepdf/overrides/404.html new file mode 100644 index 00000000..bc9ca80c --- /dev/null +++ b/_resourcepdf/overrides/404.html @@ -0,0 +1,9 @@ +{#- +A custom 404 page +-#} +{% extends "main.html" %} +{% block content %} +

404 - Not found

+

+We can't find the page you are looking for. Try using the Search or return to homepage .

+{% endblock %} diff --git a/_resourcepdf/overrides/main.html b/_resourcepdf/overrides/main.html new file mode 100644 index 00000000..63e6e569 --- /dev/null +++ b/_resourcepdf/overrides/main.html @@ -0,0 +1,73 @@ +{# MkDocs template for builds with Material Theme to customize docs layout +by adding marketing-requested elements +#} + +{# Import the theme's layout. #} +{% extends "base.html" %} + + + + {% block site_nav %} + {% if nav %} + {% if page.meta and page.meta.hide %} + {% set hidden = "hidden" if "navigation" in page.meta.hide %} + {% endif %} + + {% endif %} + {% if "toc.integrate" not in features %} + {% if page.meta and page.meta.hide %} + {% set hidden = "hidden" if "toc" in page.meta.hide %} + {% endif %} + + {% endif %} + + {% endblock %} + + + {% block content%} + + {{ super() }} + +{# The script to expand all collapsible admonitions in PDF #} + + + + {% endblock %} diff --git a/_resourcepdf/overrides/partials/banner.html b/_resourcepdf/overrides/partials/banner.html new file mode 100644 index 00000000..c4842175 --- /dev/null +++ b/_resourcepdf/overrides/partials/banner.html @@ -0,0 +1,9 @@ +
+

+

For help, click the link below to get free database assistance or contact our experts for personalized support.

+ + +
\ No newline at end of file diff --git a/_resourcepdf/overrides/partials/copyright.html b/_resourcepdf/overrides/partials/copyright.html new file mode 100644 index 00000000..d1ee943d --- /dev/null +++ b/_resourcepdf/overrides/partials/copyright.html @@ -0,0 +1,15 @@ +{#- + This file was automatically generated - do not edit +-#} + \ No newline at end of file diff --git a/_resourcepdf/overrides/partials/header.html b/_resourcepdf/overrides/partials/header.html new file mode 100644 index 00000000..4747da20 --- /dev/null +++ b/_resourcepdf/overrides/partials/header.html @@ -0,0 +1,118 @@ + +{% set class = "md-header" %} +{% if "navigation.tabs.sticky" in features %} + {% set class = class ~ " md-header--shadow md-header--lifted" %} +{% elif "navigation.tabs" not in features %} + {% set class = class ~ " md-header--shadow" %} +{% endif %} + + +
+ + + + + + + + {% if "navigation.tabs.sticky" in features %} + {% if "navigation.tabs" in features %} + {% include "partials/tabs.html" %} + {% endif %} + {% endif %} +
diff --git a/_resourcepdf/overrides/partials/source-file.html b/_resourcepdf/overrides/partials/source-file.html new file mode 100644 index 00000000..ae5bd084 --- /dev/null +++ b/_resourcepdf/overrides/partials/source-file.html @@ -0,0 +1,20 @@ +{#- + This file was automatically generated - do not edit +-#} +
+
+ + {% if page.meta.git_revision_date_localized %} + {{ lang.t("source.file.date.updated") }}: + {{ page.meta.git_revision_date_localized }} + {% if page.meta.git_creation_date_localized %} +
+ {{ lang.t("source.file.date.created") }}: + {{ page.meta.git_creation_date_localized }} + {% endif %} + {% elif page.meta.revision_date %} + {{ lang.t("source.file.date.updated") }}: + {{ page.meta.revision_date }} + {% endif %} +
+
diff --git a/_resourcepdf/templates/index.html b/_resourcepdf/templates/index.html new file mode 100644 index 00000000..ca5be511 --- /dev/null +++ b/_resourcepdf/templates/index.html @@ -0,0 +1,11 @@ + + + + Redirecting + + + + + diff --git a/_resourcepdf/templates/styles.scss b/_resourcepdf/templates/styles.scss new file mode 100644 index 00000000..d9e671d7 --- /dev/null +++ b/_resourcepdf/templates/styles.scss @@ -0,0 +1,110 @@ +/* Style for PDF created by MkDocs with mkdocs-with-pdf plugin (https://pypi.org/project/mkdocs-with-pdf/) */ +@media print { + html { + font-size: 100%; + font-family: "Poppins", sans-serif; + } + + body { + font-family: "Poppins", sans-serif; + color: #00162b; + } + + article { + font-family: "Poppins", sans-serif; + text-align: justify; + } + + pre, + code, + var, + samp, + kbd, + tt { + font-family: monospace; + font-size: 110%; + } + + pre code, + pre var, + pre samp, + pre kbd, + pre tt { + font-size: 110%; + } +} + +@page { + size: a4 portrait; + margin: 25mm 20mm 25mm 20mm; + counter-increment: page; + white-space: pre; + color: #00162b; + + @top-right { + content: string(chapter); + } + + @bottom-left { + content: string(subtitle); + } + + @bottom-center { + content: counter(page)' of 'counter(pages); + } + + @bottom-right { + } +} + +@page :first { + @top-right { + content: ''; + } + + @bottom-right { + content: ''; + } + + @bottom-left { + content: ''; + } +} + +article { + page-break-before: always; + min-height: 100%; +} + +article { + + h1, + h2, + h3 { + border-bottom: 0px solid #fff; + } + + h1>.pdf-order, + h2>.pdf-order, + h3>.pdf-order { + padding-left: 6px; + padding-right: 0.8rem; + } +} + +article h1, +h2, +h3 { + border-bottom: 0px solid #fff; + color: #3e4875; +} + +.admonition { + font-size: 100%; +} + +.md-typeset .admonition.note, +.md-typeset details.note { + color: #00162b; + border-color: #fff; +} diff --git a/_resourcepdf/theme/main.html b/_resourcepdf/theme/main.html new file mode 100644 index 00000000..b722a4f2 --- /dev/null +++ b/_resourcepdf/theme/main.html @@ -0,0 +1,222 @@ +{# +MkDocs template for PMM +Builds HTML without outer html tags +for wrapping within Drupal container +#} +{%- set url_root = config.site_url %} +{%- set site_name = config.site_name %} +{%- set page_title = page.title %} +{%- set release = config.extra.release %} + +{# toctree() section level start and limit #} +{% set default_level = 1 %} +{% set max_level = 4 %} + +{#### Horizontal navigation bars above and below main content (Home, prev, next) #} +{%- macro relbar() %} + +{% endmacro %} + +{#### 'Edit this page' link #} +{% macro edit_this_page() %} +{% if page and page.edit_url %} + +{% endif %} +{% endmacro %} + +{#### 'Last updated' (and later, other info such as author, tester) #} +{% macro last_updated() %} +
+
    + {% if page and page.meta.revision_date %} +
  • + {{ config.extra.updated_text }} {{ page.meta.revision_date }} +
  • + {% endif %} +
+
+{% endmacro %} + +{#### Contents of left column navigation bar #} +{% macro sidebar() %} +
+
+ {@ product_logo @} + {@ product_pdf_download @} + {{ version_menu() }} +

Contents

+ {{ toctree(nav, default_level) }} + {{ relations() }} + {@ product_series @} +
+
+{% endmacro %} + +{### Left nav column previous/next links #} +{% macro relations() %} +{% if page.previous_page %} +

Previous page

+

+ {{ page.previous_page.title|e }} +

+{% endif %} +{% if page.next_page %} +

Next page

+

+ {{ page.next_page.title|e }} +

+{% endif %} +{% endmacro %} + + +{# +Used by toctree() + +MkDocs doesn't allow a section link. Example, in mkdocs.yaml: + +nav: + - SECTION TITLE: + - intro: dir/index.md + - another: dir/section.md + +The toctree will render without a link for 'SECTION TITLE', +as it doesn't have a file. 'SECTION TITLE' is just a cosmetic +label. + +To match Sphinx's behaviour, this macro detects special +section labels as 'TITLE=path' (splitting on the equals sign). +The new nav element would then be: + +nav: + - SECTION TITLE=/dir/: + - intro: dir/index.md + - another: dir/section.md + +This macro will put a link to /dir/ for the toc entry +'SECTION TITLE'. If there is not an index.md file in +the subdir, link to a file with its .html extension. + +nav: + - SECTION TITLE=/dir/myindex.html: + - intro: dir/index.md + - another: dir/section.md + +#} +{%- macro navi(item, class, close) %} +
  • +{%- if item.url %} + {{ item.title }} +{%- else %} + {{ item.title }} +{% endif %} + +{%- if close %} +
  • +{% endif %} +{% endmacro %} + +{# Table of contents for left nav column #} +{% macro toctree(n, level) %} +{% if level <= max_level %} +
      +{% for i in n %} +{{ navi(i, "toctree-l" + level|string) }} +{% if i.children %} +{{ toctree(i.children, level+1) }} +{% endif %} +{% endfor %} +
    +{% endif %} +{% endmacro %} + +{# Inserts script items from mkdocs.yml #} +{%- macro script() %} +{%- for scriptfile in config.extra_javascript %} + +{% endfor %} +{# For lightgallery-markdown #} + +{% endmacro %} + +{# Inserts CSS files from mkdocs.yml #} +{%- macro css() %} +{%- for cssfile in config.extra_css %} + +{%- endfor %} +{% endmacro %} + +{%- macro metatags() %} +{# TODO #} +{% endmacro %} + +{% macro version_menu() %} +
    + +
    +{% endmacro %} + +{# Layout for content as hosted by Drupal (no outer html tag) #} +{# NOTE: title and head are ignored by Drupal's container #} +{{ site_name|e }}{% if page_title %} — {{ page_title|striptags|e }}{% endif %} + + + {{ metatags() }} + {{ script() }} + + {% if page.next_page %} + + {% endif %} + {% if page.previous %} + + {% endif %} + + + +
    + {{ css() }} + {{ script() }} +
    +
    + {{ relbar() }} + {{ edit_this_page() }} +
    +
    + {{ page.content }} +
    +
    + {{ last_updated() }} + {{ relbar() }} +
    + {{ sidebar() }} +
    +
    +
    + diff --git a/docs/assets/templates/pdf_cover_page.tpl b/docs/assets/templates/pdf_cover_page.tpl new file mode 100644 index 00000000..36df9aed --- /dev/null +++ b/docs/assets/templates/pdf_cover_page.tpl @@ -0,0 +1,10 @@ + +{{ config.extra.added_key }} +

    + +

    +

    Operator for MySQL based on Percona XtraDB Cluster

    +{% if config.site_description %} +

    {{ config.site_description }}

    +{% endif %} +

    1.17.0 (April 14, 2025)

    \ No newline at end of file diff --git a/mkdocs-base.yml b/mkdocs-base.yml index 54f3c71a..25e5c3cf 100644 --- a/mkdocs-base.yml +++ b/mkdocs-base.yml @@ -113,23 +113,25 @@ plugins: exclude: glob: - "setting-up/client/docker.md" - # https://github.com/orzih/mkdocs-with-pdf - with-pdf: - output_path: "_pdf/percona-operator-for-mysql-pxc.pdf" - cover_title: "Operator for MySQL based on Percona XtraDB Cluster documentation" - cover_subtitle: 1.16.1 (December 26, 2024) - author: "Percona Technical Documentation Team" - cover_logo: docs/assets/images/PerconaLogostackedlightbackground.svg - custom_template_path: _resource/templates - enabled_if_env: ENABLE_PDF_EXPORT - # Check links - but extends build time significantly - # https://pypi.org/project/mkdocs-htmlproofer-plugin/ - # htmlproofer: {} - mike: - version_selector: false - css_dir: css - javascript_dir: js - canonical_version: null + # PDF builder + print-site: + add_to_navigation: false + print_page_title: 'Percona Operator for MySQL documentation' + add_print_site_banner: false + # Table of contents + add_table_of_contents: true + toc_title: 'Table of Contents' + toc_depth: 2 + # Content-related + add_full_urls: false + enumerate_headings: false + enumerate_headings_depth: 1 + enumerate_figures: true + add_cover_page: true + cover_page_template: "docs/assets/templates/pdf_cover_page.tpl" + path_to_pdf: "" + include_css: true + enabled: true extra: # Used in main.html template and can't be externalized edit_page_text: ' Edit this page' @@ -153,6 +155,27 @@ extra: # Used in main.html template and can't be externalized version: provider: mike k8s_monitor_tag: 'v0.1.1' + + # Google Analytics configuration + analytics: + provider: google + property: G-J4J70BNH0G + feedback: + title: Was this page helpful? + ratings: + - icon: material/emoticon-happy-outline + name: This page was helpful + data: 1 + note: >- + Thanks for your feedback! + - icon: material/emoticon-sad-outline + name: This page could be improved + data: 0 + note: >- + Thank you for your feedback! Help us improve by using our + + feedback form. + # Common navigation for percona.com, render.com and PDF nav: diff --git a/mkdocs-pdf.yml b/mkdocs-pdf.yml deleted file mode 100644 index f0d710d5..00000000 --- a/mkdocs-pdf.yml +++ /dev/null @@ -1,12 +0,0 @@ -# MkDocs configuration for PDF output -# Usage: ENABLE_PDF_EXPORT=1 mkdocs build -f mkdocs-pdf.yml -INHERIT: mkdocs-base.yml - -extra_css: - - https://unicons.iconscout.com/release/v3.0.3/css/line.css - - https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css - - css/percona.css - - css/nocopy.css - - css/extra.css - -copyright: Percona LLC and/or its affiliates, © 2009 - 2024 diff --git a/mkdocs-percona.yml b/mkdocs-percona.yml deleted file mode 100644 index 8f96fb0a..00000000 --- a/mkdocs-percona.yml +++ /dev/null @@ -1,16 +0,0 @@ -# MkDocs configuration for HTML publishing to percona.com -INHERIT: mkdocs-base.yml - -site_url: https://docs.percona.com/percona-operator-for-mysql/pxc/ - -plugins: - section-index: {} - bootstrap-tables: {} - -theme: - name: material - custom_dir: _resources/theme - -extra_css: - - css/version-select.css - - css/toctree.css diff --git a/mkdocs.yml b/mkdocs.yml index 1f1a4d62..0ec02e0d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,7 +8,7 @@ plugins: theme: name: material - custom_dir: _resource/overrides + custom_dir: _resourcepdf/overrides # Theme features features: - search.highlight @@ -19,8 +19,3 @@ theme: - content.action.view - content.code.copy -#Google Analytics configuration -extra: - analytics: - provider: google - property: UA-343802-3 From 637688a2d5ad61c93d29afe3c4908410e07a7889 Mon Sep 17 00:00:00 2001 From: Anastasia Alexadrova Date: Mon, 14 Apr 2025 19:59:02 +0200 Subject: [PATCH 2/2] Updated requirements.txt --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7e597a89..d0cddd1c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,6 @@ mkdocs-macros-plugin mkdocs-exclude markdown-include mkdocs-material -mkdocs-with-pdf mkdocs-git-revision-date-plugin mkdocs-material-extensions mkdocs-bootstrap-tables-plugin @@ -11,3 +10,4 @@ mkdocs-section-index mkdocs-htmlproofer-plugin mkdocs-meta-descriptions-plugin mike +mkdocs-print-site-plugin