| Crates.io | snips |
| lib.rs | snips |
| version | 0.0.6 |
| created_at | 2025-07-25 04:32:53.423915+00 |
| updated_at | 2025-11-30 01:33:54.095332+00 |
| description | Keep code snippets in markdown files in sync |
| homepage | |
| repository | https://github.com/cortesi/snips |
| max_upload_size | |
| id | 1767185 |
| size | 122,556 |
snips keeps code snippets in Mardown documentation in sync with source files.
snips is a command-line tool that prevents your documentation from becoming
stale. It works by creating a direct link between your source code and your
Markdown files, ensuring your code examples are always up-to-date.
snips uses two simple markers to work its magic:
In your source code, you define a snippet with snips-start and
snips-end comments:
// In examples/example.rs
pub fn example() {
// snips-start: main_feature
println!("This is the code I want in my docs!");
// snips-end: main_feature
}
In your Markdown file, reference snippets using an HTML comment:
<!-- snips: examples/example.rs#main_feature -->
```rust
println!("This is the code I want in my docs!");
```
HTML comments are used to avoid interfering with Markdown rendering - they are hidden from view in the final output.
Run snips to process all Markdown files in the current directory and update
all contained snippets.
<!-- snips: path/to/file.rs -->).--check flag exits with non-zero status if docs
are out of sync, making it perfect for CI pipelines.Want to contribute? Have ideas or feature requests? Come tell us about it on Discord.
cargo install snips
snips [OPTIONS] [FILES]...
Processes Markdown files, updating embedded snippets from their source files.
When no files are provided, snips processes every .md and .markdown file
in the current directory.
--check - Don't write changes, exit with non-zero status if files are out
of sync. Useful for CI pipelines.
--diff - Show a colored diff of pending changes without modifying files.
--quiet - Suppress output.
snips uses the languages library for
programming language detection. This library provides access to GitHub's
Linguist language specification, ensuring accurate language identification and
CodeMirror mode selection for syntax highlighting in your documentation.