opensafely / documentation

Documentation for the OpenSAFELY platform
https://docs.opensafely.org
Other
32 stars 4 forks source link

Introduce automated documentation linting #643

Open StevenMaude opened 2 years ago

StevenMaude commented 2 years ago

Goal :checkered_flag:

Improve consistency across the documentation for both readers and writers. Or at least highlight the inconsistencies.

This suggestion is prompted:

Tooling :hammer:

There are several linting tools out there. But, Vale allows you to apply different style rules or guides taken from various different linters. You can also write your own rules in YAML.

Vale aside: there are lots of other potential tools around. But Vale is mentioned a lot.

How do other people work? :eyes:

For example, GitLab's technical writers use:

  • Text content and writing style: markdownlint, Vale
  • Text formatting: Markdownlint, yamllint
  • Link validity: nanoc
  • File permissions and naming: lint-doc.sh

I'm more interested in the stages, than the specific tools chosen by the GitLab team. We don't have any of these right now. I also opened #642 for link checking as I believe that's a self-contained problem.

Note that tools like markdownlint are actually focused on markup consistency, not content consistency. This might be another benefit. We — understandably — have a mixture of Markdown styles across our documentation due to different author contributions.

Considerations :thought_balloon:

ghickman commented 2 years ago

I've been using codespell on a personal project, unlike a spell checker it catches common misspellings. I've given it a quick go with ehr and ons ignored (lots of false positives!) it gives us output like this:

In my own project I'm running it as a pre-commit hook, but it could easily be a CI step too.

I've found it useful since my project has lots of non-dictionary words so standard spell checking is far too noisy.

StevenMaude commented 1 year ago

I ran codespell against the current docs and did fix some things as a result, so I'm for adding that in this repository too sometime.

That's a nice simpler intermediate step over adding a full spellcheck.

It may be worth considering using the GitHub Action, because of the nice annotations; example: codespell-project/actions-codespell#16.

StevenMaude commented 1 year ago

Markdown linting tools

Features

I think both markdownlint packages have the same rules available, so we'd probably be leaning towards one of the Node packages over Ruby. Remark does have some rules that are only available there.

Any of these tools gives you a rule set [^1] to enable or disable to configure your own style. Rules are a mixture of very debatable suggestions (for example, list bullet style) and suggestions that likely make universal sense and are mistakes by the writer (for example, heading levels shouldn't be skipped; brackets should come before parentheses in link syntax). You can also ignore warnings for false positives.

There is a little bit of overlap of some of these rules and some of what Vale does. For example, you can check capitalisation of proper nouns with the Node-based markdownlint, which you can also do with Vale. I think the preference would be to keep the Markdown linter's scope to specifically checking the Markdown.

Process of trialling

Enabling one of these tools is probably a process of:

We'd probably want to warn first, and see how useful the checks are, before enforcing.

Questions

Benefits

[^1]: Rule sets:

StevenMaude commented 11 months ago

Here are some ideas for suggestions we could provide with Vale.