Skip to content

Commit 8572a4b

Browse files
committed
feat: add option to remove #[cfg(test)] unit test modules from rust code
1 parent 6b6acc4 commit 8572a4b

18 files changed

+467
-36
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "stitch"
3-
version = "0.1.21"
3+
version = "0.1.22"
44
edition = "2024"
55
authors = ["Giovanni Ramistella <crimps-78-pax@icloud.com>"]
66
license = "MIT"

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Stitch is a lightweight desktop utility that lets you **select a precise slice o
1010
1111
---
1212

13-
## What it does
13+
## What it does
1414

1515
- **Fast native UI (Slint)** with a responsive tree even on large projects.
1616
- **Deterministic context packing**: you decide exactly which files/dirs are included and how they’re scrubbed.
@@ -20,7 +20,7 @@ Stitch is a lightweight desktop utility that lets you **select a precise slice o
2020
- Include takes precedence over exclude when both are present.
2121
- Dotfiles are visible by default.
2222
- **Language-specific filters** (appear dynamically when relevant files are detected)
23-
- **Rust**: Remove inline comments (`//`, `/* */`), doc comments (`///`, `//!`, `/** */`), extract function signatures only with wildcard filtering
23+
- **Rust**: Remove inline comments (`//`, `/* */`), doc comments (`///`, `//!`, `/** */`), extract function signatures only with wildcard filtering, remove `#[cfg(test)]` unit test modules
2424
- **Slint**: Remove line comments (`//`), block comments (`/* */`)
2525
- **Two “only” modes**
2626
- **Hierarchy Only** – just the tree
@@ -37,15 +37,15 @@ Stitch is a lightweight desktop utility that lets you **select a precise slice o
3737

3838
---
3939

40-
## 🧭 Philosophy
40+
## Philosophy
4141

4242
- Use the **chat models you already have**—no API keys.
4343
- **Full control & auditability**: you see exactly what the model sees.
4444
- A curated, minimal context often **beats** generic retrieval on long-tail tasks.
4545

4646
---
4747

48-
## 🧰 Install & Run
48+
## Install & Run
4949

