-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
223 lines (192 loc) · 7.56 KB
/
Taskfile.yml
File metadata and controls
223 lines (192 loc) · 7.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# https://taskfile.dev
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3"
tasks:
build_book_ja:
desc: Build the Japanese version of the book
cmds:
- uv run jupyter-book build docs/ja
build_book_ja_all:
desc: Build the Japanese version of the book (force rebuild all notebooks)
cmds:
- uv run jupyter-book build docs/ja --all
open_book_ja:
desc: Open the Japanese version of the book
cmds:
- uv run python -m webbrowser file:///$(pwd)/docs/ja/_build/html/index.html
watch_book_ja:
desc: Watch Japanese notebooks and auto-rebuild of the book
cmds:
- fswatch -o docs/ja/**/*.ipynb | xargs -n1 -I{} jupyter-book build docs/ja
book_ja:
desc: Build and open the Japanese version of the book
cmds:
- task: build_book_ja
- task: open_book_ja
book_ja_all:
desc: Build and open the Japanese version of the book (force rebuild all notebooks)
cmds:
- task: build_book_ja_all
- task: open_book_ja
check_book_ja:
desc: Confirm that the Japanese version of the book builds without errors or warnings
cmds:
- uv run jupyter-book build docs/ja --all --warningiserror
build_book_en:
desc: Build the English version of the book
cmds:
- uv run jupyter-book build docs/en
build_book_en_all:
desc: Build the English version of the book (force rebuild all notebooks)
cmds:
- uv run jupyter-book build docs/en --all
open_book_en:
desc: Open the English version of the book
cmds:
- uv run python -m webbrowser file:///$(pwd)/docs/en/_build/html/index.html
watch_book_en:
desc: Watch English notebooks and auto-rebuild of the book
cmds:
- fswatch -o docs/en/**/*.ipynb | xargs -n1 -I{} jupyter-book build docs/en
book_en:
desc: Build and open the English version of the book
cmds:
- task: build_book_en
- task: open_book_en
book_en_all:
desc: Build and open the English version of the book (force rebuild all notebooks)
cmds:
- task: build_book_en_all
- task: open_book_en
check_book_en:
desc: Confirm that the English version of the book builds without errors or warnings
cmds:
- uv run jupyter-book build docs/en --all --warningiserror
create_unreleased_notes:
desc: Create release notes for the specified version
cmds:
- |
if [[ -f ./docs/en/releases/unreleased.ipynb || -f ./docs/ja/releases/unreleased.ipynb ]]; then
echo "[ERROR] Unreleased release notes already exist!" >&2;
exit 1;
fi
- cp ./templates/release_note_en.ipynb ./docs/en/releases/unreleased.ipynb
- cp ./templates/release_note_ja.ipynb ./docs/ja/releases/unreleased.ipynb
- uv run jupytext --sync --use-source-timestamp --execute ./docs/en/releases/unreleased.ipynb
- uv run jupytext --sync --use-source-timestamp --execute ./docs/ja/releases/unreleased.ipynb
- 'yq -i ''.parts[-2].chapters |= [{"file": "releases/unreleased"}] + .'' docs/ja/_toc.yml'
- 'yq -i ''.parts[-2].chapters |= [{"file": "releases/unreleased"}] + .'' docs/en/_toc.yml'
finalize_release_notes:
desc: Create release notes for the specified version
cmds:
- |
if [[ -z "{{.CLI_ARGS}}" ]]; then
echo "[ERROR] Version argument is required!" >&2;
exit 1;
fi
- |
if [[ ! -f ./docs/en/releases/unreleased.ipynb ]]; then
cp ./templates/release_note_en.ipynb ./docs/en/releases/unreleased.ipynb;
uv run jupytext --sync --use-source-timestamp --execute ./docs/en/releases/unreleased.ipynb
fi
if [[ ! -f ./docs/ja/releases/unreleased.ipynb ]]; then
cp ./templates/release_note_ja.ipynb ./docs/ja/releases/unreleased.ipynb;
uv run jupytext --sync --use-source-timestamp --execute ./docs/ja/releases/unreleased.ipynb
fi
- |
mv ./docs/en/releases/unreleased.ipynb ./docs/en/releases/jijmodeling-{{.CLI_ARGS}}.ipynb
mv ./markdowns/en/releases/unreleased.md ./markdowns/en/releases/jijmodeling-{{.CLI_ARGS}}.md
- |
mv ./docs/ja/releases/unreleased.ipynb ./docs/ja/releases/jijmodeling-{{.CLI_ARGS}}.ipynb
mv ./markdowns/ja/releases/unreleased.md ./markdowns/ja/releases/jijmodeling-{{.CLI_ARGS}}.md
- |
for LANG in ja en ; do
TOC=docs/${LANG}/_toc.yml
yq -i '.parts[-2].chapters |= filter(.file != "releases/unreleased")' "${TOC}"
yq -i '.parts[-2].chapters |= [{"file": "releases/jijmodeling-{{.CLI_ARGS}}"}] + .' "${TOC}"
done
sync_unreleased:
desc: Synchorizes just the `unreleased.ipynb` files with thier respective markdown files.
cmds:
- uv run jupytext --sync --use-source-timestamp markdowns/*/releases/unreleased.md
sync_paired_notebooks:
desc: Synchronize paired notebooks and markdown files
cmds:
- find docs -name "*.ipynb" -not -path "*/_build/*" -exec uv run jupytext --sync --use-source-timestamp --execute {} \;
sync_markdowns_to_notebooks:
cmds:
- git diff HEAD --name-only -- 'markdowns/**/*.md' | xargs -L 1 uv run jupytext --sync --use-source-timestamp --execute
sync_notebooks_to_markdowns:
cmds:
- git diff HEAD --name-only -- 'docs/**/*.ipynb' | xargs -L 1 uv run jupytext --sync --use-source-timestamp --execute
check_paired_notebooks:
desc: Check that all notebooks and markdown files are properly paired and synchronized
cmds:
- |
#!/bin/bash
# Check for the existence of corresponding Notebook/Markdown files
NOTEBOOKS=$(find docs -name "*.ipynb" -not -path "*/_build/*")
DOCS=$(echo "$NOTEBOOKS" | sed 's|^docs/||; s|.ipynb$||' | sort)
MDS=$(find markdowns -name "*.md" | sed 's|^markdowns/||; s|.md$||' | sort)
DIFF=$(diff <(echo "$DOCS") <(echo "$MDS")) || true
if [ -n "$DIFF" ]; then
echo "[FAILED] The following notebooks/md files are not paired:"
echo "$DIFF"
exit 1
fi
# Check for the synchronization between Notebooks and Markdown files
ERR=0;
while read -r TARG; do
LOG=$(uv run jupytext --pre-commit-mode --show-changes --sync $TARG) || true;
if grep -q "Error:" <<< "$LOG"; then
echo "$LOG"
ERR=1
fi
done <<< "$NOTEBOOKS";
if [ $ERR -ne 0 ]; then
echo "[FAILED] The notebooks/markdowns are not syncrhonized.";
exit 1;
fi
echo "[SUCCESS] All notebooks/markdowns are properly paired and synchronized.";
textlint:
desc: Run textlint on Japanese markdown files
cmds:
- npm i
- npx textlint "markdowns/{{.LANG}}/**/*.md"
textlint_all:
desc: Run textlint on Japanese markdown files
cmds:
- task: textlint_ja
- task: textlint_en
textlint_ja:
desc: Run textlint on Japanese markdown files
cmds:
- task: textlint
vars:
LANG: ja
textlint_en:
desc: Run textlint on English markdown files
cmds:
- task: textlint
vars:
LANG: en
textlint_fix:
desc: Run textlint --fix on markdown files
cmds:
- npm i
- npx textlint --fix "markdowns/{{.LANG}}/**/*.md"
textlint_fix_all:
desc: Run textlint --fix on markdown files
cmds:
- task: textlint_fix_ja
- task: textlint_fix_en
textlint_fix_ja:
desc: Run textlint --fix on Japanese markdown files
cmds:
- task: textlint_fix
vars: {LANG: ja}
textlint_fix_en:
desc: Run textlint --fix on English markdown files
cmds:
- task: textlint_fix
vars: {LANG: en}