Skip to content

Commit

Permalink
Automatically check for typos with crate-ci/typos
Browse files Browse the repository at this point in the history
  • Loading branch information
bash committed Jan 15, 2025
1 parent 2038bfc commit 5c2adad
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/spelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Spelling

permissions:
contents: read

on: [pull_request]

env:
CLICOLOR: 1

jobs:
spelling:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Spell Check Repo
uses: crate-ci/[email protected]
8 changes: 8 additions & 0 deletions Documentation/src/case-studies/calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,16 @@ Why does that help us with the layout? To create the first line of our final lay

One of these chunks now looks like this:

<!-- spellchecker:off -->

```
Januar | 1 2 3 4 5 | 6 7 8 9 10 11 12 | 13 14 15 16 17 18 19 | 20 21 22 23 24 25 26 | 27 28 29 30 31 |
Februar | 1 2 | 3 4 5 6 7 8 9 | 10 11 12 13 14 15 16 | 17 18 19 20 21 22 23 | 24 25 26 27 28 29 |
März | 1 | 2 3 4 5 6 7 8 | 9 10 11 12 13 14 15 | 16 17 18 19 20 21 22 | 23 24 25 26 27 28 29 | 30 31 |
```

<!-- spellchecker:on -->

That actually already looks a lot like what we want, but we want the months on the top not on the left.

It also looks like a matrix, and on a matrix the operation to flip the rows and the columns (on a diagonal symmetry) is called transpose.
Expand All @@ -322,6 +326,8 @@ private static string CreateCalendarString(int year)

After this transforamtion our chunk of 3 months looks like this:

<!-- spellchecker:off -->

```
Januar | Februar | März
1 2 3 4 5 | 1 2 | 1
Expand All @@ -332,6 +338,8 @@ After this transforamtion our chunk of 3 months looks like this:
| | 30 31
```

<!-- spellchecker:on -->

I think it is obvious that at this point, we are done. We just have to join the chunks together to have our final output.

```cs
Expand Down
4 changes: 2 additions & 2 deletions Funcky.Test/Extensions/ParseExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public static TheoryData<Option<bool>, string> BooleanStrings()
{ Option<bool>.None, string.Empty },
{ Option.Some(true), "true" },
{ Option.Some(false), "false" },
{ Option.Some(true), "TrUe" },
{ Option.Some(false), "FalsE" },
{ Option.Some(true), "TrUe" }, // spellchecker:disable-line
{ Option.Some(false), "FalsE" }, // spellchecker:disable-line
{ Option<bool>.None, "0" },
{ Option<bool>.None, "1" },
{ Option<bool>.None, "T" },
Expand Down
2 changes: 1 addition & 1 deletion Funcky.Test/FunctionalClass/UncurryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Funcky.Test.FunctionalClass;
public sealed class UncurryTest
{
[Property]
public Property GivenA2NdLevelCurriedFunctionWeGetAFunctionWith2Parameters(int number, string text)
public Property GivenASecondLevelCurriedFunctionWeGetAFunctionWith2Parameters(int number, string text)
{
Func<int, Func<string, string>> f = number => text => $"number:{number}, text:{text}";

Expand Down
1 change: 1 addition & 0 deletions Funcky.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build Config", "Build Confi
GlobalUsings.props = GlobalUsings.props
GlobalUsings.Test.props = GlobalUsings.Test.props
NuGet.config = NuGet.config
typos.toml = typos.toml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Funcky.Xunit", "Funcky.Xunit\Funcky.Xunit.csproj", "{F2E98B0D-CC17-4576-89DE-065FF475BE6E}"
Expand Down
12 changes: 12 additions & 0 deletions typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[files]
extend-exclude = ["*.DotSettings"]

[default]
extend-ignore-re = [
# Ignore the signature block in the `install.ps1` script
"(?s)(#|//)\\s*SIG # Begin signature block.*?\\n\\s*(#|//)\\s*SIG # End signature block",
# Line ignore with trailing `# spellchecker:disable-line`
"(?Rm)^.*(#|//)\\s*spellchecker:disable-line$",
# Line block with `# spellchecker:<on|off>`
"(?s)(<!--|#|//)\\s*spellchecker:off.*?\\n\\s*(<!--|#|//)\\s*spellchecker:on",
]

0 comments on commit 5c2adad

Please sign in to comment.