Skip to content

Commit

Permalink
Minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytm committed Jun 7, 2016
1 parent 3db4311 commit 38e822d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
26 changes: 26 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P: BlankAndWhitePixel + 'static>(&self) -> Renderer<P> {
let quiet_zone = if self.version.is_micro() { 2 } else { 4 };
Expand Down
26 changes: 26 additions & 0 deletions update_doc.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 38e822d

Please sign in to comment.