summaryrefslogtreecommitdiff
path: root/src/renderer.rs
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2026-06-05 05:42:16 +0300
committerA Farzat <a@farzat.xyz>2026-06-05 05:42:16 +0300
commit58d6afbd8bb02890106f84621a1cda94c7b5d3bf (patch)
treecce9ec669bfb436a8771806fdfd0fe9cf318d03a /src/renderer.rs
parent469e303febc61ebca3b5a977cf675b9f57111767 (diff)
downloadrepo2markdown-58d6afbd8bb02890106f84621a1cda94c7b5d3bf.tar.gz
repo2markdown-58d6afbd8bb02890106f84621a1cda94c7b5d3bf.zip
Make headers more descriptive for LLMs
Diffstat (limited to 'src/renderer.rs')
-rw-r--r--src/renderer.rs19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/renderer.rs b/src/renderer.rs
index 6aa5ac7..6407b04 100644
--- a/src/renderer.rs
+++ b/src/renderer.rs
@@ -22,15 +22,12 @@ impl std::error::Error for RenderError {}
pub fn render(project_name: &str, files: &[(&Path, &[u8])]) -> Result<String, RenderError> {
let mut output = format!("# {}\n", project_name);
- if !files.is_empty() {
- output.push_str("\n## Files\n");
- }
for (filename, bytes) in files {
let content = std::str::from_utf8(bytes)
.map_err(|_| RenderError::BinaryFile(filename.to_path_buf()))?;
let outer_backticks = outer_backticks(content);
output.push_str(&format!(
- "\n### {:?}\n{}\n{}\n{}\n",
+ "\n## File: {:?}\n{}\n{}\n{}\n",
filename, outer_backticks, content, outer_backticks
));
}
@@ -75,8 +72,7 @@ mod tests {
assert_eq!(
output.unwrap(),
"# Project name\n\n\
- ## Files\n\n\
- ### \"main.rs\"\n\
+ ## File: \"main.rs\"\n\
```\n\
fn main() {}\n\
```\n"
@@ -95,12 +91,11 @@ mod tests {
assert_eq!(
output.unwrap(),
"# Project name\n\n\
- ## Files\n\n\
- ### \"main.rs\"\n\
+ ## File: \"main.rs\"\n\
```\n\
fn main() {}\n\
```\n\n\
- ### \"lib.rs\"\n\
+ ## File: \"lib.rs\"\n\
```\n\
pub fn hello() {}\n\
```\n"
@@ -119,8 +114,7 @@ mod tests {
assert_eq!(
output.unwrap(),
"# Project name\n\n\
- ## Files\n\n\
- ### \"example.rs\"\n\
+ ## File: \"example.rs\"\n\
````\n\
fn main() { println!(\"``` inside\"); }\n\
````\n"
@@ -150,8 +144,7 @@ mod tests {
assert_eq!(
output.unwrap(),
"# Project name\n\n\
- ## Files\n\n\
- ### \"some\\nma\\xC3in.rs\"\n\
+ ## File: \"some\\nma\\xC3in.rs\"\n\
```\n\
fn main() {}\n\
```\n"