5050
### Prerequisites
5151
- **Rust** (stable) + **Cargo**
@@ -101,7 +101,7 @@ Cross-compile by setting `TARGET=<triple>` (e.g. `x86_64-unknown-linux-musl`) be
101101
102102
---
103103
104-
## 🖱️ How to use
104+
## How to use
105105
106106
1. **Select Folder** – choose your project root.
107107
2. **Adjust Filters** (optional):
@@ -126,7 +126,7 @@ Works with CRLF/LF line endings and is tolerant of trailing whitespace/blank lin
126126
127127
---
128128
129-
## 🧠 Profiles & Workspace
129+
## Profiles & Workspace
130130
131131
Stitch keeps per-project state in a `.stitchworkspace` folder (auto-excluded from scans).
132132
@@ -152,7 +152,7 @@ Stitch keeps per-project state in a `.stitchworkspace` folder (auto-excluded fro
152152
153153
---
154154
155-
## 🤝 Team-wide Collaboration
155+
## Team-wide Collaboration
156156
157157
Stitch is great for **team workflows**—you can standardize “what to share” for PRs, issues, and LLM prompts.
158158
@@ -173,7 +173,7 @@ Stitch is great for **team workflows**—you can standardize “what to share”
173173
174174
---
175175
176-
## 🧽 Scrubbing & Cleanup
176+
## Scrubbing & Cleanup
177177
178178
Stitch provides both language-specific filters (for Rust and Slint files) and generic text-based scrubbing tools. Language-specific filters are applied first, followed by generic text processing.
179179
@@ -196,7 +196,7 @@ Stitch provides both language-specific filters (for Rust and Slint files) and ge
196196
197197
---
198198
199-
## 🔧 Language-Specific Filters
199+
## Language-Specific Filters
200200
201201
Stitch includes intelligent language-specific filters that appear dynamically in the UI when relevant file types are detected in your selection. These filters complement the generic scrubbing tools and are applied before text-based processing.
202202
@@ -206,11 +206,11 @@ When Rust files are present, you'll see a **Rust-specific filters** section with
206206
207207
- **Remove inline regular comments**: Strips `//` and `/* */` comments while preserving content inside strings and raw strings
208208
- **Remove doc comments**: Removes documentation comments (`///`, `//!`, `/** */`)
209-
- **Function signatures only**: Extracts only function signatures, replacing function bodies with `{ ... }`
209+
- **Function signatures only**: Extracts only function signatures, replacing function bodies with `;`
210210
- **Signature-only files/folders**: Optional wildcard filter (e.g., `src/*,tests/*,main.rs`) to apply signature-only mode to specific paths
211-
- Uses `syn` parsing for accurate AST-based processing with textual fallback
211+
- **Remove `#[cfg(test)]` modules**: Strips entire `#[cfg(test)] mod tests { ... }` blocks, useful for sharing production code without test boilerplate
212212
213-
The Rust filters use proper parsing to avoid removing comments inside string literals, raw strings (`r#"..."#`), and other protected regions.
213+
The Rust filters use state-machine parsing to correctly handle string literals, raw strings (`r#"..."#`), lifetimes, and nested structures.
214214
215215
### Slint Filters (`.slint` files)
216216
@@ -225,7 +225,7 @@ Slint filters preserve content inside string literals and handle the language's
225225
226226
---
227227
228-
## 🧩 Typical workflows
228+
## Typical workflows
229229
230230
- **LLM context packing**: curate a minimal, auditable set of files.
231231
- **Minimal repros**: share only the relevant sources + a tree.
@@ -234,11 +234,11 @@ Slint filters preserve content inside string literals and handle the language's
234234
235235
---
236236
237-
## 🔬 Implementation notes
237+
## Implementation notes
238238
239-
- **Tech**: Rust 2024 edition, Slint, `rfd`, `notify`, `regex`, `chrono`, `serde`/`serde_json`, `dunce`, `arboard`, `syn`, `quote`.
239+
- **Tech**: Rust 2024 edition, Slint, `rfd`, `notify`, `regex`, `chrono`, `serde`/`serde_json`, `dunce`, `arboard`.
240240
- **Language-specific processing**:
241-
- Rust filters use `syn` for AST-based parsing with textual fallback for malformed code
241+
- Rust filters use state-machine parsing to handle comments, strings, raw strings, lifetimes, and nested braces
242242
- Slint filters use custom state machine parsing to handle comment syntax
243243
- Language filter UI sections appear dynamically based on detected file types in the current selection
244244
- **Auto refresh**:
@@ -253,7 +253,7 @@ Slint filters preserve content inside string literals and handle the language's
253253
254254
---
255255
256-
## 🧪 Testing & Benchmarks
256+
## Testing & Benchmarks
257257
258258
- **Tests (headless)**
259259
```bash
@@ -269,7 +269,7 @@ Slint filters preserve content inside string literals and handle the language's
269269
270270
---
271271
272-
## 🤖 CI & Releases
272+
## CI & Releases
273273
274274
- **CI**: `.github/workflows/ci.yml`
275275
- Lints (fmt + clippy), tests headless, and verifies the UI build path.
@@ -278,7 +278,7 @@ Slint filters preserve content inside string literals and handle the language's
278278
279279
---
280280
281-
## 🔧 Feature flags
281+
## Feature flags
282282
283283
- `ui` (default): build the Slint desktop app.
284284
- `tokens` (default): enable accurate token counting with `tiktoken-rs`.
@@ -293,23 +293,23 @@ cargo test --no-default-features
293293
294294
---
295295
296-
## 🧱 Known limitations / edges
296+
## Known limitations / edges
297297
298-
- **Very large repos**: first scan can be heavylean on filters early.
298+
- **Very large repos**: first scan can be heavy, lean on filters early.
299299
- **Binary/huge files**: not specially parsed; consider excluding them.
300300
- **Multi-dot extensions**: only the **last** segment is considered (e.g., `.tar.gz``.gz`).
301301
- **Scrubbing**: may remove content inside comments/strings in ways that matter to your code—review before sharing.
302302
303303
---
304304
305-
## 🤝 Contributing
305+
## Contributing
306306
307307
Issues and PRs welcome—especially around defaults (exclusions), performance, UI polish, and integrations.
308308
If adding assets, place third-party licenses in `LICENSES/`.
309309
310310
---
311311
312-
## 📄 License
312+
## License
313313
314314
This project is licensed under the **MIT License** — see [LICENSE](./LICENSE) for details.
315315

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ bin-release:
2727
# macOS: build .app and .dmg
2828
dmg:
2929
#!/usr/bin/env bash
30-
VERSION="$(python -c 'import re,pathlib;print(re.search(r"^version\s*=\s*\"([^\"]+)\"", pathlib.Path("Cargo.toml").read_text(), re.M).group(1))')"
30+
VERSION="$(python3 -c 'import re,pathlib;print(re.search(r"^version\s*=\s*\"([^\"]+)\"", pathlib.Path("Cargo.toml").read_text(), re.M).group(1))')"
3131
command -v cargo-bundle >/dev/null 2>&1 || cargo install cargo-bundle
3232
cargo bundle --release --format osx
3333
APP_PATH="$(ls -d target/release/bundle/*/*.app | head -n1)"

0 commit comments

Comments
 (0)