Skip to content

Commit

Permalink
chore: watch docs and template (serious-scaffold#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan authored Jul 10, 2024
1 parent ba48e0a commit 7a35361
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
git config --global user.name github-actions
git config --global user.email github-actions@github.com
- run: pipx install copier==9.3.1
- run: make consistency
- run: make template-build
- run: git diff
- run: git status --porcelain
- run: test -z "$(git status --porcelain)"
Expand Down
2 changes: 1 addition & 1 deletion .gitlab/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ consistency:
- git config --global user.name gitlab-ci
- git config --global user.email gitlab-ci@gitlab.com
- pipx install copier==9.3.1
- make consistency
- make template-build
- git diff
- git status --porcelain
- test -z "$(git status --porcelain)"
Expand Down
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean deepclean install dev prerequisites mypy ruff ruff-format pyproject-fmt codespell lint pre-commit test-run test build publish doc-autobuild doc-build doc-coverage doc consistency
.PHONY: clean deepclean install dev prerequisites mypy ruff ruff-format pyproject-fmt codespell lint pre-commit test-run test build publish doc-watch doc-build doc-coverage doc template-watch template-build

########################################################################################
# Variables
Expand Down Expand Up @@ -65,6 +65,7 @@ else
endif
pipx install --force pyproject-fmt==2.1.4
pipx install --force ruff==0.5.1
pipx install --force watchfiles==0.22.0

########################################################################################
# Lint and pre-commit
Expand Down Expand Up @@ -128,15 +129,13 @@ publish:
########################################################################################

# Generate documentation with auto build when changes happen.
doc-autobuild:
pdm run python -m sphinx_autobuild docs $(PUBLIC_DIR) \
--watch README.md \
--watch src \
-a
doc-watch:
pdm run python -m http.server --directory public &
watchfiles "make doc-build" docs src README.md

# Build documentation only from src.
doc-build:
pdm run python -m sphinx.cmd.build docs $(PUBLIC_DIR)
pdm run sphinx-build -a docs $(PUBLIC_DIR)

# Generate html coverage reports with badge.
doc-coverage: test-run
Expand All @@ -150,7 +149,10 @@ doc: doc-build mypy doc-coverage
# Template
########################################################################################

consistency:
template-watch:
watchfiles "make template-build" template includes copier.yaml

template-build:
find . -maxdepth 1 | grep -vE '(\.|\.git|template|includes|copier\.yaml|pdm\.lock)$$' | xargs -I {} rm -r {}
copier copy -r HEAD --data-file includes/copier-answers-sample.yml --data repo_platform=gitlab -f . .
rm -rf .copier-answers.yml
Expand Down
53 changes: 2 additions & 51 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ doc = [
"mypy[reports]",
"myst-parser",
"pytest",
"sphinx-autobuild",
"sphinx-click",
"sphinx-design",
]
Expand Down
20 changes: 11 additions & 9 deletions template/Makefile.jinja
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[% from pathjoin("includes", "variable.jinja") import page_url with context -%]
.PHONY: clean deepclean install dev prerequisites mypy ruff ruff-format pyproject-fmt codespell lint pre-commit test-run test build publish doc-autobuild doc-build doc-coverage doc
[%- if project_name == "Serious Scaffold Python" %] consistency[% endif %]
.PHONY: clean deepclean install dev prerequisites mypy ruff ruff-format pyproject-fmt codespell lint pre-commit test-run test build publish doc-watch doc-build doc-coverage doc
[%- if project_name == "Serious Scaffold Python" %] template-watch template-build[% endif %]

########################################################################################
# Variables
Expand Down Expand Up @@ -67,6 +67,7 @@ else
endif
pipx install --force pyproject-fmt==2.1.4
pipx install --force ruff==0.5.1
pipx install --force watchfiles==0.22.0

########################################################################################
# Lint and pre-commit
Expand Down Expand Up @@ -130,15 +131,13 @@ publish:
########################################################################################

# Generate documentation with auto build when changes happen.
doc-autobuild:
pdm run python -m sphinx_autobuild docs $(PUBLIC_DIR) \
--watch README.md \
--watch src \
-a
doc-watch:
pdm run python -m http.server --directory public &
watchfiles "make doc-build" docs src README.md

# Build documentation only from src.
doc-build:
pdm run python -m sphinx.cmd.build docs $(PUBLIC_DIR)
pdm run sphinx-build -a docs $(PUBLIC_DIR)

# Generate html coverage reports with badge.
doc-coverage: test-run
Expand All @@ -153,7 +152,10 @@ doc: doc-build mypy doc-coverage
# Template
########################################################################################

consistency:
template-watch:
watchfiles "make template-build" template includes copier.yaml

template-build:
find . -maxdepth 1 | grep -vE '(\.|\.git|template|includes|copier\.yaml|pdm\.lock)$$' | xargs -I {} rm -r {}
copier copy -r HEAD --data-file includes/copier-answers-sample.yml --data repo_platform=gitlab -f . .
rm -rf .copier-answers.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
git config --global user.name github-actions
git config --global user.email github-actions@github.com
- run: pipx install copier==9.3.1
- run: make consistency
- run: make template-build
- run: git diff
- run: git status --porcelain
- run: test -z "$(git status --porcelain)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ consistency:
- git config --global user.name gitlab-ci
- git config --global user.email gitlab-ci@gitlab.com
- pipx install copier==9.3.1
- make consistency
- make template-build
- git diff
- git status --porcelain
- test -z "$(git status --porcelain)"
Expand Down
1 change: 0 additions & 1 deletion template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ doc = [
"mypy[reports]",
"myst-parser",
"pytest",
"sphinx-autobuild",
"sphinx-click",
"sphinx-design",
]
Expand Down

0 comments on commit 7a35361

Please sign in to comment.