docmatic-0.1.2/.clog.toml010066600017500001750000000001561326537272000134320ustar0000000000000000[clog] repository = "https://github.com/assert-rs/docmatic" changelog = "CHANGELOG.md" from-latest-tag = true docmatic-0.1.2/.github/ISSUE_TEMPLATE.md010066600017500001750000000005211326536642400156000ustar0000000000000000 I tried this code: I expected to see this happen: Instead this happened: ## Meta predicates-rs version: `rustc --version --verbose`: docmatic-0.1.2/.github/PULL_REQUEST_TEMPLATE.md010066600017500001750000000001661326536642400167010ustar0000000000000000 docmatic-0.1.2/.gitignore010066600017500001750000000000401326536625000135140ustar0000000000000000 /target/ **/*.rs.bk Cargo.lock docmatic-0.1.2/.travis.yml010066600017500001750000000015231327017357100136420ustar0000000000000000sudo: false language: rust rust: - 1.24.0 # oldest supported version - stable - beta - nightly matrix: include: - env: RUSTFMT rust: 1.24.0 # `stable`: Locking down for consistent behavior install: - rustup component add rustfmt-preview script: - cargo fmt -- --write-mode=diff - env: RUSTFLAGS="-D warnings" rust: 1.24.0 # `stable`: Locking down for consistent behavior script: - cargo check --tests - env: CLIPPY_VERSION=0.0.179 rust: nightly-2018-01-12 install: - travis_wait cargo install clippy --version $CLIPPY_VERSION || echo "clippy already installed" script: - cargo clippy -- -D clippy install: - rustc -Vv - cargo -V script: - rm -rf target/debug/deps/*docmatic* # Avoid link problems with cached versions - cargo test --verbose - cargo doc --no-deps cache: cargo: true docmatic-0.1.2/CHANGELOG.md010066600017500001750000000020671327017417700133510ustar0000000000000000 ## 0.1.2 (2018-04-25) #### Bug Fixes * Remove assert_file_impl from public API ([4fa6ac1f](https://github.com/assert-rs/docmatic/commit/4fa6ac1fc6b648cc699eca9f1b098177050bf568)) * **CI:** Bump minimum Rust version ([d5598851](https://github.com/assert-rs/docmatic/commit/d5598851752292344ef09a2e759936ef08991df3)) * **crate:** Remove unnecessary `glob` dependency ([59bffb4b](https://github.com/assert-rs/docmatic/commit/59bffb4bbc5529bf3a7d9168ff6eb74da87735e8)) #### Features * Add `docmatic::Assert` type and methods ([2ee9c763](https://github.com/assert-rs/docmatic/commit/2ee9c763f200ce1ce6f2a891f6d7ccf23d53e667)) ## 0.1.1 (2018-04-17) #### Bug Fixes * **crate:** Add metadata ([8cc81d0b](https://github.com/assert-rs/docmatic/commit/8cc81d0ba675a651360dccb33cd5056bc05b1c53), closes [#1](https://github.com/assert-rs/docmatic/issues/1)) ## 0.1.0 (2018-04-17) * Initial implementation ([0b0b5985](https://github.com/assert-rs/docmatic/commit/0b0b59857ee320a03a7721d131217a5f077b0954)) docmatic-0.1.2/CONTRIBUTING.md010066600017500001750000000051711326536734200137720ustar0000000000000000# Contributing to docmatic Thanks for wanting to contribute! There are many ways to contribute and we appreciate any level you're willing to do. ## Feature Requests Need some new functionality to help? You can let us know by opening an [issue][new issue]. It's helpful to look through [all issues][all issues] in case its already being talked about. ## Bug Reports Please let us know about what problems you run into, whether in behavior or ergonomics of API. You can do this by opening an [issue][new issue]. It's helpful to look through [all issues][all issues] in case its already being talked about. ## Pull Requests Looking for an idea? Check our [issues][issues]. If it's look more open ended, it is probably best to post on the issue how you are thinking of resolving the issue so you can get feedback early in the process. We want you to be successful and it can be discouraging to find out a lot of re-work is needed. Already have an idea? It might be good to first [create an issue][new issue] to propose it so we can make sure we are aligned and lower the risk of having to re-work some of it and the discouragement that goes along with that. ### Process When you first post a PR, we request that the the commit history get cleaned up. We recommend avoiding this during the PR to make it easier to review how feedback was handled. Once the commit is ready, we'll ask you to clean up the commit history. Once you let us know this is done, we can move forward with merging! If you are uncomfortable with these parts of git, let us know and we can help. We ask that all new files have the copyright header. Please update the copyright year for files you are modifying. As a heads up, we'll be running your PR through the following gauntlet: - warnings turned to compile errors - `cargo test` - `rustfmt` - `clippy` - `rustdoc` Check out our [CI][travis] for more information. ## Releasing When we're ready to release, a project owner should do the following - Determine what the next version is, according to semver - Bump version in a commit - Update CHANGELOG.md - Update the version in `Cargo.toml` - Update the dependency version in `src/lib.rs` - Update the dependency version in `README.md` - Tag the commit via `git tag -am "v.." v..` - `git push upstream master --tag v..` - Run `cargo publish` (run `cargo login` first if needed) [issues]: https://github.com/assert-rs/docmatic/issues [new issue]: https://github.com/assert-rs/docmatic/issues/new [all issues]: https://github.com/assert-rs/docmatic/issues?utf8=%E2%9C%93&q=is%3Aissue [travis]: https://github.com/assert-rs/docmatic/blob/master/.travis.yml docmatic-0.1.2/Cargo.toml.orig010066600017500001750000000011141327017401700144100ustar0000000000000000[package] name = "docmatic" version = "0.1.2" authors = ["Ed Page ", "Martin Larralde "] description = "Test Rust examples in your documentation." repository = "https://github.com/assert-rs/docmatic" documentation = "https://docs.rs/docmatic" readme = "README.md" categories = ["development-tools", "development-tools::testing"] keywords = ["markdown", "documentation", "testing"] license = "MIT" [badges] travis-ci = { repository = "assert-rs/docmatic" } appveyor = { repository = "epage/docmatic" } [dependencies] which = "2.0" docmatic-0.1.2/Cargo.toml0000644000000021330000000000000106530ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g. crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "docmatic" version = "0.1.2" authors = ["Ed Page ", "Martin Larralde "] description = "Test Rust examples in your documentation." documentation = "https://docs.rs/docmatic" readme = "README.md" keywords = ["markdown", "documentation", "testing"] categories = ["development-tools", "development-tools::testing"] license = "MIT" repository = "https://github.com/assert-rs/docmatic" [dependencies.which] version = "2.0" [badges.appveyor] repository = "epage/docmatic" [badges.travis-ci] repository = "assert-rs/docmatic" docmatic-0.1.2/LICENSE-APACHE010066600017500001750000000236751326536636700135040ustar0000000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS docmatic-0.1.2/LICENSE-MIT010066600017500001750000000020561326536636700132020ustar0000000000000000MIT License Copyright (c) 2017 Nick Stevens Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. docmatic-0.1.2/README.md010066600017500001750000000043341326623627100130150ustar0000000000000000# docmatic > Be dogmatic about working documentation. [![Build Status](https://travis-ci.org/assert-rs/docmatic.svg?branch=master)](https://travis-ci.org/assert-rs/docmatic) [![Build status](https://ci.appveyor.com/api/projects/status/bte7gyfxylva10ax?svg=true)](https://ci.appveyor.com/project/epage/docmatic) [![Documentation](https://img.shields.io/badge/docs-master-blue.svg)](https://docs.rs/docmatic) ![License](https://img.shields.io/crates/l/docmatic.svg) [![Crates.io](https://img.shields.io/crates/v/docmatic.svg?maxAge=2592000)](https://crates.io/crates/docmatic) ## Usage First, add this to your `Cargo.toml`: ```toml [dev-dependencies] docmatic = "0.1" ``` Next, in your test file: ```rust extern crate docmatic; fn test_readme() { docmatic::assert_file("README.md"); } ``` For more information on using docmatic, look at the [documentation](https://docs.rs/docmatic) ## Why Docmatic? Compared to doing nothing: - When you have stale documentation, it gives a sour taste to those considering your crate Compared to [`#![doc(include = "../README.md")]`](https://github.com/yoshuawuyts/human-panic/tree/ed11055e0602c3c8d223ed8354058fefb9ac47ec) - Allows your README to focus on potential contributors and your API docs on potential users - Doesn't require nightly Compared to `rustdoc -L target/debug/deps/ --test README.md` - For docmatic: - Easier for contributors to know how to run - For rustdoc: - Simple - No dependencies to muck with Compared to [skeptic](https://github.com/budziq/rust-skeptic): - For docmatic: - Fewer dependencies for faster build - Doesn't require exposing those dependencies to your users via a `[build-dependencies]` - Runs in the expected working directory - For skeptic: - Skeptic templates - Better integration with `cargo test` (each block is a distinct test) ## License `docmatic` is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See LICENSE-APACHE, and LICENSE-MIT for details. ## Credits We're grateful for all of the work done on [skeptic](https://github.com/budziq/rust-skeptic), the spiritual predecessor to docmatic and the work of [people iterating on a lighter weight solution](https://github.com/budziq/rust-skeptic/issues/60). docmatic-0.1.2/appveyor.yml010066600017500001750000000014351327017357100141230ustar0000000000000000environment: global: TARGET: x86_64-pc-windows-msvc CHANNEL: stable matrix: - CHANNEL: 1.24.0 # oldest supported version - CHANNEL: stable - CHANNEL: beta - CHANNEL: nightly install: - ps: >- $Env:PATH += ';C:\msys64\usr\bin' - curl -sSf -o rustup-init.exe https://win.rustup.rs/ - rustup-init.exe -y --default-host %TARGET% --default-toolchain %CHANNEL% - set PATH=%PATH%;C:\Users\appveyor\.cargo\bin - rustc -Vv - cargo -V test_script: - del /S/Q target\\debug\\deps\\*docmatic* || echo Not present # Avoid link problems with cached versions - cargo test --verbose cache: - C:\Users\appveyor\.cargo\registry - target notifications: - provider: Email on_build_success: false # Building is done in the test phase, so we disable Appveyor's build phase. build: false docmatic-0.1.2/src/lib.rs010066600017500001750000000063001327017357100134320ustar0000000000000000//! docmatic: //! //! `docmatic` runs `rustdoc` on your documentation files. //! //! ## Writing code blocks //! //! See ["Documentation tests"](https://doc.rust-lang.org/beta/rustdoc/documentation-tests.html) //! for how to customize your code blocks being run as tests. //! //! ## Example //! //! First, add this to your `Cargo.toml`: //! //! ```toml //! [dev-dependencies] //! docmatic = "0.1" //! ``` //! //! Next, in your test file: //! //! ```rust //! extern crate docmatic; //! //! fn test_readme() { //! docmatic::assert_file("README.md"); //! } //! ``` extern crate which; use std::path; use std::ffi::OsStr; /// A specialized process builder managing a `rustdoc` test session. /// /// # Example /// /// The following code will test the crate README with the `docmatic` /// configuration set and a default library path: /// /// ```rust /// extern crate docmatic; /// /// use std::default::Default; /// /// fn test_readme() { /// docmatic::Assert::default() /// .cfg("docmatic") /// .test_file("README.md") /// } /// ``` pub struct Assert(std::process::Command); impl Assert { /// Construct a new `Assert` with no flags set. /// /// Will likely fail if you don't provide at least one library path /// containing the tested crate. Instead, you should probably use /// [`Assert::default`] /// /// [`Assert::default`]: #tymethod.default pub fn new() -> Self { let executable = which::which("rustdoc").expect("rustdoc not found"); Assert(std::process::Command::new(executable)) } /// Add a path to the library paths passed to `rustdoc`. pub fn library_path(&mut self, path: S) -> &mut Self where S: AsRef, { self.0.arg("--library-path").arg(path); self } /// Add a *cfg* to the configuration passed to `rustdoc`. pub fn cfg(&mut self, cfg: S) -> &mut Self where S: AsRef, { self.0.arg("--cfg").arg(cfg); self } /// Test the given file, and panics on failure. pub fn test_file

(&mut self, path: P) where P: AsRef, { let process = self.0.arg("--test").arg(path.as_ref()).spawn(); let result = process .expect("rustdoc is runnable") .wait() .expect("rustdoc can run"); assert!( result.success(), format!("Failed to run rustdoc tests on '{:?}'", path.as_ref()) ); } } impl Default for Assert { /// Create an `Assert` instance with the following default parameters: /// /// * `--library-path` set to the current *deps* directory (`target/debug/deps` or /// `target/release/deps` depending on the test compilation mode). /// fn default() -> Self { let mut assert = Self::new(); let current_exe = std::env::current_exe() .and_then(|p| p.canonicalize()) .expect("could not get path to test executable"); assert.library_path(current_exe.parent().expect("parent exists")); assert } } /// Test a single file with default parameters. pub fn assert_file

(documentation: P) where P: AsRef, { Assert::default().test_file(documentation); } docmatic-0.1.2/tests/test_readme.rs010066600017500001750000000001351327017357100155330ustar0000000000000000extern crate docmatic; #[test] fn test_readme() { docmatic::assert_file("README.md"); }