Skip to content

Commit 9c35f04

Browse files
committed
feat: rust doc
Run cargo doc against the workspace - great with the deny(broken_intra_doc_links) lint.
1 parent 2dbd91a commit 9c35f04

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

.pre-commit-hooks.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@
102102
minimum_pre_commit_version: 0.15.0
103103
description: 'Run cargo fmt in the repo root'
104104

105+
- id: rust-doc
106+
name: 'Cargo doc'
107+
entry: run-rust-doc.sh
108+
language: 'script'
109+
files: \.rs$
110+
pass_filenames: false
111+
minimum_pre_commit_version: 0.15.0
112+
description: 'Run cargo doc against public & private items'
113+
105114
- id: r-stylr
106115
name: 'Format with stylr'
107116
entry: run-r-stylr.R

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Hooks:
1616
* `rust-clippy`: runs `cargo clippy` lints in the repo root
1717
* `rust-test`: runs `cargo test` at the repo root, includes all targets/features/examples/benches
1818
* `rust-fmt`: runs `cargo fmt --all`
19+
* `rust-doc`: runs `cargo doc` against the workspace - great for linting [intra-doc links]
1920
* `r-stylr`: runs [`stylr`] to format R code
2021
* `r-lintr`: static analysis of R code with [`lintr`]
2122
* `buf-lint`: runs [`buf`] lints against protobuf files
@@ -78,6 +79,9 @@ repos:
7879
- id: rust-fmt
7980
stages: [commit, push]
8081

82+
- id: rust-doc
83+
stages: [push]
84+
8185
- id: r-stylr
8286
stages: [commit, push]
8387

@@ -141,4 +145,5 @@ When adding new hooks you can run `pre-commit try-repo .` for a quick syntax che
141145
[`post-checkout`]: https://git-scm.com/docs/githooks#_post_checkout
142146
[`stylr`]: https://styler.r-lib.org/
143147
[`lintr`]: https://github.com/jimhester/lintr
144-
[`buf`]: https://buf.build/
148+
[`buf`]: https://buf.build/
149+
[intra-doc links]: https://doc.rust-lang.org/rustdoc/lints.html#broken_intra_doc_links

run-rust-doc.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Requires:
6+
#![deny(broken_intra_doc_links)]
7+
cargo doc --no-deps --all-features --workspace --document-private-items

0 commit comments

Comments
 (0)