Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Miscellaneous website improvements #3181

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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.

Loading
Loading