cargo-readme
cargo-readme copied to clipboard
build.rs example
I like to auto-generate the README with a build.rs
build script so I don't forget to update it manually.
The snippet I use:
extern crate cargo_readme;
use std::{fs, path};
use std::io::Write;
fn main() {
// Generate README.md with cargo_readme.
let mut f = fs::File::open("src/lib.rs").unwrap();
let content = cargo_readme::generate_readme(
&path::PathBuf::from("./"),
&mut f,
None,
false,
false,
false,
).unwrap();
let mut f = fs::File::create("README.md").unwrap();
f.write_all(content.as_bytes()).unwrap();
}
It would be nice to have this snippet in the docs somewhere so you can just copy/paste.
What do you thing, @livioribeiro ?
This is quite interesting.
Have this approach slowed down your build times?
I will take a look a this, but if you wish, feel free to open a pull request.
FWIW I check this in my travis script. It's not as automated as re-building automatically, but it also only slows down CI, not every build.