From b3a6a69f9d6eb00f4ce8fa5dfc4f2ac2327e75e1 Mon Sep 17 00:00:00 2001
From: Marco Ieni <11428655+MarcoIeni@users.noreply.github.com>
Date: Thu, 15 Apr 2021 22:53:21 +0200
Subject: [PATCH] ci: check docs for all crates

This also replaces '--all' in Cargo commands with '--workspace'. The
former has apparently been deprecated.

We also fix a couple warnings that this new step detected.

Closes #1848
---
 .github/workflows/ci.yml           | 25 +++++++++++++++++++++----
 crates/ignore/src/default_types.rs |  2 +-
 crates/regex/src/matcher.rs        |  4 ++--
 3 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 256bd822..5d821a5e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -118,10 +118,10 @@ jobs:
         echo "target flag is: ${{ env.TARGET_FLAGS }}"
 
     - name: Build ripgrep and all crates
-      run: ${{ env.CARGO }} build --verbose --all ${{ env.TARGET_FLAGS }}
+      run: ${{ env.CARGO }} build --verbose --workspace ${{ env.TARGET_FLAGS }}
 
     - name: Build ripgrep with PCRE2
-      run: ${{ env.CARGO }} build --verbose --all --features pcre2 ${{ env.TARGET_FLAGS }}
+      run: ${{ env.CARGO }} build --verbose --workspace --features pcre2 ${{ env.TARGET_FLAGS }}
 
     # This is useful for debugging problems when the expected build artifacts
     # (like shell completions and man pages) aren't generated.
@@ -139,7 +139,7 @@ jobs:
 
     - name: Run tests with PCRE2 (sans cross)
       if: matrix.target == ''
-      run: ${{ env.CARGO }} test --verbose --all --features pcre2 ${{ env.TARGET_FLAGS }}
+      run: ${{ env.CARGO }} test --verbose --workspace --features pcre2 ${{ env.TARGET_FLAGS }}
 
     - name: Run tests without PCRE2 (with cross)
       # These tests should actually work, but they almost double the runtime.
@@ -147,7 +147,7 @@ jobs:
       # enabled, every integration test is run twice: one with the default
       # regex engine and once with PCRE2.
       if: matrix.target != ''
-      run: ${{ env.CARGO }} test --verbose --all ${{ env.TARGET_FLAGS }}
+      run: ${{ env.CARGO }} test --verbose --workspace ${{ env.TARGET_FLAGS }}
 
     - name: Test for existence of build artifacts (Windows)
       if: matrix.os == 'windows-2019'
@@ -194,3 +194,20 @@ jobs:
     - name: Check formatting
       run: |
         cargo fmt --all -- --check
+
+  docs:
+    name: Docs
+    runs-on: ubuntu-20.04
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v2
+      - name: Install Rust
+        uses: actions-rs/toolchain@v1
+        with:
+          toolchain: stable
+          profile: minimal
+          override: true
+      - name: Check documentation
+        env:
+          RUSTDOCFLAGS: -D warnings
+        run: cargo doc --no-deps --document-private-items --workspace
diff --git a/crates/ignore/src/default_types.rs b/crates/ignore/src/default_types.rs
index 52d7d948..4ed94587 100644
--- a/crates/ignore/src/default_types.rs
+++ b/crates/ignore/src/default_types.rs
@@ -4,7 +4,7 @@
 /// types to each invocation of ripgrep with the '--type-add' flag.
 ///
 /// If you would like to add or improve this list, please file a PR:
-/// https://github.com/BurntSushi/ripgrep
+/// <https://github.com/BurntSushi/ripgrep>.
 ///
 /// Please try to keep this list sorted lexicographically and wrapped to 79
 /// columns (inclusive).
diff --git a/crates/regex/src/matcher.rs b/crates/regex/src/matcher.rs
index e5f560f2..3511e75b 100644
--- a/crates/regex/src/matcher.rs
+++ b/crates/regex/src/matcher.rs
@@ -19,7 +19,7 @@ use word::WordMatcher;
 /// types of optimizations.
 ///
 /// The syntax supported is documented as part of the regex crate:
-/// https://docs.rs/regex/*/regex/#syntax
+/// <https://docs.rs/regex/#syntax>.
 #[derive(Clone, Debug)]
 pub struct RegexMatcherBuilder {
     config: Config,
@@ -41,7 +41,7 @@ impl RegexMatcherBuilder {
     /// pattern.
     ///
     /// The syntax supported is documented as part of the regex crate:
-    /// https://docs.rs/regex/*/regex/#syntax
+    /// <https://docs.rs/regex/#syntax>.
     pub fn build(&self, pattern: &str) -> Result<RegexMatcher, Error> {
         let chir = self.config.hir(pattern)?;
         let fast_line_regex = chir.fast_line_regex()?;