Skip to content

Commit 0afd640

Browse files
Use an extensible how-to and examples section
Per review comments, tidy up the README references to the how-tos and configuration examples, and use a title / format to which more docs can be easily added. In the process, add a preliminary version of an example setup for French. Currently a copy of the extra-dics example/how-to but will become a unique document. Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
1 parent b81a51c commit 0afd640

File tree

2 files changed

+116
-17
lines changed

2 files changed

+116
-17
lines changed

README.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,11 @@ repos:
1313
- id: cspell
1414
```
1515
16-
## Using additional dictionaries
16+
## How-To Guides and Configuration Examples
1717
18-
### Using included dictionaries on non-standard files
19-
20-
For example, using Bash dictionary with Markdown or text files, by filename (the
21-
default is to only apply from within VSCode for files of type `shellscript`).
22-
23-
[Using CSpell overrides](docs/README-OVERRIDES.md)
24-
25-
### Using dictionaries from `cspell-dicts`
26-
27-
For example, using the fr_FR and fr_FR_90 dictionaries when local is `fr`
28-
29-
[Using extra CSpell dictionaries with
30-
`pre-commit`](docs/README-PRE-COMMIT-EXTRA-DICTS.md)
31-
32-
You can of course combine using override with using dictionaries from
33-
`cspell-dicts`.
18+
* [Use Dictionaries from `cspell-dicts`](docs/README-PRE-COMMIT-EXTRA-DICTS.md)
19+
* [Use a Different Dictionary Based Upon the Filename](docs/README-OVERRIDES.md)
20+
* [Example `pre-commit` Setup for French](docs/README-PRE-COMMIT-EXAMPLE-FOR-FRENCH.md)
3421

3522
### Setup Custom Dictionary
3623

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Using extra CSpell dictionaries with `pre-commit`
2+
<!--- cspell:ignore Voici nous avons française reforme --->
3+
4+
## Common configuration
5+
6+
### `pre-commit-config.yaml` configuration
7+
8+
Extend the `pre-commit` hook config from the [README.md](../README.md) with
9+
`additional_dependencies`. For example:
10+
11+
```yaml
12+
# .pre-commit-config.yaml
13+
repos:
14+
- repo: https://github.com/streetsidesoftware/cspell-cli
15+
rev: v6.2.0
16+
hooks:
17+
- id: cspell
18+
additional_dependencies:
19+
- "@cspell/dict-fr-fr"
20+
- "@cspell/dict-fr-reforme"
21+
22+
```
23+
24+
For a complete list of available dictionaries,
25+
see: <https://github.com/streetsidesoftware/cspell-dicts>.
26+
27+
## Using French as the locale
28+
29+
Use a `cspell.json` such as the following:
30+
31+
```json
32+
{
33+
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
34+
"import": [
35+
"@cspell/dict-fr-fr/cspell-ext.json",
36+
"@cspell/dict-fr-reforme/cspell-ext.json"
37+
],
38+
"language": "fr",
39+
"version": "0.2"
40+
}
41+
```
42+
43+
A file such as `test2.md` containing:
44+
45+
```markdown
46+
# Testing french in Markdown
47+
48+
## Les mots
49+
50+
Voici, nous avons les mots française.
51+
```
52+
53+
When `cspell` is invoked `test2.md` should not show errors
54+
55+
## Applying to specific files
56+
57+
And to apply those dictionaries to files with the `.md` extension (Markdown),
58+
use a `cspell.json` such as:
59+
60+
```json
61+
{
62+
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
63+
"import": [
64+
"@cspell/dict-fr-fr/cspell-ext.json",
65+
"@cspell/dict-fr-reforme/cspell-ext.json"
66+
],
67+
"overrides": [
68+
{
69+
"filename": "**/{*.md,*.txt}",
70+
"language": "fr,fr-fr,fr-90"
71+
}
72+
],
73+
"version": "0.2"
74+
}
75+
```
76+
77+
And the following, as `test2.md` and as `test2.err`:
78+
79+
``` markdown
80+
# Testing french in Markdown
81+
82+
## Les mots
83+
84+
Voici, nous avons les mots française
85+
```
86+
87+
When `cspell` is invoked `test2.md` should not show errors, but `test2.err`
88+
should.
89+
90+
## Invoking CSpell
91+
92+
### `pre-commit`
93+
94+
With [pre-commit](https://pre-commit.com) installed:
95+
96+
1. Use a config such as the one above
97+
2. Stage all files (e.g. `git add --all .`)
98+
3. Execute:
99+
100+
``` bash
101+
pre-commit run --all-files
102+
```
103+
104+
OR commit the changes
105+
106+
``` bash
107+
git commit
108+
```
109+
110+
### Command line
111+
112+
`cspell ./test2.*`

0 commit comments

Comments
 (0)