docs: add developer-workflow.org and language examples
Complete workflow guide for Perl, Python, Go, Ansible, Terraform, Podman. Includes working example files in examples/ directory.
This commit is contained in:
343
notes/developer-workflow.org
Normal file
343
notes/developer-workflow.org
Normal file
@@ -0,0 +1,343 @@
|
||||
#+TITLE: Developer Workflow v Doom Emacs
|
||||
#+AUTHOR: Martin Sukaný
|
||||
#+DATE: [2026-02-24 Tue]
|
||||
#+OPTIONS: toc:3 num:t
|
||||
#+STARTUP: overview
|
||||
|
||||
* Úvod
|
||||
|
||||
Tento dokument popisuje kompletní vývojářský workflow v Doom Emacs pro jazyky a nástroje, které Martin používá: Perl, Python, Go, Ansible, Terraform a Podman/Dockerfile. Ke každému jazyku najdeš: co nainstalovat, klávesové zkratky, příklad workflow a odkaz na ukázkový soubor v =examples/=.
|
||||
|
||||
* Instalace nástrojů
|
||||
|
||||
Všechny nástroje se instalují přes Homebrew (macOS). Na Linuxu použij příslušný package manager.
|
||||
|
||||
** Perl
|
||||
|
||||
#+begin_src bash
|
||||
brew install perl
|
||||
cpanm Perl::Tidy Perl::Critic Perl::LanguageServer
|
||||
#+end_src
|
||||
|
||||
- =perltidy= — formatter (SPC m f)
|
||||
- =perlcritic= — linter
|
||||
- =Perl::LanguageServer= — LSP backend (volitelné)
|
||||
|
||||
** Python
|
||||
|
||||
#+begin_src bash
|
||||
brew install python ruff pyright
|
||||
#+end_src
|
||||
|
||||
- =ruff= — ultra-rychlý linter + formatter
|
||||
- =pyright= — type-checking LSP server
|
||||
|
||||
** Go
|
||||
|
||||
#+begin_src bash
|
||||
brew install go gopls
|
||||
go install golang.org/x/tools/cmd/goimports@latest
|
||||
#+end_src
|
||||
|
||||
- =gopls= — oficiální Go LSP
|
||||
- =goimports= — formatter (gofmt + auto imports)
|
||||
|
||||
** Ansible
|
||||
|
||||
#+begin_src bash
|
||||
brew install ansible ansible-lint
|
||||
#+end_src
|
||||
|
||||
- =ansible-lint= — linter pro playbooky (flycheck integrace)
|
||||
|
||||
** Terraform
|
||||
|
||||
#+begin_src bash
|
||||
brew install terraform terraform-ls
|
||||
#+end_src
|
||||
|
||||
- =terraform-ls= — HashiCorp oficiální LSP server
|
||||
|
||||
** Podman / Dockerfile
|
||||
|
||||
#+begin_src bash
|
||||
brew install podman hadolint
|
||||
#+end_src
|
||||
|
||||
- =hadolint= — Dockerfile linter (flycheck integrace)
|
||||
- =podman= — Docker-kompatibilní container runtime (daemonless)
|
||||
|
||||
* Keybindings přehled
|
||||
|
||||
Všechny keybindings jsou pod =SPC m= (localleader) — aktivní pouze v příslušném major mode.
|
||||
|
||||
| Jazyk | SPC m f | SPC m r | SPC m t / b | SPC m d | SPC m i / p |
|
||||
|------------+-----------------+------------------+------------------+-----------+------------------|
|
||||
| Perl | perltidy format | perl run | — | perldb | — |
|
||||
| Python | ruff format | python3 run | — | M-x pdb | — |
|
||||
| Go | goimports | go run | go test / build | M-x dlv | — |
|
||||
| Ansible | — | ansible-playbook | — | — | — |
|
||||
| Terraform | terraform fmt | — | — | — | init / plan |
|
||||
| Dockerfile | — | podman run | podman build | — | — |
|
||||
|
||||
Obecné navigační zkratky (všechny jazyky):
|
||||
|
||||
| Zkratka | Akce |
|
||||
|-------------+-----------------------------------|
|
||||
| =C-M-a= | Začátek funkce/subroutine |
|
||||
| =C-M-e= | Konec funkce/subroutine |
|
||||
| =SPC s i= | Imenu — seznam funkcí v souboru |
|
||||
| =gd= | Go to definition (LSP/tags) |
|
||||
| =] e= / =[ e= | Další/předchozí flycheck error |
|
||||
| =SPC s p= | Grep v projektu (ripgrep) |
|
||||
| =SPC p f= | Najít soubor v projektu |
|
||||
|
||||
* Perl — workflow
|
||||
|
||||
** Co nainstalovat
|
||||
|
||||
#+begin_src bash
|
||||
brew install perl
|
||||
cpanm Perl::Tidy Perl::Critic Perl::LanguageServer
|
||||
#+end_src
|
||||
|
||||
** Keybindings
|
||||
|
||||
| Zkratka | Akce |
|
||||
|-----------+-----------------------------|
|
||||
| =SPC m f= | Formátování přes perltidy |
|
||||
| =SPC m r= | Spustit aktuální soubor |
|
||||
| =SPC m d= | Spustit Perl debugger |
|
||||
| =C-M-a= | Skok na začátek subroutine |
|
||||
| =C-M-e= | Skok na konec subroutine |
|
||||
| =SPC s i= | Imenu — seznam subs |
|
||||
|
||||
** Příklad workflow
|
||||
|
||||
1. Otevři soubor: =SPC p f= → vyber =example.pl=
|
||||
2. Navigace po subs: =SPC s i= → vyber subroutine ze seznamu
|
||||
3. Pohyb mezi subs: =C-M-a= (začátek), =C-M-e= (konec)
|
||||
4. Formátování: =SPC m f= (perltidy celý buffer)
|
||||
5. Spuštění: =SPC m r= — otevře compile buffer s výstupem
|
||||
6. Debug: =SPC m d= → zadej soubor → v kódu přidej =$DB::single = 1;= pro breakpoint
|
||||
7. Chyby: =] e= / =[ e= pro navigaci flycheck errors
|
||||
|
||||
** Ukázkový soubor
|
||||
|
||||
Viz =[[file:../examples/perl/example.pl][examples/perl/example.pl]]= — demonstruje strict/warnings, subroutines, hashe, regex, file I/O a error handling.
|
||||
|
||||
* Python — workflow
|
||||
|
||||
** Co nainstalovat
|
||||
|
||||
#+begin_src bash
|
||||
brew install python ruff pyright
|
||||
pip install pyvenv # volitelné, pro virtualenv management
|
||||
#+end_src
|
||||
|
||||
** Keybindings
|
||||
|
||||
| Zkratka | Akce |
|
||||
|-----------+-----------------------------|
|
||||
| =SPC m f= | Formátování přes ruff |
|
||||
| =SPC m r= | Spustit aktuální soubor |
|
||||
| =gd= | Go to definition (pyright) |
|
||||
| =K= | Hover docs (LSP) |
|
||||
| =SPC s i= | Imenu — seznam tříd/funkcí |
|
||||
|
||||
** Příklad workflow
|
||||
|
||||
1. Otevři projekt: =SPC p p= → vyber Python projekt
|
||||
2. Virtual env: =M-x pyvenv-activate= → vyber venv adresář
|
||||
3. Navigace: =SPC s i= pro přehled tříd a funkcí
|
||||
4. LSP: =gd= (definice), =K= (docs), =gr= (references)
|
||||
5. Format: =SPC m f= — ruff format na celý soubor
|
||||
6. Run: =SPC m r= — spustí =python3 buffer.py= v compile bufferu
|
||||
7. Debug: =M-x pdb= → zadej =python3 -m pdb soubor.py=
|
||||
8. Chyby: =] e= / =[ e= pro flycheck (ruff lint)
|
||||
|
||||
** Ukázkový soubor
|
||||
|
||||
Viz =[[file:../examples/python/example.py][examples/python/example.py]]= — demonstruje type hints, dataclass, list comprehension, argparse a exception handling.
|
||||
|
||||
* Go — workflow
|
||||
|
||||
** Co nainstalovat
|
||||
|
||||
#+begin_src bash
|
||||
brew install go gopls
|
||||
go install golang.org/x/tools/cmd/goimports@latest
|
||||
#+end_src
|
||||
|
||||
** Keybindings
|
||||
|
||||
| Zkratka | Akce |
|
||||
|-----------+------------------------------|
|
||||
| =SPC m f= | Formátování (goimports) |
|
||||
| =SPC m r= | go run aktuální soubor |
|
||||
| =SPC m t= | go test ./... |
|
||||
| =SPC m b= | go build ./... |
|
||||
| =gd= | Go to definition (gopls) |
|
||||
| =K= | Hover docs (gopls) |
|
||||
|
||||
** Příklad workflow
|
||||
|
||||
1. Nový projekt: =go mod init myproject= v terminálu
|
||||
2. Otevři: =SPC p f= → =main.go=
|
||||
3. LSP automaticky: gopls se spustí, poskytuje completion, diagnostiku, navigaci
|
||||
4. Píšeš kód: goimports automaticky doplní importy při uložení
|
||||
5. Run: =SPC m r= → =go run main.go=
|
||||
6. Test: =SPC m t= → =go test ./...=
|
||||
7. Build: =SPC m b= → =go build ./...=
|
||||
|
||||
** Ukázkový soubor
|
||||
|
||||
Viz =[[file:../examples/go/main.go][examples/go/main.go]]= — demonstruje struct, methods, error handling, goroutine a channel.
|
||||
|
||||
* Ansible — workflow
|
||||
|
||||
** Co nainstalovat
|
||||
|
||||
#+begin_src bash
|
||||
brew install ansible ansible-lint
|
||||
#+end_src
|
||||
|
||||
** Keybindings
|
||||
|
||||
| Zkratka | Akce |
|
||||
|-----------+-------------------------------|
|
||||
| =SPC m r= | Spustit ansible-playbook |
|
||||
| =] e= | Další ansible-lint chyba |
|
||||
| =SPC s p= | Grep v projektu (role, vars) |
|
||||
|
||||
** Příklad workflow
|
||||
|
||||
1. Otevři playbook: =SPC p f= → =playbook.yml=
|
||||
2. Yaml-mode se aktivuje automaticky, ansible-lint přes flycheck
|
||||
3. Navigace: =SPC s i= pro imenu (task names)
|
||||
4. Spuštění: =SPC m r= — spustí =ansible-playbook playbook.yml=
|
||||
5. Lint chyby: =] e= / =[ e= pro navigaci
|
||||
|
||||
** Ukázkový soubor
|
||||
|
||||
Viz =[[file:../examples/ansible/playbook.yml][examples/ansible/playbook.yml]]= — demonstruje apt install, user create, template copy, handlers a vars.
|
||||
|
||||
* Terraform — workflow
|
||||
|
||||
** Co nainstalovat
|
||||
|
||||
#+begin_src bash
|
||||
brew install terraform terraform-ls
|
||||
#+end_src
|
||||
|
||||
** Keybindings
|
||||
|
||||
| Zkratka | Akce |
|
||||
|-----------+-------------------------|
|
||||
| =SPC m f= | terraform fmt |
|
||||
| =SPC m i= | terraform init |
|
||||
| =SPC m p= | terraform plan |
|
||||
| =gd= | Go to definition (LSP) |
|
||||
|
||||
** Příklad workflow
|
||||
|
||||
1. Nový projekt: vytvoř adresář, =main.tf= + =variables.tf=
|
||||
2. Init: =SPC m i= — stáhne providery
|
||||
3. LSP (terraform-ls): autocompletion pro resource typy, atributy, variables
|
||||
4. Format: =SPC m f= — terraform fmt (kanonický styl)
|
||||
5. Plan: =SPC m p= — ukáže co se změní
|
||||
6. Apply: v terminálu =terraform apply=
|
||||
|
||||
** Ukázkové soubory
|
||||
|
||||
Viz =[[file:../examples/terraform/main.tf][examples/terraform/main.tf]]= a =[[file:../examples/terraform/variables.tf][examples/terraform/variables.tf]]= — demonstrují null provider, resource, variable, output a validation.
|
||||
|
||||
* Podman / Dockerfile — workflow
|
||||
|
||||
** Co nainstalovat
|
||||
|
||||
#+begin_src bash
|
||||
brew install podman hadolint
|
||||
podman machine init # jednorázově
|
||||
podman machine start
|
||||
#+end_src
|
||||
|
||||
** Keybindings
|
||||
|
||||
| Zkratka | Akce |
|
||||
|-----------+-----------------------------------|
|
||||
| =SPC m b= | podman build (zeptá se na tag) |
|
||||
| =SPC m r= | podman run (zeptá se na image) |
|
||||
| =] e= | Další hadolint chyba |
|
||||
|
||||
** Příklad workflow
|
||||
|
||||
1. Otevři =Dockerfile=: dockerfile-mode se aktivuje automaticky
|
||||
2. Hadolint: flycheck ukazuje best practices (DL3008, DL3059 atd.)
|
||||
3. Build: =SPC m b= → zadej tag (např. =myapp:latest=) → compile buffer
|
||||
4. Run: =SPC m r= → zadej image name → spustí container
|
||||
|
||||
** Ukázkový soubor
|
||||
|
||||
Viz =[[file:../examples/docker/Dockerfile][examples/docker/Dockerfile]]= — demonstruje multi-stage build, non-root user, HEALTHCHECK a layer caching.
|
||||
|
||||
* Go — učení (začátečník)
|
||||
|
||||
** Základní kroky
|
||||
|
||||
1. Vytvoř projekt:
|
||||
#+begin_src bash
|
||||
mkdir myproject && cd myproject
|
||||
go mod init myproject
|
||||
#+end_src
|
||||
|
||||
2. Struktura:
|
||||
#+begin_example
|
||||
myproject/
|
||||
├── go.mod
|
||||
├── main.go # vstupní bod
|
||||
├── internal/ # interní balíčky
|
||||
│ └── handler.go
|
||||
└── pkg/ # veřejné balíčky
|
||||
└── utils.go
|
||||
#+end_example
|
||||
|
||||
3. Spusť: =go run main.go= (nebo =SPC m r= v Emacsu)
|
||||
4. Test: =go test ./...= (nebo =SPC m t=)
|
||||
5. Build: =go build -o myapp= (nebo =SPC m b=)
|
||||
|
||||
** Klíčové koncepty
|
||||
|
||||
- =package main= + =func main()= = vstupní bod
|
||||
- Error handling: =if err != nil { return err }= (žádné exceptions)
|
||||
- Goroutines: =go func()= pro souběžnost
|
||||
- Channels: =ch := make(chan int)= pro komunikaci mezi goroutines
|
||||
- Interfaces: implicitní implementace (duck typing)
|
||||
|
||||
** Příklad
|
||||
|
||||
Viz =[[file:../examples/go/main.go][examples/go/main.go]]= pro funkční ukázku všech konceptů.
|
||||
|
||||
* Obecné tipy
|
||||
|
||||
| Zkratka | Akce |
|
||||
|---------------+-----------------------------------------|
|
||||
| =SPC s p= | Grep v projektu (ripgrep) |
|
||||
| =SPC p f= | Najít soubor v projektu |
|
||||
| =SPC p p= | Přepnout projekt |
|
||||
| =SPC g g= | Magit — git status |
|
||||
| =SPC g B= | Git blame |
|
||||
| =C-M-a= / =C-M-e= | Pohyb po funkcích (všechny jazyky) |
|
||||
| =] e= / =[ e= | Flycheck: další/předchozí error |
|
||||
| =SPC c x= | Flycheck: seznam všech errors |
|
||||
| =SPC b b= | Přepnout buffer |
|
||||
| =SPC w v= | Vertikální split |
|
||||
| =SPC o t= | Otevřít terminál (vterm) |
|
||||
|
||||
** Compile buffer
|
||||
|
||||
Všechny =SPC m r/t/b= příkazy používají Emacs =compile= — výstup se zobrazí v compile bufferu. Klávesy v compile bufferu:
|
||||
|
||||
- =g= — znovu spustit
|
||||
- =q= — zavřít
|
||||
- =RET= na error řádku — skok na zdrojový kód
|
||||
Reference in New Issue
Block a user