Minor changes.

This commit is contained in:
kennytm 2016-06-08 01:03:16 +08:00
parent e3c947dc99
commit c7e6a7a22a
3 changed files with 53 additions and 1 deletions

View file

@ -9,7 +9,7 @@ repository = "https://github.com/kennytm/qrcode-rust"
readme = "README.md" readme = "README.md"
documentation = "http://kennytm.github.io/qrcode-rust/" documentation = "http://kennytm.github.io/qrcode-rust/"
exclude = [ exclude = [
".travis.yml", ".gitignore" ".travis.yml", ".gitignore", "update_doc.sh"
] ]
[dependencies] [dependencies]

View file

@ -196,6 +196,32 @@ impl QrCode {
self.content 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")] #[cfg(feature="image")]
pub fn render<P: BlankAndWhitePixel + 'static>(&self) -> Renderer<P> { pub fn render<P: BlankAndWhitePixel + 'static>(&self) -> Renderer<P> {
let quiet_zone = if self.version.is_micro() { 2 } else { 4 }; let quiet_zone = if self.version.is_micro() { 2 } else { 4 };

26
update_doc.sh Executable file
View file

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