|
1 | 1 | ======== |
2 | | -linklint |
| 2 | +Linklint |
3 | 3 | ======== |
4 | 4 |
|
5 | | -Linklint checks .rst files for inappropriate links. |
| 5 | +Linklint checks .rst files for excessive links to references. |
6 | 6 |
|
7 | 7 | It also can be used as a Sphinx extension to automatically unlink references |
8 | 8 | that should not be links. |
9 | 9 |
|
10 | 10 |
|
| 11 | +Checks |
| 12 | +====== |
| 13 | + |
| 14 | +Linklint has two different checks: |
| 15 | + |
| 16 | +- ``self``: find references that link to their own section. For example, in the |
| 17 | + description of a class, use `:class:` referring to itself. These should not |
| 18 | + be links since they will not take you someplace new. |
| 19 | + |
| 20 | +- ``paradup``: find multiple identical references within a single paragraph. |
| 21 | + The first should be a link, but subsequent references don't need to be links, |
| 22 | + they are just distractions. |
| 23 | + |
| 24 | + |
| 25 | +Sphinx extension |
| 26 | +================ |
| 27 | + |
| 28 | +To use linklint as a Sphinx extension, add it to the ``extensions`` list in |
| 29 | +your ``conf.py`` file: |
| 30 | + |
| 31 | +.. code:: python |
| 32 | +
|
| 33 | + extensions = [ |
| 34 | + # .. probably other extensions are already here.. |
| 35 | + "linklint.ext", |
| 36 | + ] |
| 37 | +
|
| 38 | +During the build process, linklint will run all its checks and unlink any |
| 39 | +reference it considers excessive. |
| 40 | + |
| 41 | + |
| 42 | +Command-line use |
| 43 | +================ |
| 44 | + |
| 45 | +You can use linklint as a command-line linter:: |
| 46 | + |
| 47 | + % linklint --help |
| 48 | + usage: linklint [-h] [--check CHECK] [--fix] files [files ...] |
| 49 | + |
| 50 | + positional arguments: |
| 51 | + files RST files to lint |
| 52 | + |
| 53 | + options: |
| 54 | + -h, --help show this help message and exit |
| 55 | + --check CHECK comma-separated checks to run (self, paradup, all) |
| 56 | + --fix Fix the issues in place |
| 57 | + |
| 58 | +This can be useful to see what linklint considers excessive, or to modify .rst |
| 59 | +files to unlink excessive references. Linklint unlinks references by changing |
| 60 | +``:func:`foo``` to ``:func:`!foo```. |
| 61 | + |
| 62 | +If you agree with linklint's decisions, the Sphinx extension is a better |
| 63 | +option, since it doesn't require changing the source files, and doesn't |
| 64 | +hard-code the decisions. |
| 65 | + |
| 66 | + |
11 | 67 | Changes |
12 | 68 | ======= |
13 | 69 |
|
14 | | -0.3.0 – 2026-02-28 |
15 | | ------------------- |
| 70 | +v0.3.0 (2026-02-28) |
| 71 | +------------------- |
16 | 72 |
|
17 | 73 | Methods are associated with classes properly in a number of ways. |
18 | 74 |
|
19 | 75 | The Sphinx extension now displays the number of references that were unlinked. |
20 | 76 | The CPython docs report 3612 references unlinked. |
21 | 77 |
|
22 | | -0.2.0 – 2026-02-22 |
23 | | ------------------- |
| 78 | +v0.2.0 (2026-02-22) |
| 79 | +------------------- |
24 | 80 |
|
25 | 81 | Now available as a Sphinx extension. Instead of changing .rst source files, |
26 | 82 | the excessive links are automatically unlinked in the generated documentation. |
27 | 83 |
|
28 | | -0.1.0 – 2026-02-21 |
29 | | ------------------- |
| 84 | +v0.1.0 (2026-02-21) |
| 85 | +------------------- |
30 | 86 |
|
31 | 87 | First version: works as a linter with ``--check`` and ``--fix`` to change .rst |
32 | 88 | source files. |
0 commit comments