Skip to content

Commit

Permalink
Fix compilation with #![deny(missig_docs]
Browse files Browse the repository at this point in the history
fix #74
  • Loading branch information
TeXitoi committed Feb 24, 2018
1 parent c7447cd commit 7251a0a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v0.2.4 (2018-02-XX)

* Fix compilation with `#![deny(missig_docs]` ([#74](https://github.com/TeXitoi/structopt/issues/74)) by [@TeXitoi](https://github.com/TeXitoi)

# v0.2.3 (2018-02-16)

* An empty line in a doc comment will result in a double linefeed in the generated about/help call by [@TeXitoi](https://github.com/TeXitoi)
Expand Down
53 changes: 53 additions & 0 deletions examples/deny_missing_docs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) 2018 Guillaume Pinot <texitoi(a)texitoi.eu>
//
// This work is free. You can redistribute it and/or modify it under
// the terms of the Do What The Fuck You Want To Public License,
// Version 2, as published by Sam Hocevar. See the COPYING file for
// more details.

// This should be in tests but it will not work until
// https://github.com/rust-lang/rust/issues/24584 is fixed

//! A test to check that structopt compiles with deny(missing_docs)

#![deny(missing_docs)]

#[macro_use]
extern crate structopt;

use structopt::StructOpt;

/// The options
#[derive(StructOpt, Debug, PartialEq)]
pub struct Opt {
#[structopt(short = "v")]
verbose: bool,
#[structopt(subcommand)]
cmd: Option<Cmd>,
}

/// Some subcommands
#[derive(StructOpt, Debug, PartialEq)]
pub enum Cmd {
/// command A
A,
/// command B
B {
/// Alice?
#[structopt(short = "a")]
alice: bool,
},
/// command C
C(COpt),
}

/// The options for C
#[derive(StructOpt, Debug, PartialEq)]
pub struct COpt {
#[structopt(short = "b")]
bob: bool,
}

fn main() {
println!("{:?}", Opt::from_args());
}
2 changes: 2 additions & 0 deletions structopt-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ fn gen_augment_clap(fields: &Punctuated<Field, Comma>) -> quote::Tokens {
let app_var: Ident = "app".into();
let augmentation = gen_augmentation(fields, &app_var);
quote! {
#[doc(hidden)]
pub fn augment_clap<'a, 'b>(#app_var: ::structopt::clap::App<'a, 'b>) -> ::structopt::clap::App<'a, 'b> {
#augmentation
}
Expand Down Expand Up @@ -303,6 +304,7 @@ fn gen_augment_clap_enum(variants: &Punctuated<Variant, Comma>) -> quote::Tokens
});

quote! {
#[doc(hidden)]
pub fn augment_clap<'a, 'b>(app: ::structopt::clap::App<'a, 'b>) -> ::structopt::clap::App<'a, 'b> {
app #( #subcommands )*
}
Expand Down

0 comments on commit 7251a0a

Please sign in to comment.