Skip to content

Commit

Permalink
README: Autogenerate from library documentation using cargo-readme
Browse files Browse the repository at this point in the history
Based on the suggestion from @katyo in [1] and implementation in [2].

[1]: Smithay#9 (comment)
[2]: https://github.com/katyo/aubio-rs/pull/18/files
  • Loading branch information
MarijnS95 committed May 10, 2021
1 parent fd1a49b commit 8c5815e
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 13 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:

doc:
runs-on: ubuntu-latest
needs: cargo-readme
steps:
- uses: actions/checkout@v2
- name: Setup Rust
Expand All @@ -59,6 +60,15 @@ jobs:
DOCS_RS: 1
with:
command: doc
- name: Setup Cargo readme
uses: actions/cache@v2
with:
path: ~/.cargo/bin/cargo-readme
key: ${{ runner.os }}-cargo-readme
- name: Generate README
run: |
cargo readme > README.md
git diff --quiet || (echo '::error::Generated README is, please regenerate with `cargo readme > README.md`'; git diff; false)
check:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -305,3 +315,19 @@ jobs:
registry-token: ${{ secrets.CRATES_TOKEN }}
args: --no-verify
#dry-run: true

cargo-readme:
runs-on: ubuntu-latest
steps:
- name: Prepare cache
uses: actions/cache@v2
id: cache
with:
path: ~/.cargo/bin/cargo-readme
key: ${{ runner.os }}-cargo-readme
- name: Install cargo readme
if: steps.cache.outputs.cache-hit != 'true'
uses: actions-rs/cargo@v1
with:
command: install
args: cargo-readme
43 changes: 30 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
gbm
=

[![Actions Status](https://github.com/Smithay/gbm.rs/workflows/Continuous%20integration/badge.svg)](https://github.com/Smithay/gbm.rs/actions)
[![Latest version](https://img.shields.io/crates/v/hassle-rs.svg)](https://crates.io/crates/hassle-rs)
[![Documentation](https://docs.rs/hassle-rs/badge.svg)](https://docs.rs/hassle-rs)
[![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

Add to your `Cargo.toml`:

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

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

The Generic Buffer Manager
Expand All @@ -11,30 +28,23 @@ the underlying memory manager.
This library is best used in combination with [`drm-rs`](https://github.com/Smithay/drm-rs),
provided through the `drm-support` feature.

## Usage

Add to your Cargo.toml

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

## Example
### Example

```rust
extern crate drm;
extern crate gbm;

use drm::control::{self, crtc, framebuffer};
use gbm::{BufferObjectFlags, Device, Format};

#
#
#
#
// ... init your drm device ...
let drm = init_drm_device();

// init a GBM device
let gbm = Device::new(drm).unwrap();

// create a buffer
// create a 4x4 buffer
let mut bo = gbm
.create_buffer_object::<()>(
1280,
Expand All @@ -59,7 +69,14 @@ bo.write(&buffer).unwrap();
// create a framebuffer from our buffer
let fb = gbm.add_framebuffer(&bo, 32, 32).unwrap();

#
// display it (and get a crtc, mode and connector before)
gbm.set_crtc(crtc_handle, Some(fb), (0, 0), &[con], Some(mode))
.unwrap();
```

Current version: 0.6.0

Some additional info here

License: MIT
20 changes: 20 additions & 0 deletions README.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{crate}}
=

[![Actions Status](https://github.com/Smithay/gbm.rs/workflows/Continuous%20integration/badge.svg)](https://github.com/Smithay/gbm.rs/actions)
[![Latest version](https://img.shields.io/crates/v/hassle-rs.svg)](https://crates.io/crates/hassle-rs)
[![Documentation](https://docs.rs/hassle-rs/badge.svg)](https://docs.rs/hassle-rs)
[![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

Add to your `Cargo.toml`:

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

{{readme}}

License: {{license}}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
//! BufferObjectFlags::SCANOUT | BufferObjectFlags::WRITE,
//! )
//! .unwrap();
//!
//! // write something to it (usually use import or egl rendering instead)
//! let buffer = {
//! let mut buffer = Vec::new();
Expand Down

0 comments on commit 8c5815e

Please sign in to comment.