MkDocs์—์„œ PlantUML ํ‘œ์‹œ

์ž์‹ ์€ ๋ฌธ์„œ๋ฅผ ์ž‘์„ฑํ•  ๋•Œ PlantUML์„ ์ƒ๋‹นํžˆ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
์กฐ๊ธˆ ์˜ค๋žœ๋งŒ์— ์ƒ๋‹นํ•œ ์–‘์˜ ๋ฌธ์„œ๋ฅผ ์“ธ ํ•„์š”์„ฑ์ด ๋‚˜์™”๊ธฐ ๋•Œ๋ฌธ์— MkDocs๋กœ ํ™˜๊ฒฝ ์ •๋ˆํ•˜๋ ค๊ณ  ์ƒ๊ฐํ–ˆ์„ ๋•Œ ๋ง์„ค์˜€์œผ๋ฏ€๋กœ ๋น„๋ง๋ก.

ํ™˜๊ฒฝ์€ ๋ชจ๋‘ ๋„์ปค ๋กœ ์ž‘์„ฑํ•ฉ๋‹ˆ๋‹ค.

docker๋กœ ํ™˜๊ฒฝ ์ •๋ˆํ•˜๊ธฐ



PlantUML Server ๊ตฌ์ถ•



์ด๋ฒˆ ๋ณธ์„ ์€ ์•„๋‹ˆ์ง€๋งŒ, ๋งŒ์•ฝ์˜ ์œ„๋ฆฝ ๋ฐฉ๋ฒ•์„ ์จ ๋‘ก๋‹ˆ๋‹ค.
๋‹ค์Œ์„ yaml ํŒŒ์ผ์„ ์ค€๋น„ํ•˜๊ณ  docker-compose up -d๋กœ PlantUML Server๋ฅผ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.

docker-compose.yaml
version: "3.7"

services:
  plantuml:
    image: plantuml/plantuml-server
    ports:
      - 18080:8080

์„œ๋ฒ„๊ฐ€ ๊ธฐ๋™ํ•ด ๋ธŒ๋ผ์šฐ์ €๋กœ ์•ก์„ธ์Šค ํ•ด, ์ดํ•˜์™€ ๊ฐ™์€ ํŽ˜์ด์ง€๊ฐ€ ํ‘œ์‹œ๋˜๋ฉด OK์ž…๋‹ˆ๋‹ค.
์—ฌ๊ธฐ์„œ, ์„œ๋ฒ„์˜ IP ์ฃผ์†Œ๋Š” 192.168.1.100 ์œผ๋กœ ํ•˜๊ณ , ํŽ˜์ด์ง€๋Š” http://192.168.1.100:18080 ๋กœ ์•ก์„ธ์Šค ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์œผ๋กœ ํ•ด ์„ค๋ช…์„ ๊ณ„์†ํ•ฉ๋‹ˆ๋‹ค.


MkDocs ์ปจํ…Œ์ด๋„ˆ ํ™˜๊ฒฝ ๋งŒ๋“ค๊ธฐ



MkDocs ์šฉ ์ปจํ…Œ์ด๋„ˆ์˜ Dockerfile์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
๊ณต์‹ ํŒŒ์ด์ฌ docker ์ด๋ฏธ์ง€๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ํŒจํ‚ค์ง€๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
์ด๋ฒˆ์—๋Š” MkDocs๋ฅผ ๋จธํ‹ฐ๋ฆฌ์–ผ ๋””์ž์ธ ํ…Œ๋งˆ์™€ PlantUML์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ๊ฒƒ์— ๋จธ๋ฌผ๋Ÿฌ ์žˆ์Šต๋‹ˆ๋‹ค.

Dockerfile
FROM python:3-buster

WORKDIR /

RUN pip install -U \
        pip \
        mkdocs \
        mkdocs-material \
        plantuml-markdown \
    && mkdocs new docroot

WORKDIR /docroot

๊ทธ๋Ÿฐ ๋‹ค์Œ docker-compose.yaml์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
docroot ์˜ ๋””๋ ‰ํ† ๋ฆฌ๋Š” mkdocs new ๋กœ ์ž‘์„ฑํ•œ MkDocs ์˜ ํ”„๋กœ์ ํŠธ์˜ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋กœ์ปฌ์— ๋ณด๊ด€ ์œ ์ง€ํ•ด ๋งˆ์šดํŠธ ํ•˜๋„๋ก ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
์ปจํ…Œ์ด๋„ˆ๋ฅผ ๊ธฐ๋™ํ•˜๋ฉด mkdocs serve ๋กœ ์„œ๋ฒ„๊ฐ€ ๊ธฐ๋™ํ•˜๋„๋ก ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
http://192.168.1.100:18000 ๋กœ ์ด๋™ํ•˜๋ฉด ํŽ˜์ด์ง€๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
๋‹จ์ˆœํžˆ mkdocs serve ๋ฟ์ด๋ผ๋ฉด localhost:8000 ์—์„œ listen ํ•˜๋ฏ€๋กœ ์ปจํ…Œ์ด๋„ˆ ๋ฐ–์—์„œ ์•ก์„ธ์Šค ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.
๋”ฐ๋ผ์„œ ์ปจํ…Œ์ด๋„ˆ ์™ธ๋ถ€์—์„œ ์•ก์„ธ์Šค ํ•  ์ˆ˜ ์žˆ๋„๋ก -a ์˜ต์…˜์„ ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค.

