Skip to content

Commit 304ff1d

Browse files
--tldr checkpoint 2
1 parent faa44e7 commit 304ff1d

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ cargo run --bin cratedocs test --tool lookup_crate --crate-name tokio --format t
6464

6565
# Save output to a file
6666
cargo run --bin cratedocs test --tool lookup_crate --crate-name tokio --output tokio-docs.md
67+
# Summarize output by stripping LICENSE and VERSION sections
68+
cargo run --bin cratedocs test --tool lookup_crate --crate-name tokio --tldr
6769
```
6870

6971
By default, the HTTP server will listen on `http://127.0.0.1:8080/sse`.

src/bin/cratedocs.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,4 +476,56 @@ Some real documentation here.
476476
let output = apply_tldr(input);
477477
assert_eq!(output.trim(), input.trim());
478478
}
479+
#[test]
480+
fn test_apply_tldr_no_headings() {
481+
let input = r#"
482+
This is plain text without any headings.
483+
It should remain unchanged after processing.
484+
"#;
485+
let output = apply_tldr(input);
486+
assert_eq!(output.trim(), input.trim());
487+
}
488+
489+
#[test]
490+
fn test_apply_tldr_malformed_markdown() {
491+
let input = r#"
492+
#LICENSE
493+
This is a malformed license heading.
494+
#VERSION
495+
This is a malformed version heading.
496+
"#;
497+
let output = apply_tldr(input);
498+
assert!(!output.to_lowercase().contains("license"));
499+
assert!(!output.to_lowercase().contains("version"));
500+
}
501+
502+
#[test]
503+
fn test_apply_tldr_large_input() {
504+
let input = r#"
505+
# Versions
506+
Version 1.0.0
507+
Version 2.0.0
508+
509+
# LICENSE
510+
MIT License text.
511+
512+
# Usage
513+
Some real documentation here.
514+
515+
# Another Section
516+
More docs.
517+
518+
# LICENSE
519+
Another license section.
520+
521+
# Versions
522+
Another version section.
523+
"#;
524+
let output = apply_tldr(input);
525+
assert!(!output.to_lowercase().contains("license"));
526+
assert!(!output.to_lowercase().contains("version"));
527+
assert!(output.contains("Usage"));
528+
assert!(output.contains("Another Section"));
529+
assert!(output.contains("Some real documentation here."));
530+
}
479531
}

0 commit comments

Comments
 (0)