Skip to content

Commit da40ea6

Browse files
authoredDec 2, 2024··
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

+32
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

+2
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

+1-1
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

+24-1
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

+1-1
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

+23
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

+3-3
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

+4-4
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

+1-1
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

+1-1
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.

‎doc/how-to-use-backpack.rst

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ are somewhat experimental; while fully supported by cabal-install, they are curr
1616

1717
A Backpack package is defined by use of the
1818
:pkg-field:`library:signatures` field, or by (transitive) dependency on
19-
a package that defines some requirements. To define a parametrized
19+
a package that defines some requirements. To define a parameterized
2020
package, define a signature file (file extension ``hsig``) that
2121
specifies the signature of the module you want to parametrize over, and
2222
add it to your Cabal file in the :pkg-field:`library:signatures` field.
@@ -31,10 +31,10 @@ add it to your Cabal file in the :pkg-field:`library:signatures` field.
3131
concat :: [Str] -> Str
3232
3333
.. code-block:: cabal
34-
:caption: parametrized.cabal
34+
:caption: parameterized.cabal
3535
3636
cabal-version: 2.2
37-
name: parametrized
37+
name: parameterized
3838
3939
library
4040
build-depends: base
@@ -45,14 +45,14 @@ You can define any number of regular modules (e.g., ``MyModule``) that
4545
import signatures and use them as regular modules.
4646

4747
If you are familiar with ML modules, you might now expect there to be
48-
some way to apply the parametrized package with an implementation of
48+
some way to apply the parameterized package with an implementation of
4949
the ``Str`` module to get a concrete instantiation of the package.
5050
Backpack operates slightly differently with a concept of *mix-in
5151
linking*, where you provide an implementation of ``Str`` simply by
5252
bringing another module into scope with the same name as the
5353
requirement. For example, if you had a package ``str-impl`` that provided a
54-
module named ``Str``, instantiating ``parametrized`` is as simple as
55-
just depending on both ``str-impl`` and ``parametrized``:
54+
module named ``Str``, instantiating ``parameterized`` is as simple as
55+
just depending on both ``str-impl`` and ``parameterized``:
5656

5757
.. code-block:: cabal
5858
:caption: combined.cabal
@@ -61,7 +61,7 @@ just depending on both ``str-impl`` and ``parametrized``:
6161
name: combined
6262
6363
library
64-
build-depends: base, str-impl, parametrized
64+
build-depends: base, str-impl, parameterized
6565
6666
Note that due to technical limitations, you cannot directly define
6767
``Str`` in the ``combined`` library; it must be placed in its own
@@ -75,7 +75,7 @@ a requirement ``Str`` and an implementation ``Data.Text``, you can
7575
line up the names in one of two ways:
7676

7777
* Rename the requirement to match the implementation:
78-
``mixins: parametrized requires (Str as Data.Text)``
78+
``mixins: parameterized requires (Str as Data.Text)``
7979
* Rename the implementation to match the requirement:
8080
``mixins: text (Data.Text as Str)``
8181

@@ -91,13 +91,13 @@ the requirements and provided modules renamed to be distinct.
9191
name: double-combined
9292
9393
library
94-
build-depends: base, text, bytestring, parametrized
94+
build-depends: base, text, bytestring, parameterized
9595
mixins:
96-
parametrized (MyModule as MyModule.Text) requires (Str as Data.Text),
97-
parametrized (MyModule as MyModule.BS) requires (Str as Data.ByteString)
96+
parameterized (MyModule as MyModule.Text) requires (Str as Data.Text),
97+
parameterized (MyModule as MyModule.BS) requires (Str as Data.ByteString)
9898
9999
Intensive use of Backpack sometimes involves creating lots of small
100-
parametrized libraries; :ref:`Sublibraries <sublibs>` can be used
100+
parameterized libraries; :ref:`Sublibraries <sublibs>` can be used
101101
to define all of these libraries in a single package without having to
102102
create many separate Cabal packages. You may also find it useful to use
103103
:pkg-field:`library:reexported-modules` to reexport instantiated

‎release-notes/Cabal-3.10.1.0.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ are listed here.
4646

