summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA Farzat <a@farzat.xyz>2026-06-19 08:19:24 +0300
committerA Farzat <a@farzat.xyz>2026-06-19 08:19:24 +0300
commit82b2555d858cc94c4c9b5655ee820d80540ea509 (patch)
tree94b97675b005e54ce446516e7ecd84ec8159758d
parent18a33193000e996e08e9a5547afe62c0346c0e21 (diff)
downloadrepo2markdown-82b2555d858cc94c4c9b5655ee820d80540ea509.tar.gz
repo2markdown-82b2555d858cc94c4c9b5655ee820d80540ea509.zip
Add some docs to r2md-fence and fence_wrapper
-rw-r--r--src/bin/r2md-fence.rs1
-rw-r--r--src/fence_wrapper.rs11
2 files changed, 12 insertions, 0 deletions
diff --git a/src/bin/r2md-fence.rs b/src/bin/r2md-fence.rs
index bfaf8d5..cced391 100644
--- a/src/bin/r2md-fence.rs
+++ b/src/bin/r2md-fence.rs
@@ -3,6 +3,7 @@ use std::io;
use clap::Parser;
use repo2markdown::fence_wrapper::wrap_in_fence;
+/// Wrap stdin in a Markdown fenced code block.
#[derive(Debug, Parser)]
#[command(version, about, long_about = None)]
struct Cli {
diff --git a/src/fence_wrapper.rs b/src/fence_wrapper.rs
index fc8f1c2..565f848 100644
--- a/src/fence_wrapper.rs
+++ b/src/fence_wrapper.rs
@@ -1,7 +1,18 @@
+//! Utilities for wrapping arbitrary input in a Markdown fenced code block.
+
use std::io::{Read, Write};
use crate::util::fence::generate_outer_backticks;
+/// Reads all input, wraps it in a Markdown fenced code block, and writes it to output.
+///
+/// The opening fence includes the supplied language tag. If `lang` is empty, the fence is emitted
+/// without a language identifier.
+///
+/// The fence length is chosen so that any backtick runs inside the input do not accidentally close
+/// the outer fence.
+///
+/// This function intentionally writes a blank line before the closing fence.
pub fn wrap_in_fence<R: Read, W: Write>(
mut input: R,
mut output: W,