|
13 | 13 | - '!doc/UpdateChangelog.pl' |
14 | 14 | - '.github/workflows/docs-common.yml' |
15 | 15 | # Include all include::ed files outside doc/ directory! |
16 | | - - 'src/README.unit_testing' |
17 | | - - 'tools/README' |
| 16 | + - 'src/README.unit_testing.md' |
| 17 | + - 'tools/README.md' |
18 | 18 | - 'doc/test/test_container_eq_ctsm_pylib.sh' |
19 | 19 |
|
20 | 20 | pull_request: |
|
27 | 27 | - '!doc/UpdateChangelog.pl' |
28 | 28 | - '.github/workflows/docs-common.yml' |
29 | 29 | # Include all include::ed files outside doc/ directory! |
30 | | - - 'src/README.unit_testing' |
31 | | - - 'tools/README' |
| 30 | + - 'src/README.unit_testing.md' |
| 31 | + - 'tools/README.md' |
32 | 32 | - 'doc/test/test_container_eq_ctsm_pylib.sh' |
33 | 33 |
|
34 | 34 | workflow_dispatch: |
@@ -82,3 +82,138 @@ jobs: |
82 | 82 | with: |
83 | 83 | name: test-build-docs-container_failed |
84 | 84 | path: build-logs/ |
| 85 | + |
| 86 | + check-docs-style: |
| 87 | + if: ${{ always() }} |
| 88 | + name: Check documentation against style guide |
| 89 | + runs-on: ubuntu-latest |
| 90 | + steps: |
| 91 | + |
| 92 | + - name: Checkout repository |
| 93 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 94 | + |
| 95 | + - name: Disallow fake degree signs |
| 96 | + if: always() |
| 97 | + # Prevents anyone from using the masculine ordinal indicator, as well as superscript-o/O if |
| 98 | + # preceded by a digit in |
| 99 | + # - Markdown math style, |
| 100 | + # - reStructuredText math style, |
| 101 | + # - MyST text style, and |
| 102 | + # - reStructuredText text style, |
| 103 | + # with or without curly brackets and/or spaces. |
| 104 | + # |
| 105 | + # What follows is an explanation of the regex. Keep in mind that the superscript-o will |
| 106 | + # match whether it's an uppercase O or lowercase o because of the -i flag to grep, so that's |
| 107 | + # not handled in the regex. |
| 108 | + # |
| 109 | + # Markdown math style: |
| 110 | + # Markdown math superscripts look like $^o$. There can also be curly brackets, like |
| 111 | + # $^{o}$, which would allow you to put multiple characters (including spaces) in the |
| 112 | + # superscript. The preceding digit can be inside or outside the dollar signs, again with |
| 113 | + # or without spaces. |
| 114 | + # |
| 115 | + # There are two regex patterns separated by |, to handle the cases where the preceding |
| 116 | + # digit is outside or inside the dollar signs, respectively: |
| 117 | + # [0-9]\s*\\$\s*\^\{?\s*o |
| 118 | + # [0-9] Any digit |
| 119 | + # \s* Any number of spaces, including none |
| 120 | + # \\$ A literal dollar sign |
| 121 | + # \s* Any number of spaces, including none |
| 122 | + # \^ A literal caret |
| 123 | + # \{? Optionally a literal left curly bracket |
| 124 | + # \s* Any number of spaces, including none |
| 125 | + # o Lowercase o |
| 126 | + # \\\$[0-9]+\s*\^\{?\s*o\s*\}? |
| 127 | + # \\\$ A literal dollar sign |
| 128 | + # [0-9]+ One or more digits |
| 129 | + # \s* Any number of spaces, including none |
| 130 | + # \^ A literal caret |
| 131 | + # \{? Optionally a literal left curly bracket |
| 132 | + # \s* Any number of spaces, including none |
| 133 | + # o Lowercase o |
| 134 | + # \s* Any number of spaces, including none |
| 135 | + # \}? Optionally a literal right curly bracket |
| 136 | + # |
| 137 | + # MyST text style: |
| 138 | + # MyST text superscripts look like {sup}`o`. Here's the regex: |
| 139 | + # [0-9]\s*\{sup}\`\s*o\` |
| 140 | + # [0-9] Any digit |
| 141 | + # \s* Any number of spaces, including none |
| 142 | + # \{ A literal left curly bracket |
| 143 | + # sup The text "sup" designating the superscript role |
| 144 | + # \} A literal right curly bracket |
| 145 | + # \` A literal backtick |
| 146 | + # \s* Any number of spaces, including none |
| 147 | + # o Lowercase o |
| 148 | + # \` A literal backtick |
| 149 | + # |
| 150 | + # reStructuredText text style |
| 151 | + # Similar to MyST text superscripts, but with colons instead of curly brackets: :sup:`o`. |
| 152 | + # Another difference is that spaces aren't allowed inside the backticks. Also, there has |
| 153 | + # to be a space preceding the first colon; this can be preceded by a backslash to avoid |
| 154 | + # putting an extraneous space in the rendered text. Here's the regex: |
| 155 | + # [0-9]\\\? :sup:\`o\` |
| 156 | + # [0-9] Any digit |
| 157 | + # \\\? Optionally a literal backslash |
| 158 | + # (A literal space) |
| 159 | + # :sup: The text ":sup:" designating the superscript role |
| 160 | + # \` A literal backtick |
| 161 | + # o Lowercase o |
| 162 | + # \` A literal backtick |
| 163 | + # |
| 164 | + # reStructuredText math style |
| 165 | + # Mostly the same as reStructuredText text superscripts, but with :math: instead of |
| 166 | + # :sup:. In addition, the superscript can optionally be in curly brackets. There can be |
| 167 | + # a space after the first backtick but not before the last one. |
| 168 | + # |
| 169 | + # There are two regex patterns separated by |, to handle the cases where the preceding |
| 170 | + # digit is outside or inside the dollar signs, respectively: |
| 171 | + # [0-9]\\\? :math:\`\s*\^\{?\s*o\s*\}?\` |
| 172 | + # [0-9] Any digit |
| 173 | + # \\\? Optionally a literal backslash |
| 174 | + # (A literal space) |
| 175 | + # :math: The text ":math:" designating the math role |
| 176 | + # \` A literal backtick |
| 177 | + # \s* Any number of spaces, including none |
| 178 | + # \^ A literal caret |
| 179 | + # \{? Optionally a literal left curly bracket |
| 180 | + # \s* Any number of spaces, including none |
| 181 | + # o Lowercase o |
| 182 | + # \s* Any number of spaces, including none |
| 183 | + # \}? Optionally a literal right curly bracket |
| 184 | + # \` A literal backtick |
| 185 | + # :math:\`\s*[0-9]+\s*\^\{?\s*o\s*\}?\` |
| 186 | + # :math: The text ":math:" designating the math role |
| 187 | + # \` A literal backtick |
| 188 | + # \s* Any number of spaces, including none |
| 189 | + # [0-9]+ One or more digits |
| 190 | + # \s* Any number of spaces, including none |
| 191 | + # \^ A literal caret |
| 192 | + # \{? Optionally a literal left curly bracket |
| 193 | + # \s* Any number of spaces, including none |
| 194 | + # o Lowercase o |
| 195 | + # \s* Any number of spaces, including none |
| 196 | + # \}? Optionally a literal right curly bracket |
| 197 | + # \` A literal backtick |
| 198 | + run: | |
| 199 | + set +e |
| 200 | + instances_of_fake_degree_signs="$(grep -ionE "[0-9]\s*\\$\s*\^\{?\s*o|\\\$[0-9]+\s*\^\{?\s*o\s*\}?|[0-9]\s*\{sup}\`\s*o\`|[0-9]\\\? :sup:\`o\`|[0-9]\\\? :math:\`\s*\^\{?\s*o\s*\}?\`| :math:\`\s*[0-9]+\s*\^\{?\s*o\s*\}?\`|º" $(find doc -name "*.md" -or -name "*.rst"))" |
| 201 | + set -e |
| 202 | + if [[ "$instances_of_fake_degree_signs" ]] then |
| 203 | + echo -e "Instances of superscript-o or masculine ordinal indicator (º) instead of degree sign (°):\n${instances_of_fake_degree_signs}" |
| 204 | + echo -e "\nSee https://escomp.github.io/CTSM/users_guide/working-with-documentation/docs-style-guide.html" |
| 205 | + exit 1 |
| 206 | + fi |
| 207 | + exit 0 |
| 208 | +
|
| 209 | + - name: Disallow curly apostrophes/quotes |
| 210 | + if: always() |
| 211 | + run: | |
| 212 | + set +e |
| 213 | + instances_of_curlies="$(grep -onE "“|”|‘|’" $(find doc -name "*.md" -or -name "*.rst"))" |
| 214 | + set -e |
| 215 | + if [[ "$instances_of_curlies" ]] then |
| 216 | + echo -e "Instances of curly apostrophes and/or quote marks:\n${instances_of_curlies}" |
| 217 | + exit 1 |
| 218 | + fi |
| 219 | + exit 0 |
0 commit comments