From 90ef676343cb36dd5ac0a7360fba12637e37d2bf Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 4 Apr 2020 22:47:49 +0200 Subject: [PATCH] Enforce README examples testing --- Cargo.toml | 3 +++ src/lib.rs | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3b345a3..27b8c9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,9 @@ edition = "2018" [dependencies] winapi = { version = "0.3", features = ["winnt", "combaseapi", "oleauto", "roapi", "roerrorapi", "hstring", "winstring", "winerror", "restrictederrorinfo"] } +[dev-dependencies] +doc-comment = "0.3" + [features] nightly = [] windows-ai = [] diff --git a/src/lib.rs b/src/lib.rs index 590b8d1..4b6c382 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,8 +2,6 @@ //! //! ## Example //! ``` -//! # // THIS IS THE SAME CODE THAT IS SHOWN IN README.md -//! # // PLEASE KEEP THEM IN SYNC SO WE CAN RELY ON DOCTESTS! //! extern crate winrt; //! //! use winrt::*; // import various helper types @@ -28,12 +26,18 @@ #![allow(dead_code,non_upper_case_globals,non_snake_case)] +#[cfg(doctest)] +#[macro_use] +extern crate doc_comment; extern crate winapi as w; +#[cfg(doctest)] +doctest!("../README.md"); + mod guid; pub use guid::Guid; -///Represents the trust level of an activatable class (re-export from WinAPI crate) +/// Represents the trust level of an activatable class (re-export from WinAPI crate) pub type TrustLevel = w::winrt::inspectable::TrustLevel; // Compared to the DEFINE_GUID macro from winapi, this one creates a private const