Skip to content

Commit a0da372

Browse files
authored
Change dv doc options (#19)
* Change to no-verus-conds and add verus-conds-debug * Bug fix
1 parent 5507d67 commit a0da372

2 files changed

Lines changed: 36 additions & 13 deletions

File tree

src/doc.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ use std::path::Path;
44
use std::process::Command;
55

66
/// Generate documentation for verification targets
7-
pub fn exec_doc(target: &str, verus_conds: bool) -> Result<(), DynError> {
7+
pub fn exec_doc(target: &str, verus_conds: bool, verus_conds_debug: bool) -> Result<(), DynError> {
88
let target_to_use = verus::find_target(target)?;
9-
generate_docs(&target_to_use, verus_conds)?;
9+
generate_docs(&target_to_use, verus_conds, verus_conds_debug)?;
1010
Ok(())
1111
}
1212

1313
/// Generate documentation for the target including all its dependencies
14-
fn generate_docs(target: &VerusTarget, verus_conds: bool) -> Result<(), DynError> {
14+
fn generate_docs(
15+
target: &VerusTarget,
16+
verus_conds: bool,
17+
verus_conds_debug: bool,
18+
) -> Result<(), DynError> {
1519
info!(
1620
"Generating documentation for {} with all dependencies...",
1721
target.name
@@ -26,13 +30,18 @@ fn generate_docs(target: &VerusTarget, verus_conds: bool) -> Result<(), DynError
2630

2731
for (_name, dep_target) in deps.iter() {
2832
if dep_target.name != target.name {
29-
generate_single_target_doc(dep_target, verus_conds, &doc_output_dir)?;
33+
generate_single_target_doc(
34+
dep_target,
35+
verus_conds,
36+
verus_conds_debug,
37+
&doc_output_dir,
38+
)?;
3039
}
3140
}
3241

33-
generate_single_target_doc(target, verus_conds, &doc_output_dir)?;
42+
generate_single_target_doc(target, verus_conds, verus_conds_debug, &doc_output_dir)?;
3443

35-
if verus_conds {
44+
if verus_conds && !verus_conds_debug {
3645
run_verusdoc_postprocessor()?;
3746
}
3847

@@ -45,6 +54,7 @@ fn generate_docs(target: &VerusTarget, verus_conds: bool) -> Result<(), DynError
4554
fn generate_single_target_doc(
4655
target: &VerusTarget,
4756
verus_conds: bool,
57+
verus_conds_debug: bool,
4858
doc_output_dir: &Path,
4959
) -> Result<(), DynError> {
5060
info!(
@@ -57,8 +67,12 @@ fn generate_single_target_doc(
5767
let target_dir = verus::get_target_dir();
5868
let mut cmd = Command::new("rustdoc");
5969

60-
// Set VERUSDOC environment variable based on verus_conds flag
61-
let verus_doc_value = if verus_conds { "1" } else { "0" };
70+
// Set VERUSDOC environment variable based on verus_conds flags
71+
let verus_doc_value = if verus_conds || verus_conds_debug {
72+
"1"
73+
} else {
74+
"0"
75+
};
6276
cmd.env("VERUSDOC", verus_doc_value);
6377
cmd.env("RUSTC_BOOTSTRAP", "1");
6478

src/main.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,20 @@ struct DocArgs {
197197
target: String,
198198

199199
#[arg(
200-
long = "verus-conds",
201-
help = "Include Verus pre/post conditions in generated docs",
200+
long = "no-verus-conds",
201+
help = "Call normal rustdoc without Verus conditions",
202202
default_value = "false",
203-
action = ArgAction::SetTrue)]
204-
verus_conds: bool,
203+
action = ArgAction::SetTrue,
204+
conflicts_with = "verus_conds_debug")]
205+
no_verus_conds: bool,
206+
207+
#[arg(
208+
long = "verus-conds-debug",
209+
help = "Show `verus_doc_special_attr` in generated docs without verusdoc post-processing",
210+
default_value = "false",
211+
action = ArgAction::SetTrue,
212+
conflicts_with = "no_verus_conds")]
213+
verus_conds_debug: bool,
205214
}
206215

207216
#[derive(Parser, Debug)]
@@ -423,7 +432,7 @@ fn verify(args: &VerifyArgs) -> Result<(), DynError> {
423432
}
424433

425434
fn doc(args: &DocArgs) -> Result<(), DynError> {
426-
doc::exec_doc(&args.target, args.verus_conds)
435+
doc::exec_doc(&args.target, !args.no_verus_conds, args.verus_conds_debug)
427436
}
428437

429438
fn bootstrap(args: &BootstrapArgs) -> Result<(), DynError> {

0 commit comments

Comments
 (0)