Skip to content

Commit da40ea6

Browse files
authored
Merge pull request #10603 from cabalism/add/typo-checking-10601
Add typo checking for *.rst and *.md files
2 parents 411fcfa + 6d8f0f3 commit da40ea6

15 files changed

+113
-33
lines changed

.github/workflows/typos.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Typos
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: ["master"]
7+
8+
env:
9+
TYPOS_VER: v1.28.1
10+
TYPOS_PLATFORM: x86_64-unknown-linux-musl
11+
12+
jobs:
13+
typos:
14+
defaults:
15+
run:
16+
shell: bash
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
21+
- uses: actions/checkout@v4
22+
23+
- run: |
24+
wget -q https://github.com/crate-ci/typos/releases/download/${{ env.TYPOS_VER }}/typos-${{ env.TYPOS_VER }}-${{ env.TYPOS_PLATFORM }}.tar.gz
25+
tar -xf typos-${{ env.TYPOS_VER }}-${{ env.TYPOS_PLATFORM }}.tar.gz --one-top-level=typos-${{ env.TYPOS_VER }}
26+
mkdir -p "$HOME/.local/bin"
27+
mv typos-${{ env.TYPOS_VER }} "$HOME/.local/bin/typos-${{ env.TYPOS_VER }}"
28+
chmod +x "$HOME/.local/bin/typos-${{ env.TYPOS_VER }}/typos"
29+
echo "$HOME/.local/bin/typos-${{ env.TYPOS_VER }}" >> $GITHUB_PATH
30+
31+
- run: make users-guide-typos
32+
- run: make markdown-typos

.typos.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[default]
2+
extend-ignore-re = ["(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on"]

Cabal/ChangeLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@
773773
* Many checks added for common mistakes
774774
* New `--package-db=` option for specific package databases
775775
* Many internal changes to support cabal-install
776-
* Stricter parsing for version strings, eg dissalows "1.05"
776+
* Stricter parsing for version strings, eg disallows "1.05"
777777
* Improved user guide introduction
778778
* Programatica support removed
779779
* New options `--program-prefix/suffix` allows eg versioned programs

Makefile

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ lint-json: ## Run HLint in JSON mode
6060
# local checks
6161

6262
.PHONY: checks
63-
checks: whitespace style lint-json
63+
checks: whitespace users-guide-typos markdown-typos style lint-json
6464

6565
# source generation: SPDX
6666

@@ -268,3 +268,26 @@ PROCS := $(shell sysctl -n hw.logicalcpu)
268268
else
269269
PROCS := $(shell nproc)
270270
endif
271+
272+
.PHONY: typos-install
273+
typos-install: ## Install typos-cli for typos target using cargo
274+
cargo install typos-cli
275+
276+
GREP_EXCLUDE := grep -v -E 'dist-|cabal-testsuite|python-'
277+
FIND_NAMED := find . -type f -name
278+
279+
.PHONY: users-guide-typos
280+
users-guide-typos: ## Find typos in users guide
281+
cd doc && $(FIND_NAMED) '*.rst' | xargs typos
282+
283+
.PHONY: users-guide-fix-typos
284+
users-guide-fix-typos: ## Fix typos in users guide
285+
cd doc && $(FIND_NAMED) '*.rst' | xargs typos --write-changes
286+
287+
.PHONY: markdown-typos
288+
markdown-typos: ## Find typos in markdown files
289+
$(FIND_NAMED) '*.md' | $(GREP_EXCLUDE) | xargs typos
290+
291+
.PHONY: markdown-fix-typos
292+
markdown-fix-typos: ## Fix typos in markdown files
293+
$(FIND_NAMED) '*.md' | $(GREP_EXCLUDE) | xargs typos --write-changes

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Currently, we only provide binaries for `x86_64` platforms.
6464
6565
6666
2. Even more cutting-edge binaries built from pull requests are always available
67-
from the `Validate` worklow page on GitHub, at the very bottom of the page,
67+
from the `Validate` workflow page on GitHub, at the very bottom of the page,
6868
or from the `build-alpine` workflow for statically linked Linux builds.
6969
7070
Ways to build `cabal-install` for everyday use

doc/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,29 @@ either from the root of the cabal repository or from the `docs/` subdirectory. Y
4040

4141
In some cases, you may have to add a bound manually to `requirements.in`, e.g. `requests >= 2.31.0`.
4242

