Skip to content

Commit 64233cb

Browse files
authored
Fix doc-links and run Rustdoc as part of the infra check suite (#694)
Part of #155
1 parent 0e38580 commit 64233cb

File tree

12 files changed

+38
-82
lines changed

12 files changed

+38
-82
lines changed

crates/codegen/language/definition/src/internals/parse_input_tokens/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub trait ParseInputTokens: Sized {
1818
Self::parse_value(input, errors)
1919
}
2020

21-
/// Allows implementations (like 'Option<T>') to modify the parsing logic,
21+
/// Allows implementations (like `Option<T>`) to modify the parsing logic,
2222
/// by checking if the field exists before attempting to parse it.
2323
fn parse_field(name: &str, input: ParseStream, errors: &mut ErrorsCollection) -> Result<Self> {
2424
ParseHelpers::field(name, input, errors)

crates/codegen/parser/runtime/src/support/choice_helper.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,6 @@ impl ChoiceHelper {
7979
/// Executes a closure that allows the caller to drive the choice parse.
8080
///
8181
/// Useful when you want to eagerly return a result from the parse function (e.g. when the choice was fully matched).
82-
///
83-
/// Usage:
84-
/// ```no_run
85-
/// # use codegen_parser_runtime::support::{ParserResult, ChoiceHelper, Stream};
86-
/// # fn parse_something() -> ParserResult { ParserResult::r#match(vec![], vec![]) }
87-
/// # fn parse_another() -> ParserResult { ParserResult::r#match(vec![], vec![]) }
88-
/// ChoiceHelper::run(input, |mut choice| {
89-
/// choice.consider(parse_something()).pick_or_backtrack(input)?;
90-
/// choice.consider(parse_another()).pick_or_backtrack(input)?;
91-
/// choice.finish(input)
92-
/// });
93-
/// ```
9482
pub fn run(
9583
input: &mut ParserContext,
9684
f: impl FnOnce(Self, &mut ParserContext) -> ControlFlow<ParserResult, Self>,
@@ -105,7 +93,7 @@ impl ChoiceHelper {
10593

10694
/// Aggregates a choice result into the accumulator.
10795
///
108-
/// Returns a [`Choice`] struct that can be used to either pick the value or backtrack the input.
96+
/// If a value is considered as a full match, it is returned, otherwise we backtrack and continue.
10997
pub fn consider(
11098
&mut self,
11199
input: &mut ParserContext,

crates/codegen/parser/runtime/src/support/sequence_helper.rs

-12
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,6 @@ impl SequenceHelper {
169169
/// Executes a closure that allows the caller to drive the sequence parse.
170170
///
171171
/// Useful when you want to eagerly return a result from the parse function (e.g. when we can't make more progress).
172-
///
173-
/// Usage:
174-
/// ```no_run
175-
/// # use codegen_parser_runtime::support::{ParserResult, SequenceHelper};
176-
/// # fn parse_something() -> ParserResult { ParserResult::r#match(vec![], vec![]) }
177-
/// # fn parse_another() -> ParserResult { ParserResult::r#match(vec![], vec![]) }
178-
/// SequenceHelper::run(|mut sequence| {
179-
/// sequence.elem(parse_something())?;
180-
/// sequence.elem(parse_another())?;
181-
/// sequence.finish()
182-
/// });
183-
/// ```
184172
pub fn run(f: impl FnOnce(Self) -> ControlFlow<ParserResult, Self>) -> ParserResult {
185173
match f(SequenceHelper::default()) {
186174
ControlFlow::Break(result) => result,

crates/codegen/spec/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//!
88
//! and the auxiliary snippet files included by the grammar mkdocs pages.
99
//!
10-
//! Exposes a [`SpecGeneratorExtensions`] trait that generates all the pages in a given [`CodegenContext`].
10+
//! Exposes a [`SpecGeneratorExtensions`] trait that generates all the pages in a given [`Codegen`] context.
1111
mod grammar;
1212
mod markdown;
1313
mod navigation;

crates/infra/cli/generated/infra.zsh-completions

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/infra/cli/src/commands/check/mod.rs

+16-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ impl CheckController {
2626
enum CheckCommand {
2727
/// Run 'cargo check' for all crates, features, and targets.
2828
Cargo,
29+
/// Run `cargo doc` to generate Rustdoc documentation and check for any broken links.
30+
Rustdoc,
2931
/// Check NPM packages for any outdated codegen steps.
3032
Npm,
3133
/// Check mkdocs documentation for any build issues or broken links.
@@ -38,14 +40,27 @@ impl OrderedCommand for CheckCommand {
3840

3941
match self {
4042
CheckCommand::Cargo => check_cargo(),
43+
CheckCommand::Rustdoc => check_rustdoc(),
4144
CheckCommand::Npm => check_npm(),
4245
CheckCommand::Mkdocs => check_mkdocs(),
4346
}
4447
}
4548
}
4649

4750
fn check_cargo() -> Result<()> {
48-
CargoWorkspace::get_command("check")?.run()
51+
CargoWorkspace::get_command("check")?
52+
.flag("--all-targets")
53+
.run()
54+
}
55+
56+
fn check_rustdoc() -> Result<()> {
57+
CargoWorkspace::get_command("doc")?
58+
.flag("--no-deps")
59+
.flag("--document-private-items")
60+
.flag("--lib")
61+
.flag("--bins")
62+
.flag("--examples")
63+
.run()
4964
}
5065

5166
fn check_npm() -> Result<()> {

crates/infra/cli/src/commands/lint/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ impl OrderedCommand for LintCommand {
6565
}
6666

6767
fn run_clippy() -> Result<()> {
68-
CargoWorkspace::get_command("clippy")?.run()
68+
CargoWorkspace::get_command("clippy")?
69+
.flag("--all-targets")
70+
.run()
6971
}
7072

7173
fn run_cargo_fmt() -> Result<()> {

crates/infra/utils/src/cargo/workspace.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ impl CargoWorkspace {
9999
}
100100

101101
pub fn get_command(subcommand: impl AsRef<str>) -> Result<Command> {
102+
let subcommand = subcommand.as_ref();
103+
102104
let mut command = Command::new("cargo")
103-
.arg(subcommand.as_ref())
104-
.flag("--all")
105-
.flag("--all-targets")
105+
.arg(subcommand)
106+
.flag("--workspace")
106107
.flag("--all-features");
107108

108109
if GitHub::is_running_in_ci() {
@@ -115,6 +116,15 @@ impl CargoWorkspace {
115116
rustflags = serde_json::to_string(&["--deny", "warnings"])?,
116117
),
117118
);
119+
// Rustdoc requires specifying RUSTDOCFLAGS, instead:
120+
// See <https://github.com/rust-lang/cargo/issues/8424#issuecomment-1070988443>.
121+
command = command.property(
122+
"--config",
123+
format!(
124+
"build.rustdocflags = {rustdocflags}",
125+
rustdocflags = serde_json::to_string(&["--deny", "warnings"])?,
126+
),
127+
);
118128
}
119129

120130
Ok(command)

crates/solidity/outputs/cargo/crate/src/generated/support/choice_helper.rs

+1-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/cargo/crate/src/generated/support/sequence_helper.rs

-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/npm/crate/src/generated/support/choice_helper.rs

+1-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/solidity/outputs/npm/crate/src/generated/support/sequence_helper.rs

-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)