gbm.rs icon indicating copy to clipboard operation
gbm.rs copied to clipboard

README: Autogenerate from library documentation using cargo-readme

Open MarijnS95 opened this issue 4 years ago • 3 comments

Based on the suggestion from @katyo in 1 and implementation in 2. This also adds some neat badges for the repo (though I'm not sure how relevant the SLOC one is given all the generated files...).

We'll have to wait for https://github.com/livioribeiro/cargo-readme/pull/67 to get rid of the # without introducing empty newlines.

MarijnS95 avatar May 10 '21 10:05 MarijnS95

Error: Generated README is, please regenerate with `cargo readme > README.md`
diff --git a/README.md b/README.md
index c0d3cba..e7a3138 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ gbm
 [![Lines of code](https://tokei.rs/b1/github/Smithay/gbm.rs)](https://github.com/Smithay/gbm.rs)
 ![MIT](https://img.shields.io/badge/license-MIT-blue.svg)
 
-## Usage
+### Usage
 
 Add to your `Cargo.toml`:
 
@@ -75,8 +75,4 @@ gbm.set_crtc(crtc_handle, Some(fb), (0, 0), &[con], Some(mode))
     .unwrap();
#```
 
-Current version: 0.6.0
-
-Some additional info here
-
 License: MIT
Error: Process completed with exit code 1.

Ha, that' works at least :)

MarijnS95 avatar May 10 '21 10:05 MarijnS95

@MarijnS95 Rust since 1.54 can include README.md into documentation (see https://blog.rust-lang.org/2021/07/29/Rust-1.54.0.html#attributes-can-invoke-function-like-macros). So I suggest simply to use this feature if support older Rust versions does not so important for us. I was used cargo-readme as temporary solution before.

katyo avatar Sep 19 '21 08:09 katyo

@katyo I've considered that for some other projects too, but am hesitant for a couple reasons (drawbacks):

  • cargo-readme has some macros to take care of automatically inserting {{version}} and {{license}};
  • All unnecessary bits from the readme (everything that's in README.tpl around {{readme}}) such as license and badges make it into the module docs;
  • #-prefixed lines aren't filtered out in ```rust markdown in the rendered readme;
  • ```rust,no_run isn't rendered as Rust code - but breaks doc testing if no_run is removed.

On the other hand cargo-readme is an extra utility that isn't maintained anymore.

MarijnS95 avatar Sep 19 '21 09:09 MarijnS95