docker-compose.yaml
version: "3.7"

services:
  mkdocs:
    build:
      context: ./
      dockerfile: ./Dockerfile
    volumes:
      - ./docroot:/docroot
    ports:
      - 18000:8000
    tty: true
    command: bash -c "mkdocs serve -a 0.0.0.0:8000"

PlantUML๊ณผ ํ˜‘๋ ฅ



PlantUML๊ณผ ํ•จ๊ป˜ ์ž‘๋™ํ•˜๋ ค๋ฉด ๋‹ค์Œ ์ค€๋น„๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
  • plantuml-markdown ์„ค์น˜
  • mkdocs.yml์— plantuml_markdown extension ์ถ”๊ฐ€

  • plantuml-markdown์˜ ์„ค์น˜๋Š” Dockerfile์—์„œ ์ด๋ฏธ ์™„๋ฃŒ๋˜์—ˆ์œผ๋ฏ€๋กœ ์ƒ๋žตํ•ฉ๋‹ˆ๋‹ค.

    plantuml_markdown์˜ ํ™•์žฅ ์ถ”๊ฐ€



    mkdocs.yml์— ๋‹ค์Œ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
    ์ด์ „์ด๋ผ๋ฉด, server๋กœ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์ด htp // 192.168.1.100:18080 ์™€ ๊ฐ™์ด ๋งˆ์ง€๋ง‰์— ใ€Œplantumlใ€์ด ๋ถ™์–ด ์žˆ์„ ํ•„์š”๊ฐ€ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
    PlantUML Server์˜ ์‚ฌ์–‘์ด ๋ฐ”๋€Œ์—ˆ๋Š”์ง€ ์ด๋Œ€๋กœ ์›€์ง์ด์ง€ ์•Š๊ณ  ์ž์‹ ์€ ๋ง์„ค์ด๊ณ  ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
    ๊ทธ๋ฆฌ๊ณ , ๊ฐœ์ธ์ ์œผ๋กœ ๋‹ค์ด์–ด๊ทธ๋žจ์€ svg ๋กœ ํ‘œ์‹œํ•˜๊ณ  ์‹ถ๊ธฐ ๋•Œ๋ฌธ์—, ์ด์ „์—๋Š” htp // 192.168.1.100:18080 ์™€ ๊ฐ™์ด URL์— svg ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  ์žˆ๋˜ ์ƒ๊ฐ์ด์—ˆ๋Š”๋ฐ exception ํˆฌ์„ฑ์ด๋กœ ํ‘œ์‹œ๋˜์ง€ ์•Š๊ณ , ํ ์ด ๋˜์–ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

    ์ด ๋ณ€๋„ ์‚ฌ์–‘์ด ๋ฐ”๋€Œ์—ˆ๋Š”์ง€ ํŠนํžˆ ์•„๋ฌด๊ฒƒ๋„ ์ถ”๊ธฐํ•  ํ•„์š”๋Š” ์—†๊ณ , http://192.168.1.100:18080 ๋งŒ์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
    ์ฃผ์˜์ ์œผ๋กœ์„œ๋Š”, ๋งˆ์ง€๋ง‰ ์Šฌ๋ž˜์‹œ๋„ ๋ถˆํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
    site_name: My Docs
    theme:
      name: material
    
    + markdown_extensions:
    +  - plantuml_markdown:
    +      server: http://192.168.1.100:18080
    

    ํ˜•์‹ ์ง€์ •์ด ์—†์œผ๋ฉด ๊ธฐ๋ณธ png์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.
    ์ž์‹ ์ฒ˜๋Ÿผ ๊ธฐ๋ณธ๊ฐ’์„ svg๋กœ ๋งŒ๋“ค๋ ค๋ฉด ๋‘ ๊ฐ€์ง€ ๋ฐฉ๋ฒ•์ด์žˆ๋Š” ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
  • ํฌ๋งท์„ ๋งคํšŒ ์ง€์ •
  • ๋””ํดํŠธ์˜ ํฌ๋งท์„ ์ง€์ •ํ•œ๋‹ค

  • ํ˜•์‹์„ ๋งค๋ฒˆ ์ง€์ •ํ•˜๋ ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด "format"๋กœ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
    
        ```plantuml format="svg"
        @startuml
        Bob -> Alice : hello
        @enduml
        ```
    

    ๊ธฐ๋ณธ์ ์œผ๋กœ ์ง€์ •ํ•˜๋ ค๋ฉด mkdocs.yml์—์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
    site_name: My Docs
    theme:
      name: material
    
    markdown_extensions:
     - plantuml_markdown:
         server: http://192.168.1.100:18080
    +    format: svg
    

    ์ด์ƒ์œผ๋กœ, ์•„๋งˆ ํ˜„์‹œ์ ์—์„œ์˜ ์ตœ์‹ ์˜ MkDocs ์™€ PlantUML ๋ฅผ ์‚ฌ์šฉํ•œ ํ™˜๊ฒฝ์—์„œ ๋ฌธ์„œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์„๊นŒ ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.
    ๊ธธ์–ด์กŒ์ง€๋งŒ ์—ฌ๊ธฐ๊นŒ์ง€ ์‚ฌ๊ท€์–ด ์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

    ์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