Skip to content

Commit 299d118

Browse files
committed
Add build_only_latest_option flag
1 parent ce16eda commit 299d118

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/docbuilder/mod.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11

2-
//! DocBuilder
3-
4-
// TODO:
5-
// * Need to get proper version of crate when dealing with local dependencies
6-
// Some crates are using '*' version for their local dependencies. DocBuilder
7-
// or Crate must get proper version information. To do this, I am planning
8-
// to find correct crate file in crates.io-index and generate a crate
9-
// from it. And add a function like find_version to return correct version
10-
// of local dependency.
11-
122
pub mod crte;
133

144
use std::io::prelude::*;
@@ -24,7 +14,6 @@ use toml;
2414
use regex::Regex;
2515

2616

27-
/// Alright
2817
pub struct DocBuilder {
2918
keep_build_directory: bool,
3019
destination: PathBuf,
@@ -35,6 +24,7 @@ pub struct DocBuilder {
3524
logs_path: PathBuf,
3625
skip_if_exists: bool,
3726
skip_if_log_exists: bool,
27+
build_only_latest_version: bool,
3828
debug: bool,
3929
}
4030

@@ -111,6 +101,7 @@ impl Default for DocBuilder {
111101
keep_build_directory: false,
112102
skip_if_exists: false,
113103
skip_if_log_exists: false,
104+
build_only_latest_version: false,
114105
debug: false,
115106
}
116107
}
@@ -194,6 +185,10 @@ impl DocBuilder {
194185
self.skip_if_log_exists = b;
195186
}
196187

188+
pub fn build_only_latest_version(&mut self, b: bool) {
189+
self.build_only_latest_version = b;
190+
}
191+
197192

198193
pub fn check_paths(&self) -> Result<(), DocBuilderPathError> {
199194
if !self.destination.exists() {
@@ -263,6 +258,12 @@ impl DocBuilder {
263258
&crte.name, &crte.versions[i], e)
264259
}
265260
}
261+
262+
// if self.build_only_latest_version is true
263+
// we are skipping oldest versions of crate
264+
if self.build_only_latest_version {
265+
break;
266+
}
266267
}
267268
}
268269

src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ fn main() {
177177
.long("keep-build-directory")
178178
.help("Keeps build directory after build."))
179179
.subcommand(SubCommand::with_name("world")
180-
.about("Builds documentation of every crate"))
180+
.about("Builds documentation of every crate")
181+
.arg(Arg::with_name("BUILD_ONLY_LATEST_VERSION")
182+
.long("build-only-latest-version")
183+
.help("Builds only latest version of crate and \
184+
skips oldest versions")))
181185
.subcommand(SubCommand::with_name("crate")
182186
.about("Builds documentation for a crate")
183187
.arg(Arg::with_name("CRATE_NAME")
@@ -232,7 +236,8 @@ fn main() {
232236
}
233237

234238
// build world
235-
if let Some(_) = matches.subcommand_matches("world") {
239+
if let Some(matches) = matches.subcommand_matches("world") {
240+
dbuilder.build_only_latest_version(matches.is_present("BUILD_ONLY_LATEST_VERSION"));
236241
dbuilder.build_doc_for_every_crate();
237242
}
238243

0 commit comments

Comments
 (0)