From ea802aa91e40ea6150773d4c7618f450a64a8ca8 Mon Sep 17 00:00:00 2001 From: Damien Date: Thu, 22 Jul 2021 00:38:53 +0200 Subject: [PATCH] docs: Setup mkdocs with mkdocs-material theme This changes the framework used to generate the klipper3d site. Signed-off-by: Damien Martin --- .github/workflows/klipper3d-deploy.yaml | 29 +++++ docs/_config.yml | 4 - docs/_klipper3d/css/extra.css | 15 +++ docs/_klipper3d/mkdocs-requirements.txt | 8 ++ docs/_klipper3d/mkdocs_hooks.py | 18 +++ docs/_layouts/README | 5 - docs/_layouts/default.html | 139 ------------------------ docs/_layouts/home.html | 16 --- docs/img/favicon.ico | Bin 0 -> 8222 bytes docs/index.md | 1 - mkdocs.yml | 119 ++++++++++++++++++++ 11 files changed, 189 insertions(+), 165 deletions(-) create mode 100644 .github/workflows/klipper3d-deploy.yaml delete mode 100644 docs/_config.yml create mode 100644 docs/_klipper3d/css/extra.css create mode 100644 docs/_klipper3d/mkdocs-requirements.txt create mode 100644 docs/_klipper3d/mkdocs_hooks.py delete mode 100644 docs/_layouts/README delete mode 100644 docs/_layouts/default.html delete mode 100644 docs/_layouts/home.html create mode 100644 docs/img/favicon.ico create mode 100644 mkdocs.yml diff --git a/.github/workflows/klipper3d-deploy.yaml b/.github/workflows/klipper3d-deploy.yaml new file mode 100644 index 00000000..246209c8 --- /dev/null +++ b/.github/workflows/klipper3d-deploy.yaml @@ -0,0 +1,29 @@ +name: klipper3d deploy +on: + push: + branches: + - master + paths: + - docs/** + - mkdocs.yml + - .github/workflows/klipper3d-deploy.yaml +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: '3.8' + - uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('docs/_klipper3d/mkdocs-requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - name: Install dependencies + run: pip install -r docs/_klipper3d/mkdocs-requirements.txt + - name: Build and deploy klipper3d + run: | + mkdocs gh-deploy --force --remote-branch gh-pages --verbose diff --git a/docs/_config.yml b/docs/_config.yml deleted file mode 100644 index 9daee3ca..00000000 --- a/docs/_config.yml +++ /dev/null @@ -1,4 +0,0 @@ -# This is a Jekyll config file that is used by "github pages" to -# produce the https://www.klipper3d.org/ website. -include: CONTRIBUTING.md -google_analytics: UA-138371409-1 diff --git a/docs/_klipper3d/css/extra.css b/docs/_klipper3d/css/extra.css new file mode 100644 index 00000000..0bdfed47 --- /dev/null +++ b/docs/_klipper3d/css/extra.css @@ -0,0 +1,15 @@ +[data-md-color-scheme="slate"] { + --md-primary-fg-color: hsla(var(--md-hue),15%,12%,1); + --md-default-bg-color: hsla(var(--md-hue),17%,17%,1); + --md-typeset-a-color: steelblue; + --md-accent-fg-color: lightblue; +} + +img { + background-color: white; +} + +.center-image { + margin: 0 auto; + display: block; +} \ No newline at end of file diff --git a/docs/_klipper3d/mkdocs-requirements.txt b/docs/_klipper3d/mkdocs-requirements.txt new file mode 100644 index 00000000..6afd2723 --- /dev/null +++ b/docs/_klipper3d/mkdocs-requirements.txt @@ -0,0 +1,8 @@ +mkdocs==1.2.2 +mkdocs-material==7.2.0 +mkdocs-section-index==0.3.1 +mkdocs-simple-hooks==0.1.3 +mkdocs-exclude==1.0.2 +mdx-truly-sane-lists==1.2 +mdx-breakless-lists==1.0.1 +py-gfm==1.0.2 diff --git a/docs/_klipper3d/mkdocs_hooks.py b/docs/_klipper3d/mkdocs_hooks.py new file mode 100644 index 00000000..5b122a1d --- /dev/null +++ b/docs/_klipper3d/mkdocs_hooks.py @@ -0,0 +1,18 @@ +import re + +def transform(markdown: str, page, config, files): + in_list = False + lines = markdown.splitlines() + for i in range(len(lines)): + lines[i] = lines[i].replace('](../', + f"]({config['repo_url']}blob/master/") + lines[i] = re.sub(r"\\", "
", lines[i]) + # check that lists at level 0 are not indented (no space before *|-|1.) + if len(lines[i]) == 0: + in_list = False + elif re.match(r"^(\*|-|\d+\.) ", lines[i]): + in_list = True + if not in_list: + lines[i] = re.sub(r"^\s+(\*|-|\d+\.) ", r"\1 ", lines[i]) + output = "\n".join(lines) + return output diff --git a/docs/_layouts/README b/docs/_layouts/README deleted file mode 100644 index 266b60e4..00000000 --- a/docs/_layouts/README +++ /dev/null @@ -1,5 +0,0 @@ -This directory defines the https://www.klipper3d.org/ website. The -site is hosted using "github pages" (which uses Jekyll to -automatically convert the markdown files in the docs/ directory to -html). In addition to the files in this directory, the docs/CNAME and -docs/_config.yml file also control the website generation. diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html deleted file mode 100644 index 5bbb3cca..00000000 --- a/docs/_layouts/default.html +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - {% seo %} - - - - - - - - - - - - -
-
- - - - - -
-
- {{ content }} -
-
- -
-
- - - {% if site.google_analytics %} - - {% endif %} - - - - - - - - - - - - - - diff --git a/docs/_layouts/home.html b/docs/_layouts/home.html deleted file mode 100644 index 6f213fd0..00000000 --- a/docs/_layouts/home.html +++ /dev/null @@ -1,16 +0,0 @@ ---- -# This file defines the main https://www.klipper3d.org/ page. -layout: default ---- -

- -

Klipper is a 3d-Printer firmware. It combines the power of a general -purpose computer with one or more micro-controllers. See the -features document for more information on why you -should use Klipper.

- -

To begin using Klipper start by installing it.

- -

Klipper is Free Software. Read the documentation or -view -the Klipper code on github.

diff --git a/docs/img/favicon.ico b/docs/img/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..fae2846315ae6f8a13eb2ee5b6d367795479045d GIT binary patch literal 8222 zcmc&(3v5$W7(Qc$hf$Ged?VxGK*2t?wWYncTgM)(uK_}3Z3n3+)2J~9A2BFU5CkK^ z2Z|6A!$S}jwzUH>J`x@wF#(kj9|R?ckNAv;z+{`-uHS#x+ntu%_I7q~m(z3Z|NrMd z-*?V`{(J8kV|n;9PGI;gU_%QSyMZx=TV_O=jzV&}Hr~$Iu)N+P3v&DuaEonzx41Wz z+kjhG1RE*n6eg##x!m&0$sy<#mImDRwLz!-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