Expand description
§src2md Library
This crate can be used to:
- Collect all source/text files from a project and compile them into a Markdown file
- Extract original source files back from a generated Markdown file
§Usage
§To generate a Markdown file:
use src2md::{Config, run_src2md};
use std::collections::HashSet;
use std::path::PathBuf;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let config = Config {
output_path: PathBuf::from("output.md"),
ignore_file: None,
specific_paths: HashSet::new(),
project_root: std::env::current_dir()?,
extract_input: None,
extract_path: None,
};
run_src2md(config).await
}
§To extract files from a Markdown file:
use src2md::extract_from_markdown;
use std::path::PathBuf;
use std::fs;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create a dummy markdown file for testing
extract_from_markdown(&PathBuf::from("output.md"), Some(&PathBuf::from("restored/"))).await
}
Re-exports§
pub use cli::Config;
pub use extractor::extract_from_markdown;
pub use filewalker::collect_files;
pub use writer::MarkdownWriter;
Modules§
Functions§
- run_
src2md - Generate a Markdown file from source/text files