Współtworzenie¶
- Autor:
Rohit Goswami
Konfiguracja środowiska¶
git clone https://github.com/TurtleTech-ehf/snapper
cd snapper
cargo build
cargo test
Za pomocą pixi:
pixi run -e dev check
Uruchamianie sprawdzeń¶
cargo fmt --check
cargo clippy -- -D warnings
cargo test
Sprawdzenie dogfood (weryfikacja formatowania całej dokumentacji):
pixi run -e dev dogfood
Struktura projektu¶
src/
main.rs -- Entry point, CLI dispatch, subcommand routing
lib.rs -- Public API: format_text(), FormatConfig, build_splitter()
cli.rs -- Clap derive CLI + subcommands (init, sdiff, git-diff, watch, lsp)
config.rs -- .snapperrc.toml serde-based config with per-format sections
format.rs -- Format enum + auto-detection from extension
diff.rs -- Unified diff output for --diff mode
sdiff.rs -- Sentence-level diff (snapper sdiff)
git_diff.rs -- Git-aware sentence diff (snapper git-diff)
init.rs -- Project initialization (snapper init)
lsp.rs -- LSP server (snapper lsp) via tower-lsp
watch.rs -- File watcher (snapper watch) via notify
output.rs -- JSON/SARIF output for --check mode
abbreviations.rs -- Multi-language abbreviation lists (en, de, fr, is, pl)
reflow.rs -- Core reflow engine (regions + splitter -> output)
files.rs -- File-level formatting utilities
sentence/
mod.rs -- SentenceSplitter trait
unicode.rs -- UAX #29 + abbreviation merge + placeholder system
neural.rs -- nnsplit LSTM sentence detection (9 languages)
parser/
mod.rs -- Region enum, FormatParser trait, pragma support
org.rs -- Org-mode parser
latex.rs -- LaTeX parser
markdown.rs -- Markdown parser
rst.rs -- reStructuredText parser
plaintext.rs -- Plaintext parser (everything is prose)
editors/
vscode/ -- VS Code extension (LSP client)
tests/
integration.rs -- Integration tests (format, check, idempotency, stdin)
fixtures/ -- Sample input/expected output pairs per format
vale/
snapper/ -- Vale style rules for editor hints
site/ -- Landing page (static HTML)
docs/
orgmode/ -- Documentation source (org-mode)
source/ -- Sphinx config + templates
export.el -- Batch org -> RST exporter
Konwencje commitów¶
Commity stosują konwencję conventional commits, zarządzaną przez cocogitto (cog):
feat:nowe funkcjonalności
fix:poprawki błędów
doc:zmiany w dokumentacji
chore:utrzymanie, aktualizacje zależności
tst:zmiany w testach
bld:zmiany w systemie budowania
Budowanie dokumentacji¶
pixi run -e docs docbld
Lub ręcznie:
emacs --batch -l docs/export.el
sphinx-build docs/source docs/build -b html
Dodawanie nowego parsera formatu¶
Utwórz
src/parser/yourformat.rsimplementujący cechęFormatParserDodaj wariant do enuma
Formatwsrc/format.rsPodłącz go do
format_text()wsrc/lib.rsDodaj mapowanie rozszerzeń w
Format::from_path()Dodaj parę plików testowych w
tests/fixtures/(sample.fmt+expected.fmt)Dodaj testy integracyjne w
tests/integration.rsUdokumentuj w
docs/orgmode/reference/formats.org