4747
- Add `PackageInfo_` module [#8534](https://github.com/haskell/cabal/pull/8534)
4848

49-
- Add `PackageInfo_` module to embed portable package-related informations (issue #3909)
49+
- Add `PackageInfo_` module to embed portable package-related information (issue #3909)
5050

5151
- *Cabal-syntax* Add language extensions `DeepSubsumption` and `TypeData` [#8493](https://github.com/haskell/cabal/pull/8493)
5252

‎release-notes/Cabal-3.12.0.0.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ Cabal and Cabal-syntax 3.12.0.0 changelog and release notes
3636
package *without* having previously built the dependency. Instead, we
3737
promise to the configure phase that we will have built it by the time we
3838
build the package. This allows us to configure all the packages we intend
39-
to load into the repl without building any dependenices which we will load
40-
in the same session, because the promise is satisifed due to loading the
39+
to load into the repl without building any dependencies which we will load
40+
in the same session, because the promise is satisfied due to loading the
4141
package and its dependency into one multi-session which ensures the
4242
dependency is built before it is needed.
4343

@@ -67,7 +67,7 @@ Cabal and Cabal-syntax 3.12.0.0 changelog and release notes
6767
prone, as `initialBuildSteps` only handles things like the paths module
6868
and nothing else.
6969
70-
To mimick `initialBuildSteps` behaviour when there is no custom Setup, you
70+
To mimic `initialBuildSteps` behaviour when there is no custom Setup, you
7171
can call `repl_setupHooks`.
7272
7373
If you are dealing with a custom setup, you have to invoke
@@ -144,7 +144,7 @@ Cabal and Cabal-syntax 3.12.0.0 changelog and release notes
144144
large file can reduce overall compile times.
145145
2. Breaking up the module allows dependent modules to refine their imports
146146
to just the parts they require, allowing them to start buildling quicker
147-
when GHC is run in parrallel make mode ('--ghc-options -j').
147+
when GHC is run in parallel make mode ('--ghc-options -j').
148148
149149
- Reimplementing `cabal check` [#7423](https://github.com/haskell/cabal/issues/7423) [#8427](https://github.com/haskell/cabal/pull/8427)
150150
@@ -166,7 +166,7 @@ Cabal and Cabal-syntax 3.12.0.0 changelog and release notes
166166
167167
The `./Setup repl` command is modified to allow a user to defer starting
168168
the repl and instead instruct the command to write the necessary build
169-
flags to a directiory. The option is called `--repl-multi-file <DIR>`.
169+
flags to a directory. The option is called `--repl-multi-file <DIR>`.
170170
171171
This is useful when starting multi-component sessions, as we want to query
172172
Setup.hs for the arguments which are needed to build each component but
@@ -264,7 +264,7 @@ Cabal and Cabal-syntax 3.12.0.0 changelog and release notes
264264
That behavior is desirable to parsing multiline field contents, but it is
265265
a bit surprising for fields in sections, which we expect to be aligned.
266266
267-
Such insonsistency seems to be always a mistake, and it's easy to fix once
267+
Such inconsistency seems to be always a mistake, and it's easy to fix once
268268
a machine points it out.
269269
270270
- Add `LexBraces` lexer warning [#8577](https://github.com/haskell/cabal/issues/8577)

‎release-notes/cabal-install-3.10.3.0.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cabal-install and cabal-install-solver 3.10.3.0 changelog and release notes
3333

3434
Previously, cabal-install would crash when `pkg-config --list-all` contained
3535
invalid Unicode. With this change, invalid unicode in package descriptions is
36-
ignored, and unparseable package names are considered nonexistent.
36+
ignored, and unparsable package names are considered nonexistent.
3737

3838
- Script cache dir is the base16 hash of the canonical path of the script. [#9459](https://github.com/haskell/cabal/pull/9459)
3939

‎release-notes/cabal-install-3.12.1.0.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ cabal-install 3.12.1.0 changelog and release notes.
140140

141141
In particular this means that cabal-install will create a semaphore which it then
142142
passes to `./Setup build` (and hence `ghc`) which can be used by `ghc` in order to
143-
control how much paralellism it uses, coordinating with other simultaneously running
143+
control how much parallelism it uses, coordinating with other simultaneously running
144144
processes.
145145

146146
This feature requires ghc-9.8 in order to use, as this is the first version of GHC

0 commit comments

Comments
 (0)
Please sign in to comment.