From c7e6a7a22adcc25ea3f4a5a6e25a4f25b952d15a Mon Sep 17 00:00:00 2001 From: kennytm Date: Wed, 8 Jun 2016 01:03:16 +0800 Subject: [PATCH] Minor changes. --- Cargo.toml | 2 +- src/lib.rs | 26 ++++++++++++++++++++++++++ update_doc.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100755 update_doc.sh diff --git a/Cargo.toml b/Cargo.toml index 77ff301..2aad91f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ repository = "https://github.com/kennytm/qrcode-rust" readme = "README.md" documentation = "http://kennytm.github.io/qrcode-rust/" exclude = [ - ".travis.yml", ".gitignore" + ".travis.yml", ".gitignore", "update_doc.sh" ] [dependencies] diff --git a/src/lib.rs b/src/lib.rs index c79763c..c7678a6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -196,6 +196,32 @@ impl QrCode { self.content } + /// Renders the QR code into an image. The result is an image builder, which + /// you may do some additional configuration before copying it into a + /// concrete image. + /// + /// # Examples + /// + /// ``` + /// # extern crate image; + /// # extern crate qrcode; + /// # use qrcode::QrCode; + /// # use image::Rgb; + /// # fn main() { + /// + /// let image = QrCode::new(b"hello").unwrap() + /// .render() + /// .dark_color(Rgb { data: [0, 0, 128] }) + /// .light_color(Rgb { data: [224, 224, 224] }) // adjust colors + /// .quiet_zone(false) // disable quiet zone (white border) + /// .min_width(300) // sets minimum image size + /// .to_image(); + /// + /// # } + /// ``` + /// + /// Note: the `image` crate itself also provides method to rotate the image, + /// or overlay a logo on top of the QR code. #[cfg(feature="image")] pub fn render(&self) -> Renderer

{ let quiet_zone = if self.version.is_micro() { 2 } else { 4 }; diff --git a/update_doc.sh b/update_doc.sh new file mode 100755 index 0000000..29b093d --- /dev/null +++ b/update_doc.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# Generate documentation and commit into the gh-pages branch. + +set -euo pipefail + +VERSION=$(grep -w version -m 1 Cargo.toml) +COMMIT=$(git rev-parse HEAD) + +rustup default nightly +cargo doc +git worktree add doc gh-pages +cd doc +git rm -r . +git reset HEAD .gitignore index.html +git checkout -- .gitignore index.html +mv ../target/doc/qrcode . +mv ../target/doc/*.{txt,woff,js,css} . +mkdir src +mv ../target/doc/src/qrcode src +git add . +git commit -m "Update doc for ${VERSION} (${COMMIT})" +cd .. +rm -rf doc +git worktree prune +