This program generates README.md from documentation comments in lib.rs
⚓ Rust 📅 2026-02-28 👤 surdeus 👁️ 1I made a program that generates README.md from lib.rs doc comments because I think we can a lot do better than #![doc = include_str!("../README.md")].
Given this lib.rs:
//! This prints all prime numbers, using [`println!`]:
//!
//! ```
//! # fn main() {
//! for i in 2.. {
//! if is_prime(i) {
//! println!("{i}");
//! }
//! }
//! # }
//! ```
Generates this README.md:
This prints all prime numbers, using [`println!`](https://doc.rust-lang.org/stable/std/macro.println.html):
```rust
for i in 2.. {
if is_prime(i) {
println!("{i}");
}
}
```
Features
- Resolves intra-doc links to the
docs.rsurl:
| before | after |
|---|---|
[`println!`] |
[`println!`](https://doc.rust-lang.org/stable/std/macro.println.html) |
- Adds
rustlanguage to code blocks:
| before | after |
|---|---|
```ignore |
```rust |
- Expands macros:
| before | after |
|---|---|
#![doc = concat!("pkg = '", env!("CARGO_PKG_VERSION"), "'")] |
pkg = '0.4.2' |
- and more!
1 post - 1 participant
🏷️ Rust_feed