43+
### How to check spelling
44+
45+
To check for typos, run `make typos` and to fix them, run `make fix-typos`. Fixing might fail.
46+
47+
> If there is any ambiguity (multiple possible corrections),
48+
> `typos` will just report it to the user and move on.
49+
>
50+
> SOURCE: [typos/Getting Started](https://github.com/crate-ci/typos#getting-started)
51+
52+
```
53+
# spellchecker:off
54+
$ make users-guide-typos
55+
cd doc && find . -type f -name '*.rst' | xargs typos
56+
error: `managable` should be `manageable`, `manageably`
57+
--> doc/getting-started.rst:75:6
58+
|
59+
75 | more managable building blocks.
60+
| ^^^^^^^^^
61+
|
62+
make: *** [Makefile: users-guide-typos] Error 2
63+
# spellchecker:on
64+
```
65+
4366
### Gitpod workflow
4467

4568
From a fork of cabal, these docs can be edited online with

doc/cabal-commands.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ cabal list
395395
cabal info
396396
^^^^^^^^^^
397397

398-
``cabal info [FLAGS] PACKAGES`` displays useful informations about remote
398+
``cabal info [FLAGS] PACKAGES`` displays useful information about remote
399399
packages.
400400

401401
.. option:: --package-db=DB
@@ -468,7 +468,7 @@ the source code of ``PACKAGES`` locally. By default the content of the
468468
packages is unpacked in the current working directory, in named subfolders
469469
(e.g. ``./filepath-1.2.0.8/``), use ``--destdir=PATH`` to specify another
470470
folder. By default the latest version of the package is downloaded, you can
471-
ask for a spefic one by adding version numbers
471+
ask for a specific one by adding version numbers
472472
(``cabal get random-1.0.0.1``).
473473

474474
The ``cabal get`` command supports the following options:
@@ -1384,7 +1384,7 @@ A list of all warnings with their constructor:
13841384
- ``no-autogen-paths``: missing autogen ``Paths_*`` modules in ``autogen-modules`` (``cabal-version`` ≥ 2.0).
13851385
- ``no-autogen-pinfo``: missing autogen ``PackageInfo_*`` modules in ``autogen-modules`` *and* ``exposed-modules``/``other-modules`` (``cabal-version`` ≥ 2.0).
13861386
- ``no-glob-match``: glob pattern not matching any file.
1387-
- ``glob-no-extension``: glob pattern not matching any file becuase of lack of extension matching (`cabal-version` < 2.4).
1387+
- ``glob-no-extension``: glob pattern not matching any file because of lack of extension matching (`cabal-version` < 2.4).
13881388
- ``glob-missing-dir``: glob pattern trying to match a missing directory.
13891389
- ``unknown-os``: unknown operating system name in condition.
13901390
- ``unknown-arch``: unknown architecture in condition.

doc/cabal-package-description-file.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,14 +1114,14 @@ the :pkg-field:`test-module` field.
11141114
An optional list of preprocessors which can generate new modules
11151115
for use in the test-suite.
11161116

1117-
A list of executabes (possibly brought into scope by
1117+
A list of executables (possibly brought into scope by
11181118
:pkg-field:`build-tool-depends`) that are run after all other
11191119
preprocessors. These executables are invoked as so: ``exe-name
11201120
TARGETDIR [SOURCEDIRS] -- [GHCOPTIONS]``. The arguments are, in order a target dir for
11211121
output, a sequence of all source directories with source files of
11221122
local lib components that the given test stanza depends on, and
11231123
following a double dash, all options cabal would pass to ghc for a
1124-
build. They are expected to output a newline-seperated list of
1124+
build. They are expected to output a newline-separated list of
11251125
generated modules which have been written to the targetdir
11261126
(excepting, if written, the main module). This can
11271127
be used for driving doctests and other discover-style tests generated
@@ -3090,8 +3090,8 @@ The auto generated :file:`PackageInfo_{pkgname}` module exports the constant
30903090
which is defined as the version of your package as specified in the
30913091
``version`` field.
30923092

3093-
Accessing package-related informations
3094-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3093+
Accessing package-related information
3094+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30953095

30963096
The auto generated :file:`PackageInfo_{pkgname}` module exports the following
30973097
package-related constants:

doc/file-format-changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ relative to the respective preceding *published* version.
3939
----------------------
4040

4141
* Added field ``code-generators`` to :pkg-section:`test-suite` stanzas. This
42-
enumerates executabes (possibly brought into scope by :pkg-field:`build-tool-depends`) that are run after all other
42+
enumerates executables (possibly brought into scope by :pkg-field:`build-tool-depends`) that are run after all other
4343
preprocessors. These executables are invoked with a target dir for
4444
output, a sequence of all source directories with source files of
4545
local lib components that the given test stanza depends on, and

doc/getting-started.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The ``myapp.cabal`` file is a package description file, commonly referred to as
7272
7373
It contains metadata (package name and version, author name, license, etc.) and sections
7474
to define package components. Components can be used to split large codebases into smaller,
75-
more managable building blocks.
75+
more manageable building blocks.
7676
A component can be of one of several types (executable, library, etc.) and describes,
7777
among other things, the location of source files and its dependencies.
7878
The ``myapp.cabal`` file above defines a single component named ``myapp`` of the executable type.

0 commit comments

Comments
 (0)