Skip to content
This repository has been archived by the owner on May 20, 2020. It is now read-only.

Commit

Permalink
display the name of the documented library
Browse files Browse the repository at this point in the history
  • Loading branch information
euclio committed Aug 26, 2017
1 parent 30babe6 commit fd6dcbc
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,25 @@ pub fn target_from_metadata(ui: &Ui, metadata: &serde_json::Value) -> Result<Tar
TargetKind::Binary => false,
});

if !libs.is_empty() {
ui.warn(
"Found more than one target to document. Documenting the library.",
);
Ok(libs.remove(0))
// Default to documenting the library if it exists.
let target = if !libs.is_empty() {
libs.remove(0)
} else {
let target = bins.remove(0);
ui.warn(&format!(
"Found more than one target to document. Documenting the first binary: {}",
target.name
));
Ok(target)
}
bins.remove(0)
};

let kind = match target.kind {
TargetKind::Library => "library",
TargetKind::Binary => "first binary",
};

ui.warn(&format!(
"Found more than one target to document. Documenting the {}: {}",
kind,
target.name
));

Ok(target)
}
}

Expand Down

0 comments on commit fd6dcbc

Please sign in to comment.