Skip to content
Merged
19 changes: 19 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Rust v1.77 as a base image
FROM rust:1.77-slim

RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
# install python3, jinja2 pyyaml
python3 \
python3-pip \
&& python3 -m pip install --break-system-packages jinja2 PyYAML \
# install nodejs and serve
&& curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g [email protected] \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \

WORKDIR /workspace
ENV PATH="/root/.cargo/bin:${PATH}"
24 changes: 24 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Dev Containerについて

Visual Studio Codeで編集する場合には、[Dev Container](https://code.visualstudio.com/docs/devcontainers/containers)を使用してローカル環境でWebページの仕上がりを確認することができます。
Visual Studio Codeでtypst-jp.github.ioディレクトリを開き以下の操作を実施してください。
1. Ctrl+Shift+Pから`> Dev Containers: Reopen in Container`を実行
2. ビルドが完了したらブラウザで http://localhost:3000 に接続
3. ページを更新した際には、Ctrl+shift+Pから`> Tasks: Run task`を実行し`preview: typst-jp documentation`を選択。ビルドが完了したらブラウザを更新。


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

別のエディターで編集している場合にもDockerfileの使用のみであれば可能です。
ターミナルから typst-jp.github.io ディレクトリ上で以下のコマンドを実行してください。
1. Docker imageをビルドして実行
```
docker build . -f .devcontainer/Dockerfile -t typst-jp-doc
docker run --name typst-jp-doc -p 3000:3000 -it -v "$(pwd):/workspace" -w /workspace --rm typst-jp-doc /bin/bash
```
2. Dockerコンテナ内でビルド
```
cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && npx serve -n ./dist
```
3. ビルドが完了したらブラウザで http://localhost:3000 に接続
4. ファイルを更新した際には、2 のコマンドを再度実行して、ブラウザを更新。
11 changes: 11 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "typst-jp-domumentation",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"forwardPorts": [3000],
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
"workspaceFolder": "/workspace",
"postStartCommand": "cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && npx serve -n ./dist"
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# General
.vscode
# .vscode
.idea
_things
desktop.ini
Expand Down
11 changes: 11 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "preview: typst-jp documentation",
"type": "shell",
"command": "cargo test --package typst-docs --lib -- tests::test_docs --exact --nocapture && python3 ./gen.py && echo reload or open http://localhost:3000",
"problemMatcher": []
}
]
}