๊ฐ๋ฐ - ๊ธฐ์ฌ¶
๋จผ์ help FastAPI and get help์์ ๊ธฐ๋ณธ ๋ฐฉ๋ฒ์ ๋ณด๊ณ ๋์์ ์ป๋ ๊ฒ์ด ์ข์์ง๋ ๋ชจ๋ฆ ๋๋ค.
๊ฐ๋ฐ¶
์ด๋ฏธ ์ ์ฅ์๋ฅผ Cloneํ๊ณ , ์ฝ๋๋ฅผ ์กฐ์ฌํ๊ฒ ์๊ณ ์ถ์ ๊ฒฝ์ฐ์ ํ๊ฒฝ ๊ตฌ์ถ์ ์ํ ๋ช ๊ฐ์ง ๊ฐ์ด๋๋ผ์ธ์ด ์์ต๋๋ค.
venv
๋ฅผ ์ด์ฉํ ๊ฐ์ํ๊ฒฝ¶
Python์ venv
๋ชจ๋์ ์ฌ์ฉํ์ฌ ๋๋ ํ ๋ฆฌ์ ๊ฐ์ ํ๊ฒฝ์ ๋ง๋ค ์ ์์ต๋๋ค:
$ python -m venv env
๊ทธ๋ฌ๋ฉด Python ๋ฐ์ด๋๋ฆฌ๋ฅผ ํฌํจํ ./env/
๋๋ ํ ๋ฆฌ๊ฐ ์์ฑ๋๊ณ ๊ทธ ๊ณ ๋ฆฝ๋ ํ๊ฒฝ์ ํจํค์ง๋ฅผ ์ค์นํ ์ ์์ต๋๋ค.
๊ฐ์ ํ๊ฒฝ ํ์ฑํ¶
์๋ก์ด ํ๊ฒฝ์ ํ์ฑํํ๋ ค๋ฉด:
<div class="termy">
```console
$ source ./env/bin/activate
```
</div>
<div class="termy">
```console
$ .\env\Scripts\Activate.ps1
```
</div>
Or if you use Bash for Windows (e.g. <a href="https://gitforwindows.org/" class="external-link" target="_blank">Git Bash</a>):
<div class="termy">
```console
$ source ./env/Scripts/activate
```
</div>
๋์ ํ์ธ์ ์ํด ๋ค์์ ์คํํ์ญ์์ค:
<div class="termy">
```console
$ which pip
some/directory/fastapi/env/bin/pip
```
</div>
<div class="termy">
```console
$ Get-Command pip
some/directory/fastapi/env/bin/pip
```
</div>
env/bin/pip
์ pip
๋ฐ์ด๋๋ฆฌ๊ฐ ๋ํ๋๋ค๋ฉด ์ ๋๋ก ์๋ํ๊ณ ์๋ ๊ฒ์
๋๋ค. ๐
ํ
์ด ํ๊ฒฝ ์๋์ pip
์์ ์ ํจํค์ง๋ฅผ ์ค์นํ ๋๋ง๋ค, ๊ฐ์ ํ๊ฒฝ์ ๋ค์ ํ์ฑํ ํฉ๋๋ค.
This makes sure that if you use a terminal program installed by that package (like `flit`), you use the one from your local environment and not any other that could be installed globally.
Flit¶
FastAPI ๋ Flit ์ ์ฌ์ฉํ์ฌ ํ๋ก์ ํธ๋ฅผ ๋น๋, ํจํค์ง, publishํฉ๋๋ค.
์์ ๊ฐ์ด ํ๊ฒฝ์ ํ์ฑํ ํ ํ, flit
์ ์ค์นํฉ๋๋ค:
$ pip install flit
---> 100%
์ด์ ํ๊ฒฝ์ ๋ค์ ํ์ฑํํ์ฌ ์ค์นํ flit
์ด ์ ์ญ์ด ์๋ ํ๊ฒฝ์์ ์ฌ์ฉ๋๊ณ ์๋์ง ํ์ธํ์ญ์์ค.
๊ทธ๋ฆฌ๊ณ flit
์ ์ฌ์ฉํ์ฌ ๊ฐ๋ฐ ์ข
์์ฑ์ ์ค์นํฉ๋๋ค :
<div class="termy">
```console
$ flit install --deps develop --symlink
---> 100%
```
</div>
If you are on Windows, use `--pth-file` instead of `--symlink`:
<div class="termy">
```console
$ flit install --deps develop --pth-file
---> 100%
```
</div>
์ด์ ๋ชจ๋ ์ข ์์ฑ๊ณผ FastAPI๋ฅผ ๋น์ ์ ๋ก์ปฌํ๊ฒฝ์ ์ค์นํฉ๋๋ค.
๋ก์ปฌ ํ๊ฒฝ์์์ FastAPI ์ฌ์ฉ¶
FastAPI๋ฅผ ๊ฐ์ ธ์ค๊ณ ์ฌ์ฉํ๋ Python ํ์ผ์ ๋ง๋ค์ด, ๋ก์ปฌ ํ๊ฒฝ์ ์ค์น๋ Python์ผ๋ก ์คํํ๋ฉด, ๋ก์ปฌ FastAPI ์์ค์ฝ๋๊ฐ ์ฌ์ฉ๋ฉ๋๋ค.
๊ทธ๋ฆฌ๊ณ --symlink
(Windows์ ๊ฒฝ์ฐ --pth-file
)์ ์ค์น๋์ด์๋ ๋ก์ปฌ FastAPI ์์ค์ฝ๋๋ฅผ ์
๋ฐ์ดํธํ ๊ฒฝ์ฐ, Python ํ์ผ์ ๋ค์ ์คํํ๋ฉด, ์๋ก์ด ๋ฒ์ ์ FastAPI๋ฅผ ์ฌ์ฉํฉ๋๋ค.
์ด๋ฐ ๋ฐฉ๋ฒ์ผ๋ก ๋ก์ปฌ๋ฒ์ ์ "install" ํ์ง ์๊ณ ๋ชจ๋ ๋ณ๊ฒฝ ์ฌํญ์ ํ ์คํธ ํ ์ ์์ต๋๋ค.
Format¶
๋ชจ๋ ์ฝ๋๋ฅผ ํฌ๋งทํ๊ณ ์ง์์ฃผ๋ ์คํฌ๋ฆฝํธ๊ฐ ์์ต๋๋ค :
$ bash scripts/format.sh
๋ํ ๋ชจ๋ ๊ฐ์ ธ์ค๊ธฐ๋ฅผ ์๋์ผ๋ก ์ ๋ ฌํฉ๋๋ค.
์ฌ๋ฐ๋ฅด๊ฒ ์ ๋ ฌํ๋ ค๋ฉด, ์ ์น์
์ ๋ช
๋ น์ธ --symlink
(Windows์ ๊ฒฝ์ฐ --pth-file
)์ ์ฌ์ฉํ์ฌ FastAPI๋ฅผ ๋ก์ปฌํ๊ฒฝ์ ์ค์นํด์ผ ํฉ๋๋ค.
Format imports¶
์ด์ธ์๋ ๋ชจ๋ import๋ฅผ ํฌ๋งทํ๊ณ ์ฌ์ฉํ์ง ์์ import๊ฐ ์๋์ง ํ์ธํ๋ ์คํฌ๋ฆฝํธ๊ฐ ์์ต๋๋ค:
$ bash scripts/format-imports.sh
์ฌ๋ฌ ๋ช
๋ น์ ์ฐจ๋ก๋ก ์คํํ๊ณ ๋ง์ ํ์ผ์ ์์ ํ๊ณ ๋๋๋ฆฌ๊ธฐ ๋๋ฌธ์ ์๊ฐ์ด ์กฐ๊ธ ๋ ๊ฑธ๋ฆฝ๋๋ค. ๊ทธ๋์ scripts/format.sh
๋ฅผ ์์ฃผ ์ฌ์ฉํ๊ณ , scripts/format-imports.sh
๋ ์ปค๋ฐํ๊ธฐ ์ ์ ์คํํ๋ ๊ฒ์ด ์ข์ต๋๋ค .
Docs¶
๋จผ์ ์์ ๊ฐ์ด ํ๊ฒฝ์ ์ค์ ํ๋ค๋ฉด ํ์ํ ๋ชจ๋ ํจํค์ง๊ฐ ์ค์น๋ฉ๋๋ค.
๋ฌธ์ํ ํ๋๋ฐ MkDocs ๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
๊ทธ๋ฆฌ๊ณ ๋ฒ์ญ์ ์ฒ๋ฆฌํ๊ธฐ ์ํ ์ถ๊ฐ ๋๊ตฌ / ์คํฌ๋ฆฝํธ์ธ ./scripts/docs.py
๊ฐ ์์ต๋๋ค.
ํ
./scripts/docs.py
์ ์ฝ๋๋ฅผ ๋ณผ ํ์๋ ์๊ณ , ๊ทธ๋ฅ ๋ช
๋ นํ์์ ์ฌ์ฉํ๋ฉด ๋ฉ๋๋ค.
๋ชจ๋ ๋ฌธ์๋ Markdown ํ์์ผ๋ก ./docs/en/
๋๋ ํ ๋ฆฌ์ ์์ต๋๋ค.
๋ง์ ํํ ๋ฆฌ์ผ์ ์ฝ๋ ๋ธ๋ก์ด ์์ต๋๋ค.
๋๋ถ๋ถ์ ๊ฒฝ์ฐ, ์ด๋ฌํ ์ฝ๋ ๋ธ๋ก๋ค์ ์๋ ๊ทธ๋๋ก ์คํํ ์ ์๋ ์์ ํ ์์ฉํ๋ก๊ทธ๋จ์ ๋๋ค.
์ฌ์ค, ์ด๋ฌํ ์ฝ๋ ๋ธ๋ก๋ค์ Markdown ๋ด๋ถ์ ์์ฑ๋์ง ์๊ณ , ./docs_src/
๋๋ ํ ๋ฆฌ์ ์๋ Python ํ์ผ์
๋๋ค.
๊ทธ๋ฆฌ๊ณ ํด๋น Python ํ์ผ์ ์ฌ์ดํธ๋ฅผ ์์ฑํ ๋ ๋ฌธ์์ ํฌํจ/์ฝ์ ๋ฉ๋๋ค.
Docs for tests¶
๋๋ถ๋ถ์ ํ ์คํธ๋ ์ค์ ๋ฌธ์์ ์์ ์์ค ํ์ผ์ ๋ํด ์คํ๋ฉ๋๋ค.
๊ทธ๋ฌ๋ฉด ๋ค์์ ํ์ธํ ์ ์์ต๋๋ค :
- ๋ฌธ์๊ฐ ์ต์ ์ํ์ธ๊ฐ?
- ๋ฌธ์์ ์์ ๋ฅผ ๊ทธ๋๋ก ์คํํ ์ ์๋๊ฐ?
- ๋๋ถ๋ถ์ ๊ธฐ๋ฅ์ด ๋ฌธ์์ ํฌํจ๋์ด ์์ผ๋ฉฐ, ํ ์คํธ ๋ฒ์์์ ๋ณด์ฅ๋๋๊ฐ?
๋ก์ปฌ ๊ฐ๋ฐ ์ค์, ์ฌ์ดํธ๋ฅผ ๊ตฌ์ถํ์ฌ ๋ณ๊ฒฝ ์ฌํญ์ ์ ๋ฌด๋ฅผ ํ์ธํ๋ ์คํฌ๋ฆฝํธ๊ฐ live-reloading ๋ฉ๋๋ค:
$ python ./scripts/docs.py live
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
<span style="color: green;">[INFO]</span> Start watching changes
<span style="color: green;">[INFO]</span> Start detecting changes
๋ฌธ์๋ http://127.0.0.1:8008
์์ ์ ๊ณต๋ฉ๋๋ค.
์ด ๋ฐฉ๋ฒ์ผ๋ก, ๋ฌธ์/์์ค ํ์ผ ์ ํธ์งํ๊ณ ๋ณ๊ฒฝ์ฌํญ์ ์ค์๊ฐ์ผ๋ก ๋ณผ ์ ์์ต๋๋ค.
Typer CLI (optional)¶
./scripts/docs.py
์์๋ python
ํ๋ก๊ทธ๋จ์์ ์ง์ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ์ค๋ช
ํฉ๋๋ค.
ํ์ง๋ง Typer CLI ๋ฅผ ์ฌ์ฉํ์ฌ ์ค์นํ๋ค๋ฉด, ์ค์น๊ฐ ์๋ฃ๋ ํ ํฐ๋ฏธ๋์์ ์๋ ์์ฑ ๊ธฐ๋ฅ์ ํ ์ ์์ต๋๋ค.
๋ค์์ ์ด์ฉํ์ฌ Typer CLI๋ฅผ ์ค์น๋ฅผ ์๋ฃํ ์ ์์ต๋๋ค:
$ typer --install-completion
zsh completion installed in /home/user/.bashrc.
Completion will take effect once you restart the terminal.
Apps and docs at the same time¶
๋ค์๊ณผ ๊ฐ์ด ์ํ์ ์คํํ๋ฉด :
$ uvicorn tutorial001:app --reload
<span style="color: green;">INFO</span>: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
Uvicorn์ ๊ธฐ๋ณธ ๊ฐ์ผ๋ก port 8000
์ ์ฌ์ฉํ๊ธฐ ๋๋ฌธ์, port 8008
์ ๋ฌธ์์ ์ถฉ๋ํ์ง ์์ต๋๋ค.
Translations¶
๋ฒ์ญ์ ๋ํ ๋์์ ๋งค์ฐ ํ์ํฉ๋๋ค! ๊ทธ๋ฆฌ๊ณ ์ด๊ฒ์ ์ปค๋ฎค๋ํฐ์ ๋์ ์์ด ์ด๋ฃฐ ์ ์์ต๋๋ค. ๐ ๐
๋ฒ์ญ์ ์ง์ํ๊ธฐ ์ํ ์ ์ฐจ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
Tips and guidelines¶
- ๋น์ ์ ์ธ์ด๋ฅผ existing pull requests ์์ ํ์ธํ๊ณ , ๋ณ๊ฒฝ์ ์์ฒญํ๊ฑฐ๋ ์น์ธํ๋ ๋ฆฌ๋ทฐ๋ฅผ ์ถ๊ฐํฉ๋๋ค.
ํ
์ด๋ฏธ ์กด์ฌํ๋ pull requests์ add comments with change suggestions ํ ์ ์์ต๋๋ค.
Check the docs about <a href="https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-reviews" class="external-link" target="_blank">adding a pull request review</a> to approve it or request changes.
- issues ์์ ๋น์ ์ ์ธ์ด์ ๋ํ ๋ฒ์ญ์ด ์๋์ง ํ์ธํ์ญ์์ค.
- ๋ฒ์ญํ๋ ํ์ด์ง ๋น ํ ๊ฐ์ pull request๋ฅผ ์ถ๊ฐํ์ญ์์ค. ์ด๊ฒ์ ๋ค๋ฅธ ์ฌ์ฉ์๊ฐ ๊ฒํ ํ๊ธฐ ์ฌ์์ง๋๋ค.
์ ๊ฐ ํ ์ ์๋ ์ธ์ด์ ๊ฒฝ์ฐ, ๋ณํฉํ๊ธฐ ์ ์ ๋ค๋ฅธ ์ฌ๋ฌ ์ฌ์ฉ์๊ฐ ๋ฒ์ญ์ ๊ฒํ ํ ๋๊น์ง ๊ธฐ๋ค๋ฆฌ๊ฒ ์ต๋๋ค.
- ์์ ์ ์ธ์ด๊ฐ ๋ฒ์ญ๋๊ณ ์๋์ง ํ์ธํ๊ณ , ๊ทธ๊ฒ์ ๋ฆฌ๋ทฐ๋ฅผ ์ถ๊ฐํ ์ ์์ต๋๋ค. ๋ฆฌ๋ทฐ๋ ๋ฒ์ญ์ด ์ ์ด๋ฃจ์ด์ก๋์ง ํ์ธ ํ ์ ์๊ณ , ๊ทธ๊ฒ์ ๋ณํฉํ ์ ์์ต๋๋ค.
- ๊ฐ์ Python ์์๋ฅผ ์ฌ์ฉํ๊ณ ๋ฌธ์๋ด์ ์๋ ํ ์คํธ๋ง์ ๋ฒ์ญํฉ๋๋ค. ์ด ์์ ์ค์ ์๋ฌด๊ฒ๋ ๋ณ๊ฒฝํ ํ์๊ฐ ์์ต๋๋ค.
- ๊ฐ์ ์ด๋ฏธ์ง, ํ์ผ, ๋งํฌ๋ฅผ ์ฌ์ฉํ์ญ์์ค. ์ด ์์ ์ค์ ์๋ฌด๊ฒ๋ ๋ณ๊ฒฝํ ํ์๊ฐ ์์ต๋๋ค.
- ๋ฒ์ญ์ ์ํ๋ ์ธ์ด์ ๋ ๋ฌธ์๋ก ๋ ์ฝ๋๋ฅผ ํ์ธํ๋ ค๋ฉด ํ List of ISO 639-1 codes ๋ฅผ ์ด์ฉํ ์ ์์ต๋๋ค.
Existing language¶
์คํ์ธ์ด์ฒ๋ผ ์ด๋ฏธ ์ผ๋ถ ํ์ด์ง๊ฐ ๋ฒ์ญ๋์ด ์๋ ์ธ์ด์ ๋ฒ์ญ์ ์ถ๊ฐํ๊ณ ์ถ๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.
์คํ์ธ์ด์ ๊ฒฝ์ฐ, ๋ ๋ฌธ์๋ก ๋ ์ฝ๋๊ฐ es
์
๋๋ค. ๋ฐ๋ผ์ ์คํ์ธ์ด์ ๋๋ ํ ๋ฆฌ๋ docs/es/
์ ์์ต๋๋ค.
ํ
๋ฉ์ธ ("๊ณต์") ์ธ์ด๋ ์์ด์ด๊ณ , docs/en/
์ ์์ต๋๋ค.
์ด์ ์คํ์ธ์ด๋ก ์์ฑ๋ ๋ฌธ์๋ฅผ ๋ผ์ด๋ธ ์๋ฒ์์ ์คํํฉ๋๋ค :
// Use the command "live" and pass the language code as a CLI argument
$ python ./scripts/docs.py live es
<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008
<span style="color: green;">[INFO]</span> Start watching changes
<span style="color: green;">[INFO]</span> Start detecting changes
์ด์ http://127.0.0.1:8008 ์ ์ด์ด ์์ ํ ๋ด์ฉ์ ํ์ธํ ์ ์์ต๋๋ค.
FastAPI ๋ฌธ์ ์น ์ฌ์ดํธ๋ฅผ ๋ณด๋ฉด ๋ชจ๋ ์ธ์ด์ ๋ชจ๋ ํ์ด์ง๊ฐ ์์์ ์ ์ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ์ผ๋ถ ํ์ด์ง๋ ๋ฒ์ญ๋์ง ์๊ณ , ๋๋ฝ๋ ๋ฒ์ญ์ ๋ํ ์๋ฆผ์ด ์์ต๋๋ค.
ํ์ง๋ง ์ด๋ฐ ๋ฐฉ๋ฒ์ผ๋ก ๋ก์ปฌ์์ ์คํํ๋ฉด ๋ฒ์ญ๋ ํ์ด์ง๋ง ํ์๋ฉ๋๋ค.
Now let's say that you want to add a translation for the section Features.
- ๋ค์ ํ์ผ์ ๋ณต์ฌํฉ๋๋ค :
docs/en/docs/features.md
- ๋ฒ์ญํ๊ณ ์ถ์ ์ธ์ด๋ฅผ ์ํด์ ์ด๊ฒ์ ์ ํํ ๊ฐ์ ์์น์ ๋ถ์ฌ ๋ฃ์ต๋๋ค. ์๋ฅผ๋ค๋ฉด:
docs/es/docs/features.md
ํ
๊ฒฝ๋ก์ ํ์ผ์ ์ ์ผํ ๋ณ๊ฒฝ ์ฌํญ์ en
์์ es
๋ก ๋ฐ๊พธ๋ ์ธ์ด์ฝ๋์
๋๋ค.
- ์ด์ ์์ด๋ก๋ MkDocs config file ์ ์ฝ๋๋ค :
docs/en/docs/mkdocs.yml
- config file์์
docs/features.md
์ ์์น๋ฅผ ์ฐพ์ต๋๋ค. :
site_name: FastAPI
# More stuff
nav:
- FastAPI: index.md
- Languages:
- en: /
- es: /es/
- features.md
- ํธ์งํ๊ณ ์ ํ๋ ์ธ์ด์ MkDocs ๊ตฌ์ฑ ํ์ผ์ ์ฝ๋๋ค, ์๋ฅผ ๋ค๋ฉด:
docs/es/docs/mkdocs.yml
- ๊ทธ๊ฒ์ ์์ด์ ๋๊ฐ์ ์์น์ ์ถ๊ฐํฉ๋๋ค, ์๋ฅผ ๋ค๋ฉด:
site_name: FastAPI
# More stuff
nav:
- FastAPI: index.md
- Languages:
- en: /
- es: /es/
- features.md
๋ค๋ฅธ ํญ๋ชฉ์ด ์๋ ๊ฒฝ์ฐ์๋ ๋ฒ์ญ์ ํฌํจํ ์๋ก์ด ํญ๋ชฉ์ด ์์ด ๋ฒ์ ๊ณผ ๋์ผํ ์์๋ก๋์ด ์๋์ง ํ์ธํ์ญ์์ค.
๋ธ๋ผ์ฐ์ ์ ์ ์ํ๋ฉด ๋ฌธ์์ ์๋ก์ด ์น์ ์ด ํ์๋์ด ์๋ ๊ฒ์ ํ์ธํ ์ ์์ต๋๋ค. ๐
์ด์ ๋ชจ๋ ๊ฒ์ ๋ฒ์ญํ ์ ์๊ณ , ํ์ผ์ ์ ์ฅ ์ํ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
New Language¶
์์ง ๋ฒ์ญ๋์ง ์์ ์ธ์ด์ ๋ฒ์ญ์ผ๋ก ์ถ๊ฐํ๊ณ ์ถ๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.
Creole์ด ๋ฒ์ญ์ ์ถ๊ฐํ๊ณ ์ถ์ง๋ง, ์์ง ๋ฌธ์์ ์์ต๋๋ค.
์์ ๋งํฌ๋ฅผ ํ์ธํ๋ฉด "Creole"์ ๋ฌธ์์ฝ๋๋ ht
์
๋๋ค.
๋ค์ ๋จ๊ณ๋ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ์ฌ ์๋ก์ด ๋ฒ์ญ ๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํ๋ ๊ฒ์ ๋๋ค :
// Use the command new-lang, pass the language code as a CLI argument
$ python ./scripts/docs.py new-lang ht
Successfully initialized: docs/ht
Updating ht
Updating en
์ด์ ์ฝ๋ํธ์ง๊ธฐ์์ ์๋ก ์์ฑ๋ docs/ht/
๋๋ ํ ๋ฆฌ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
ํ
Create a first pull request with just this, to set up the configuration for the new language, before adding translations.
์ด๋ ๊ฒ ํ๋ฉด ์ฒซ ๋ฒ์งธ ํ์ด์ง์์ ์์
ํ๋ ๋์ ๋๊ตฐ๊ฐ ๋ค๋ฅธ ํ์ด์ง ์์
์ ๋์ธ ์ ์์ต๋๋ค. ๐
๋จผ์ ๋ฉ์ธ ํ์ด์ง์ docs/ht/index.md
๋ฅผ ๋ฒ์ญํฉ๋๋ค.
๊ทธ ํ "๊ธฐ์กด์ ์ธ์ด"์ ๋ํ ์ด์ ์ ์ง์๋ฅผ ๊ณ์ํ ์ ์์ต๋๋ค.
New Language not supported¶
๋ผ์ด๋ธ ์๋ฒ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ ๋ ์ง์๋์ง ์๋ ์ธ์ด์ ๋ํ ์ค๋ฅ๊ฐ ๋ฐ์ํ ๊ฒฝ์ฐ์๋ ๋ค์๊ณผ ๊ฐ์ด ํ์๋ฉ๋๋ค :
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: partials/language/xx.html
์ด๊ฒ์ ํ
๋ง๊ฐ ํด๋น ์ธ์ด๋ฅผ ์ง์ํ์ง ์๋๋ค๋ ๊ฒ์ ์๋ฏธํฉ๋๋ค (์ด ๊ฒฝ์ฐ, xx
์ ๋ ๋ฌธ์๋ก ๋ ๊ฐ์ง ์ฝ๋).
๊ทธ๋ฌ๋ ๊ฑฑ์ ํ์ง ๋ง์ญ์์ค, ํ ๋ง ์ธ์ด๋ฅผ ์์ด๋ก ์ค์ ํ์ฌ ๋ฌธ์์ ๋ด์ฉ์ ๋ฒ์ญํ ์ ์์ต๋๋ค.
๊ทธ ํ์๊ฐ ์๋ ๊ฒฝ์ฐ, ์๋ก์ด ์ธ์ด์ mkdocs.yml
๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ํธ์งํ์ญ์์ค:
site_name: FastAPI
# More stuff
theme:
# More stuff
language: xx
์ธ์ด๋ฅผ xx
(๋น์ ์ ์ธ์ด ์ฝ๋) ์์ en
์ผ๋ก ๋ณ๊ฒฝํฉ๋๋ค.
๊ทธ ํ ๋ผ์ด๋ธ ์๋ฒ๋ฅผ ๋ค์ ์์ํฉ๋๋ค.
Preview the result¶
./scripts/docs.py
์คํฌ๋ฆฝํธ๋ฅผ live
๋ช
๋ น์ผ๋ก ์คํํ๋ฉด ํ์ฌ์ ์ธ์ด์์ ์ด์ฉ๊ฐ๋ฅํ ํ์ผ๊ณผ ๋ฒ์ญ๋ง ํ์๋ฉ๋๋ค.
๊ทธ๋ฌ๋ ์ผ๋จ ์คํ๋๋ฉด ์จ๋ผ์ธ์์ ๋ณด์ด๋ ๊ฒ๊ณผ ๊ฐ์ด ๋ชจ๋ ํ ์คํธ ํ ์ ์์ต๋๋ค.
์ด๋ฅผ ์ํด, ๋จผ์ ๋ชจ๋ ๋ฌธ์๋ฅผ ๋น๋ํฉ๋๋ค :
// Use the command "build-all", this will take a bit
$ python ./scripts/docs.py build-all
Updating es
Updating en
Building docs for: en
Building docs for: es
Successfully built docs for: es
Copying en index.md to README.md
์ด์ ์ธ์ด๋ง๋ค ./docs_build/
์ ์๋ ๋ชจ๋ ๋ฌธ์๊ฐ ์์ฑ๋ฉ๋๋ค. ์ฌ๊ธฐ์๋ ๋ฒ์ญ์ด ๋๋ฝ๋ ํ์ผ์ ์ถ๊ฐํ๋ ๊ฒ๊ณผ "์ด ํ์ผ์๋ ๋ฒ์ญ์ด ์์ง ์์ต๋๋ค" ๋ผ๋ ๋ฉ๋ชจ๊ฐ ํฌํจ๋์ด ์์ต๋๋ค. ๊ทธ๋ฌ๋ ๊ทธ ๋๋ ํ ๋ฆฌ์์ ์๋ฌด๊ฒ๋ ํ ํ์๊ฐ ์์ต๋๋ค.
๊ทธ๋ฐ ๋ค์ ๊ฐ ์ธ์ด์ ๋ํ ๋ชจ๋ ๋
๋ฆฝ MkDocs ์ฌ์ดํธ๋ฅผ ๋น๋ํ์ฌ ๊ทธ๊ฒ๋ค์ ๊ฒฐํฉํ๊ณ ./site/
์์ ์์ฑํ๋ค.
๊ทธ๋ฌ๋ฉด serve
๋ช
๋ น์ผ๋ก ๊ทธ๊ฒ์ ์ฒ๋ฆฌํ ์ ์์ต๋๋ค:
// Use the command "serve" after running "build-all"
$ python ./scripts/docs.py serve
Warning: this is a very simple server. For development, use mkdocs serve instead.
This is here only to preview a site with translations already built.
Make sure you run the build-all command first.
Serving at: http://127.0.0.1:8008
Tests¶
๋ก์ปฌ์์ ๋ชจ๋ ์ฝ๋๋ฅผ ํ ์คํธํ๊ณ HTML์์ coverage ๋ณด๊ณ ์๋ฅผ ์์ฑํ๊ธฐ ์ํ ์คํฌ๋ฆฝํธ๊ฐ ์์ต๋๋ค:
$ bash scripts/test-cov-html.sh
์ด ๋ช
๋ น์ ./htmlcov/
๋๋ ํ ๋ฆฌ๋ฅผ ์์ฑํฉ๋๋ค. ๋ธ๋ผ์ฐ์ ์์ ./htmlcov/index.html
ํ์ผ์ ์ด๋ฉด, ํ
์คํธ์ ํฌํจ๋ ์ฝ๋์ ์์ญ์ ๋ํ์์ผ๋ก ํ์ํ ์ ์๊ณ ๋๋ฝ๋ ์์ญ์ด ์๋์ง ํ์ธํ ์ ์์ต๋๋ค.