about summary refs log tree commit diff
path: root/src/doc/rustc-dev-guide
diff options
context:
space:
mode:
authorjyn <github@jyn.dev>2023-04-08 22:08:46 -0500
committerGitHub <noreply@github.com>2023-04-09 12:08:46 +0900
commit8c838fb2fbcfae52b24d361cfe3152930a5a01d5 (patch)
tree06f7d6301334524a8c209893ae5cf32900ca75ec /src/doc/rustc-dev-guide
parent41dac679da4639f540a82b92733a895b8d20a434 (diff)
Various improvements to `check_line_lengths.sh` (#1667)
Diffstat (limited to 'src/doc/rustc-dev-guide')
-rw-r--r--src/doc/rustc-dev-guide/.github/workflows/ci.yml2
-rw-r--r--src/doc/rustc-dev-guide/README.md6
-rwxr-xr-xsrc/doc/rustc-dev-guide/ci/lengthcheck.sh (renamed from src/doc/rustc-dev-guide/ci/check_line_lengths.sh)8
-rw-r--r--src/doc/rustc-dev-guide/src/contributing.md2
4 files changed, 9 insertions, 9 deletions
diff --git a/src/doc/rustc-dev-guide/.github/workflows/ci.yml b/src/doc/rustc-dev-guide/.github/workflows/ci.yml
index 2346698d449..bb0493bf7fe 100644
--- a/src/doc/rustc-dev-guide/.github/workflows/ci.yml
+++ b/src/doc/rustc-dev-guide/.github/workflows/ci.yml
@@ -46,7 +46,7 @@ jobs:
         if: github.event_name != 'push'
         run: |
           shopt -s globstar
-          MAX_LINE_LENGTH=100 bash ci/check_line_lengths.sh src/**/*.md
+          MAX_LINE_LENGTH=100 bash ci/lengthcheck.sh src/**/*.md
 
       - name: Install latest nightly Rust toolchain
         if: steps.mdbook-cache.outputs.cache-hit != 'true'
diff --git a/src/doc/rustc-dev-guide/README.md b/src/doc/rustc-dev-guide/README.md
index b2b538ffb65..fdf6c5050d8 100644
--- a/src/doc/rustc-dev-guide/README.md
+++ b/src/doc/rustc-dev-guide/README.md
@@ -67,20 +67,20 @@ including the `<!-- toc -->` marker at the place where you want the TOC.
 ### Pre-commit script
 
 We also test that line lengths are less than 100 columns. To test this locally,
-you can run `ci/check_line_lengths.sh`.
+you can run `ci/lengthcheck.sh`.
 
 You can also set this to run automatically.
 
 On Linux:
 
 ```bash
-ln -s ../../ci/check_line_lengths.sh .git/hooks/pre-commit
+ln -s ../../ci/lengthcheck.sh .git/hooks/pre-commit
 ```
 
 On Windows:
 
 ```powershell
-New-Item -Path .git/hooks/pre-commit -ItemType HardLink -Value <absolute_path/to/check_line_lengths.sh>
+New-Item -Path .git/hooks/pre-commit -ItemType HardLink -Value $(Resolve-Path ci/lengthcheck.sh)
 ```
 
 ## How to fix toolstate failures
diff --git a/src/doc/rustc-dev-guide/ci/check_line_lengths.sh b/src/doc/rustc-dev-guide/ci/lengthcheck.sh
index 31cda5c65e9..76d677be74b 100755
--- a/src/doc/rustc-dev-guide/ci/check_line_lengths.sh
+++ b/src/doc/rustc-dev-guide/ci/lengthcheck.sh
@@ -1,5 +1,7 @@
 #!/usr/bin/env bash
 
+# Check files for lines that are too long.
+
 if [ "$1" == "--help" ]; then
   echo 'Usage:' "[MAX_LINE_LENGTH=n] $0 [file ...]"
   exit 1
@@ -10,8 +12,7 @@ if [ "$MAX_LINE_LENGTH" == "" ]; then
 fi
 
 if [ "$1" == "" ]; then
-  shopt -s globstar
-  files=( src/**/*.md )
+  files=( src/*.md src/*/*.md src/*/*/*.md )
 else
   files=( "$@" )
 fi
@@ -22,7 +23,6 @@ echo "Offending files and lines:"
 (( bad_lines = 0 ))
 (( inside_block = 0 ))
 for file in "${files[@]}"; do
-  echo "$file"
   (( line_no = 0 ))
   while IFS="" read -r line || [[ -n "$line" ]] ; do
     (( line_no++ ))
@@ -34,7 +34,7 @@ for file in "${files[@]}"; do
         && ! [[ "$line" =~ " | "|"-|-"|"://"|"]:"|\[\^[^\ ]+\]: ]] \
         && (( "${#line}" > $MAX_LINE_LENGTH )) ; then
       (( bad_lines++ ))
-      echo -e "\t$line_no : $line"
+      echo -e "\t$file:$line_no : $line"
     fi
   done < "$file"
 done
diff --git a/src/doc/rustc-dev-guide/src/contributing.md b/src/doc/rustc-dev-guide/src/contributing.md
index 549c18cc495..8f4f498b12e 100644
--- a/src/doc/rustc-dev-guide/src/contributing.md
+++ b/src/doc/rustc-dev-guide/src/contributing.md
@@ -311,7 +311,7 @@ There are issues for beginners and advanced compiler devs alike!
 Just a few things to keep in mind:
 
 - Please limit line length to 100 characters. This is enforced by CI, and you can run the checks
-  locally with `ci/check_line_lengths.sh`.
+  locally with `ci/lengthcheck.sh`.
 
 - When contributing text to the guide, please contextualize the information with some time period
   and/or a reason so that the reader knows how much to trust or mistrust the information.