Skip to content

Commit b891c8b

Browse files
authored
chore: add textlint to devcontainer (#97)
Signed-off-by: Shunsuke Kimura <[email protected]>
1 parent 23bfcf8 commit b891c8b

File tree

4 files changed

+41
-14
lines changed

4 files changed

+41
-14
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
FROM rust:1.77-slim
22

3-
ARG USERNAME=typst-jp
3+
ARG USER_NAME=typst-jp
44
ARG USER_UID=1000
55
ARG USER_GID=$USER_UID
6+
ARG BUN_VERSION=1.1.37
67

7-
RUN groupadd --gid $USER_GID $USERNAME \
8-
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
9-
&& chsh -s /bin/bash $USERNAME \
8+
RUN groupadd --gid $USER_GID $USER_NAME \
9+
&& useradd --uid $USER_UID --gid $USER_GID -m $USER_NAME \
10+
&& chsh -s /bin/bash $USER_NAME \
1011
&& apt-get update \
1112
&& apt-get install -y --no-install-recommends \
1213
git \
1314
openssh-client \
15+
curl \
16+
unzip \
1417
python3 \
1518
python3-pip \
1619
&& python3 -m pip install --break-system-packages jinja2 PyYAML \
20+
&& su $USER_NAME -c 'curl -fsSL https://bun.sh/install | bash -s "bun-v$BUN_VERSION"' \
1721
&& apt-get clean \
1822
&& rm -rf /var/lib/apt/lists/*
1923

2024
WORKDIR /workspace
2125
ENV PATH="/root/.cargo/bin:${PATH}"
22-
USER $USERNAME
26+
USER $USER_NAME

.devcontainer/README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,33 @@
33
[Docker](https://docs.docker.com/)を用いてWebページの仕上がりを確認できます。
44
以下の操作はDockerがインストール済み、かつDockerデーモンを起動していることが前提となります。
55

6-
76
## VS Codeを使用している場合
87

98
[Dev Container](https://code.visualstudio.com/docs/devcontainers/containers)を使用します。
109
Visual Studio Codeでtypst-jp.github.ioディレクトリを開き、以下の操作を実施してください。
10+
1111
1. Ctrl+Shift+Pから`> Dev Containers: Reopen in Container`を実行
12-
2. Webサーバーが起動したらブラウザで http://localhost:3000 に接続
13-
3. ページを更新した際には、Ctrl+Shift+Pから`> Tasks: Run task`を実行し`gen: typst-jp documentation`を選択。ビルドが完了したらブラウザを更新。
12+
2. Webサーバーが起動したらブラウザで http://localhost:8000 に接続
13+
3. ページを更新した際には、Ctrl+Shift+Pから`> Tasks: Run task`を実行し`generate-docs`を選択、ビルドが完了したらブラウザを更新
14+
4. 体裁を確認したい場合、同様に`> Tasks: Run task`を実行し`textlint-md`(markdownファイルを翻訳した場合)または`textlint-html`(Rustソースコードを翻訳した場合)を選択
15+
5. 自動修正を実施したい場合、markdownファイルの添削であれば、同様に`textlint-md:fix`を選択(Rustコードは対応していなため、該当箇所を手動で修正してください。)
1416

1517

1618
## 別のエディターを使用している場合
1719

1820
ターミナルからDockerfileをビルドして、コマンド実行します。
1921
typst-jp.github.io ディレクトリ上で以下のコマンドを実行してください。
22+
2023
1. Docker imageをビルドしてコンテナを作成
2124
```
2225
docker build . -f .devcontainer/Dockerfile -t typst-jp-doc
23-
docker run --name typst-jp-doc -p 3000:3000 -it -v "$(pwd):/workspace" -w /workspace --rm typst-jp-doc /bin/bash
26+
docker run --name typst-jp-doc -p 8000:8000 -it -v "$(pwd):/workspace" -w /workspace --rm typst-jp-doc /bin/bash
2427
```
2528
2. Dockerコンテナ内でページを生成
2629
```
2730
cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && npx serve -n ./dist
2831
```
29-
3. Webサーバーが起動したらブラウザで http://localhost:3000 に接続
30-
4. ファイルを更新した際には、2 のコマンドを一旦 Ctrl+C で終了して再度実行、その後ブラウザを更新。
32+
3. Webサーバーが起動したらブラウザで http://localhost:8000 に接続
33+
4. ファイルを更新した際には、2 のコマンドを一旦 Ctrl+C で終了して再度実行、その後ブラウザを更新
34+
5. 体裁を確認したい場合には、初めの一回だけ`bun install --frozen-lockfile`を実行した後、`bun run textlint-md`や`bun run textlint-html`を実行
35+
6. markdownファイルの体裁を修正したい場合には`textlint-md:fix`を実行

.devcontainer/devcontainer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
"remoteUser": "typst-jp",
88
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
99
"workspaceFolder": "/workspace",
10-
"postStartCommand": "cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && python3 -m http.server -d dist",
11-
"postCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}"
10+
"postCreateCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
11+
"postStartCommand": "bun install --frozen-lockfile && cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && python3 -m http.server -d dist"
1212
}

.vscode/tasks.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,28 @@
22
"version": "2.0.0",
33
"tasks": [
44
{
5-
"label": "gen: typst-jp documentation",
5+
"label": "generate-docs",
66
"type": "shell",
77
"command": "cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && echo reload or open http://localhost:8000",
88
"problemMatcher": []
9+
},
10+
{
11+
"label": "textlint-md",
12+
"type": "shell",
13+
"command": "bun run textlint-md",
14+
"problemMatcher": []
15+
},
16+
{
17+
"label": "textlint-md:fix",
18+
"type": "shell",
19+
"command": "bun run textlint-md:fix",
20+
"problemMatcher": []
21+
},
22+
{
23+
"label": "textlint-html",
24+
"type": "shell",
25+
"command": "bun run textlint-html",
26+
"problemMatcher": []
927
}
1028
]
1129
}

0 commit comments

Comments
 (0)