Skip to content

Commit

Permalink
chore: Miscellaneous website improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenhilton committed Aug 21, 2023
1 parent 166feaf commit 7b300e4
Show file tree
Hide file tree
Showing 15 changed files with 484 additions and 495 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/main.yml
Expand Up @@ -17,7 +17,7 @@ env:
GOLINES_VERSION: 0.11.0
GOVERSIONINFO_VERSION: 1.4.0
FINDTYPOS_VERSION: 0.0.1
MKDOCS_VERSION: 1.5.1
MKDOCS_VERSION: 1.5.2
jobs:
changes:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -273,7 +273,9 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
- name: install-website-dependencies
run: pip3 install mkdocs==${{ env.MKDOCS_VERSION }} mkdocs-material mkdocs-mermaid2-plugin mkdocs-redirects mkdocs-simple-hooks
run: |
pip3 install mkdocs==${{ env.MKDOCS_VERSION }}
pip3 install -r assets/chezmoi.io/requirements.txt
- name: build-website
run: ( cd assets/chezmoi.io && mkdocs build )
env:
Expand Down Expand Up @@ -422,7 +424,8 @@ jobs:
go-version: ${{ env.GO_VERSION }}
- name: prepare-chezmoi.io
run: |
pip3 install mkdocs==${{ env.MKDOCS_VERSION }} mkdocs-material mkdocs-mermaid2-plugin mkdocs-redirects mkdocs-simple-hooks
pip3 install mkdocs==${{ env.MKDOCS_VERSION }}
pip3 install -r assets/chezmoi.io/requirements.txt
( cd assets/chezmoi.io && mkdocs build )
env:
CHEZMOI_GITHUB_TOKEN: ${{ secrets.CHEZMOI_GITHUB_TOKEN }}
Expand Down
33 changes: 29 additions & 4 deletions assets/chezmoi.io/docs/developer/website.md
Expand Up @@ -5,20 +5,45 @@ MkDocs](https://squidfunk.github.io/mkdocs-material/) from the contents of the
`assets/chezmoi.io/docs/` directory. It hosted by [GitHub pages](https://pages.github.com/) from
the [`gh-pages` branch](https://github.com/twpayne/chezmoi/tree/gh-pages).

Install Material for MkDocs and the required plugins with:
Change into the website directory:

```console
$ pip3 install mkdocs-material mkdocs-mermaid2-plugin mkdocs-redirects mkdocs-simple-hooks
$ cd assets/chezmoi.io
```

!!! note ""

=== "Default"

Install the website dependencies:

```console
$ pip3 install --user -r requirements.txt
```

=== "virutalenv (Recommended)"

Create a virtualenv with:

```console
$ python3 -m venv .venv
```

and [activate it](https://docs.python.org/3/library/venv.html#how-venvs-work).

Install the website dependencies:

```console
$ pip3 install -r requirements.txt
```

Test the website locally by running:

```console
$ cd assets/chezmoi.io
$ mkdocs serve
```

and visiting [https://127.0.0.1:8000/](http://127.0.0.1:8000/).
and visiting [http://127.0.0.1:8000/](http://127.0.0.1:8000/).

Deploy the website with:

Expand Down
31 changes: 16 additions & 15 deletions assets/chezmoi.io/docs/hooks.py
@@ -1,9 +1,7 @@
import os
import os.path
import subprocess

from pathlib import PurePosixPath, Path
from mkdocs import utils
from mkdocs.structure.files import File

non_website_paths = [
"docs.go",
Expand All @@ -22,18 +20,20 @@
"reference/release-history.md",
]


def on_pre_build(config, **kwargs):
docs_dir = config['docs_dir']
docs_dir = PurePosixPath(config['docs_dir'])
for src_path in templates:
output_path = docs_dir + "/" + src_path
template_path = output_path + '.tmpl'
data_path = output_path + '.yaml'
output_path = docs_dir.joinpath(src_path)
template_path = output_path.parent / (output_path.name + '.tmpl')
data_path = output_path.parent / (output_path.name + '.yaml')
args = ['go', 'run', '../../internal/cmds/execute-template']
if os.path.exists(data_path):
args += ['-data', data_path]
args += ['-output', output_path, template_path]
if Path(data_path).exists():
args.extend(['-data', data_path])
args.extend(['-output', output_path, template_path])
subprocess.run(args)


def on_files(files, config, **kwargs):
# remove non-website files
for src_path in non_website_paths:
Expand All @@ -48,16 +48,17 @@ def on_files(files, config, **kwargs):

return files


def on_post_build(config, **kwargs):
site_dir = config['site_dir']

# copy GitHub pages config
utils.copy_file('CNAME', os.path.join(site_dir, 'CNAME'))
utils.copy_file('CNAME', Path(site_dir, 'CNAME'))

# copy installation scripts
utils.copy_file('../scripts/install.sh', os.path.join(site_dir, 'get'))
utils.copy_file('../scripts/install-local-bin.sh', os.path.join(site_dir, 'getlb'))
utils.copy_file('../scripts/install.ps1', os.path.join(site_dir, 'get.ps1'))
utils.copy_file('../scripts/install.sh', Path(site_dir, 'get'))
utils.copy_file('../scripts/install-local-bin.sh', Path(site_dir, 'getlb'))
utils.copy_file('../scripts/install.ps1', Path(site_dir, 'get.ps1'))

# copy cosign.pub
utils.copy_file('../cosign/cosign.pub', os.path.join(site_dir, 'cosign.pub'))
utils.copy_file('../cosign/cosign.pub', Path(site_dir, 'cosign.pub'))
6 changes: 2 additions & 4 deletions assets/chezmoi.io/docs/links/articles.md.tmpl
Expand Up @@ -4,10 +4,8 @@

Recommended article: [Fedora Magazine: Take back your dotfiles with Chezmoi](https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/)

| Date | Version | Lang | Title |
| ---- | ------- | ---- | ----- |
| Date | Version | Language | Title |
| ---- | ------- | -------- | ----- |
{{- range mustReverse .articles }}
{{- if not (index . "formats") }}
| {{ .date }} | {{ .version }} | {{ index . "lang" | default "EN" }} | [{{ .title }}]({{ .url }}) |
{{- end }}
{{- end }}
1 change: 0 additions & 1 deletion assets/chezmoi.io/docs/links/articles.md.yaml

This file was deleted.

0 comments on commit 7b300e4

Please sign in to comment.