Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README: Autogenerate from library documentation using cargo-readme #11

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MarijnS95
Copy link
Contributor

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 webern/cargo-readme#67 to get rid of the # without introducing empty newlines.

@MarijnS95 MarijnS95 marked this pull request as draft May 10, 2021 10:31
README.md Outdated
Comment on lines 10 to 18
## Usage

Add to your `Cargo.toml`:

```toml
gbm = "0.6.0"
```

## Safe `libgbm` bindings for [rust](https://www.rust-lang.org)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that this sits above the module documentation now :/

@MarijnS95
Copy link
Contributor Author

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 :)

@katyo
Copy link
Contributor

katyo commented Sep 19, 2021

@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.

@MarijnS95
Copy link
Contributor Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants