| Crates.io | prk_mdgen |
| lib.rs | prk_mdgen |
| version | 0.1.9 |
| created_at | 2025-04-17 07:49:36.01822+00 |
| updated_at | 2025-04-21 14:18:52.473501+00 |
| description | Generate and execute Rust projects from annotated Markdown files |
| homepage | |
| repository | https://github.com/prk-Jr/prk_mdgen |
| max_upload_size | |
| id | 1637354 |
| size | 65,346 |
This tool parses specially formatted Markdown files to generate fully structured Rust projects โ and even executes them (via cargo run or cargo test depending on the code)!
It can also extract a real Rust project from disk into a Markdown spec file using the extract command!
This CLI tool supports two main workflows:
.md) files in the current directoryCargo.toml, etc.)main.rs projects using cargo runlib.rs projects using cargo testrun_output.log or test_output.log.rs files are converted to annotated code blocks with file paths.gitignore and additional --skip rulesYou can annotate code blocks in your Markdown using several supported patterns:
XML-style tag
<code path="src/main.rs">
fn main() {
println!("Hello!");
}
</code>
Markdown heading
### src/lib.rs
```rust
pub fn add(a: i32, b: i32) -> i32 {
a + b
}
======== src/utils.rs ========
```rust
pub fn double(x: i32) -> i32 {
x * 2
}
// file: src/math.rs
pub fn square(x: i32) -> i32 {
x * x
}
File Fence
### <file> src/main.rs </file>
```rust
use std::sync::Arc;
use std::error::Error;
use std::future::Future;
https://rustup.rs)cargo install prk_mdgen
prk_mdgen
Generate Rust projects from all .md files in the current directory.
prk_mdgen extract -o ./docs --skip target,.git,tests
This will scan the current Rust project and generate docs/codebase.md with annotated code blocks for each file.
USAGE:
prk_mdgen [OPTIONS]
OPTIONS:
-o, --output-dir <DIR> Output directory [default: output]
-p, --pattern <PATTERN> Force a specific pattern (code-tag, hash, delimiter, raw, file-code, file-fence)
-c, --command <COMMAND> sample | prompt | extract
-e, --execute Run `cargo run` or `cargo test` on generated projects
--skip <ITEMS> Comma-separated list of files or folders to skip
--project-type <TYPE> (Optional) Language hint during extraction (e.g. rust, node, flutter)
# Generate a prompt template
prk_mdgen prompt
# Generate sample Markdown to test parsing
prk_mdgen sample
# Extract an existing Rust project to Markdown
prk_mdgen extract -o ./docs --skip target,.git
# Generate projects from Markdown and run them
prk_mdgen -o ./output -e
When generating a project from Markdown:
output/
โโโ my_project/
โโโ Cargo.toml
โโโ src/
โ โโโ main.rs
โโโ run_output.log # if main.rs exists
When extracting a project to Markdown:
output/
โโโ codebase.md # contains annotated code blocks for each source file
src/main.rs is present: runs cargo run, output is saved to run_output.logsrc/lib.rs is present: runs cargo test, output is saved to test_output.logTo test parsing or generation logic:
prk_mdgen sample
To add new parsing formats, see parser.rs and extend the MdPatternType enum and detection logic.
Pull requests welcome! Please:
cargo fmt before committingMIT
This tool is built with love in Rust using: