Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
welf committed Jan 16, 2025
1 parent f029913 commit 293ab13
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,19 @@ implementation details while preserving the essential structure and interfaces.
## Features

- **Removes**:
- Function bodies (with specific exceptions)
- Test functions (`#[test]`) and test modules (`#[cfg(test)]`)
- Doc comments and module-level documentation when the `--no-comments` flag is
used
- Function bodies (with specific exceptions and when the
`--no-function-bodies` option is used)
- Doc comments and module-level documentation when the `--no-comments` option
is used
- Implementation details of derived traits
- **Preserves**:
- Module structure and imports
- Type definitions (structs, enums, traits)
- Function signatures and interfaces
- Non-test attributes (e.g., `#[derive]`)
- Doc comments and module-level documentation (unless `--no-comments` is
specified)
- Doc comments and module-level documentation (unless `--no-comments` option
is specified)
- Function bodies for:
- String-like return types (`String`, `&str`, `Cow<str>`)
- `Result<T, E>` where `T` is string-like
Expand Down Expand Up @@ -97,8 +98,9 @@ code-context <input_path> --output-dir <suffix_for_output_dir_name> --no-comment
```
Options:
-o, --output-dir <NAME> Output directory name [default: code-context]
--no-function-bodies Remove function bodies (except for functions with string-like return types)
--no-comments Remove all comments (including doc comments)
--stats Show processing statistics
--no-stats Show processing statistics
--dry-run Run without writing output files
--single-file Output all files into a single combined file
-h, --help Print help
Expand All @@ -113,25 +115,37 @@ Generated output files can be found in the

- The file
[`src-code-context/code_context.rs.txt`](./src-code-context/code_context.rs.txt)
was generated by passing the path to the `src` directory of this repo with the
`--single-file` flag.
was generated by passing the path to the `src` directory of this repo with
`--single-file` and `--no-function-bodies` options.
- Files in the [`src-custom-suffix`](./src-custom-suffix/) directory were
generated by passing the path to the `src` directory with the
`--output-dir custom-suffix` flag.
generated by passing the path to the `src` directory with
`--output-dir custom-suffix` and `--no-function-bodies` options.

In both cases, the size reduction is 92.5% (from 70925 bytes to 5353 bytes).
In both cases, the size reduction is 92.5% (from 76371 bytes to 5744 bytes).

### Before and After Example

**Before:**

```rust
/// Adds two numbers.
fn add(a: i32, b: i32) -> i32 {
a + b
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_add() {
assert_eq!(add(1, 2), 3);
}
}
```

**After:**
**After using the tool with `--no-comments` and `--no-function-bodies`
options:**

```rust
fn add(a: i32, b: i32) -> i32 {}
Expand Down

0 comments on commit 293ab13

Please sign in to comment.