1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//! This project is Erich's personal Rust starter kit for developing new libraries and binaries in
//! Rust. You shouldn't be seeing this anywhere outside of his
//! [`new-rust-project`](https://github.com/erichdongubler/new-rust-project) repo.
//!
//! ## Overview
//!
//! At one point, Erich got tired of accumulating lots of interesting tidbits for starting Rust
//! projects that he knew he'd forget. So he finally hunkered down and made this repo. An example
//! of usage:
//!
//! ```sh,ignore
//! #! /bin/sh
//!
//! git clone --shallow https://github.com/ErichDonGubler/new-rust-project name-of-new-rust-project
//! cd name-of-new-rust-project
//! rm -rf .git
//! git init
//! git add .
//! git commit -m "Initial commit"
//! git remote add origin git@github.com:ErichDonGubler/name-of-new-rust-project
//! git push -u origin master
//! ```
//!
//! ## Features
//!
//! ### Licensing
//!
//! This template uses [MPL 2.0](LICENSE.md) by default. Erich's reasons for MPL by default here are:
//!
//! * Very permissive license in general
//! * Patent protection for that project that suddenly takes off
//! * Not-terribly-annoying copyleft
//!
//! When in doubt, remember that Erich is not a lawyer. change your own project to use what you
//! deem appropriate.
//!
//! ### Contributing
//!
//! Contributions, feature requests, and bug reports are warmly welcomed! See the [contribution
//! guidelines](CONTRIBUTING.md) for getting started.
//!
//! The [code of conduct](CODE_OF_CONDUCT.md) uses [Contributor Covenant
//! v1.4.1](https://www.contributor-covenant.org/version/1/4/code-of-conduct). If there's a newer
//! version of this, feel free to open a PR!
//!
//! ### Crate documentation in README
//!
//! Crate documentation is inlined into this README.  This means you get doc-tests for freebies!
//! Try it out by reading the README -- it uses `cargo-sync-readme`.  Also, this is integrated into
//! CI, so you don't forget about it!
//!
//! ```rust
//! println!("This should run just fine.");
//! ```
//!
//! ```rust,should_panic
//! panic!("This should panic.");
//! ```
//!
//! ```rust,compile_fail
//! !@#$% // This should fail to compile.
//! ```
//!
//! ### Intelligent defaults for docs
//!
//! The [Rust Playground](https://play.rust-lang.org/) is used as the playground service by
//! default.
//!
//! ### `cargo-release` configuration
//!
//! `cargo-release` is configured to keep features of this template in sync with version releases,
//! and has some defaults Erich considers more sensible.
//!
//! # CHANGELOG
//!
//! Yes, you should maintain a [`CHANGELOG`](CHANGELOG.md). ;)
//!
//! ### More aggressive linting and tests
//!
//! Several `rustc` and `clippy` lints have been enabled that Erich prefers. See the top of
//! [`src/lib.rs`](src/lib.rs) for the full list.
//!
//! Warnings are denied in doctests and in release mode.
//!
//! ### Out-of-the-box CI
//!
//! The associated CI configuration (Travis at [`.travis.yml`](.travis.yml)) tests:
//! * Runs tests on Linux, Windows, and MacOS.
//! * The full set of lints with `cargo clippy`
//! * Formatting with `cargo fmt`
//! * The full suite of built-in tests with `cargo test`
//!
//! ### Buttons!
//!
//! There are a variety of handy buttons on the top of the README. These are meant to encourage
//! activity both for maintainers and newcomers. Some buttons may not be suitable for, say,
//! internal or private projects that won't actually be published on `crates.io`. You are
//! encouraged to keep the ones you want and throw out the rest.

#![cfg_attr(not(debug_assertions), deny(warnings))]
#![doc(html_playground_url = "https://play.rust-lang.org/")]
// UNCOMMENT_BEFORE_RELEASE: #![doc(html_root_url = "https://docs.rs/new-rust-project/0.1.2")]
#![doc(test(attr(deny(warnings))))]
#![doc(test(attr(warn(
    bare_trait_objects,
    clippy::cargo,
    clippy::pedantic,
    elided_lifetimes_in_paths,
    missing_copy_implementations,
    single_use_lifetimes,
    unused_extern_crates,
))))]
#![warn(
    bare_trait_objects,
    clippy::cargo,
    clippy::pedantic,
    elided_lifetimes_in_paths,
    missing_copy_implementations,
    missing_docs,
    single_use_lifetimes,
    unused_extern_crates
)]
#![allow(clippy::multiple_crate_versions)]

#[test]
fn check_readme_synchronized() {
    use {
        cargo_sync_readme::{extract_inner_doc, read_readme, transform_readme},
        std::path::PathBuf,
    };

    let crate_docs = extract_inner_doc(file!(), false, cfg!(windows));
    let readme_path = PathBuf::from(file!())
        .parent()
        .and_then(|p| p.parent())
        .expect("unable to create path to README dir")
        .join("README.md");
    let current_readme_content = read_readme(readme_path).expect("unable to read README");
    if transform_readme(&current_readme_content, crate_docs, cfg!(windows)).unwrap()
        != current_readme_content
    {
        panic!("README is not sync'd -- make sure to run `cargo sync-readme`");
    }
}

#[test]
fn test_html_root_url() {
    version_sync::assert_html_root_url_updated!(file!());
}