silverstripe / documentation-lint
An abstraction around various documentation linters to make linting documentation easy for commercially supported Silverstripe CMS modules.
Installs: 25 690
Dependents: 8
Suggesters: 0
Security: 0
Stars: 1
Watchers: 7
Forks: 1
Open Issues: 0
Language:Shell
Requires
README
An abstraction around various documentation linters to make linting markdown documentation easy.
Warning
This repository is intended for use by commercially supported Silverstripe CMS modules. Its linting rules are opinionated and may include rules which are specific to the documentation style and syntax used by those modules.
Installation
Add this package as a dev dependency
composer require --dev silverstripe/documentation-lint
You'll also need to allow the dealerdirect/phpcodesniffer-composer-installer
plugin in the repository (this won't affect downstream users) so that the slevomat PHP linting rules are pulled in correctly.
{ // ... "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true } } }
Setup
Required software
You need nvm
(or node
installed with the right version - see .nvmrc
) and yarn
installed.
Warning
If you're using a shell other than bash (e.g. zsh) you'll need to set your node version before running the linting script, since your nvm
installation is probably not set up in a way that it can be used in bash.
You also need getopt
(enhanced) installed - which you probably do but the script will let you know if you don't.
Setup in the repository
You must add a .doclintrc
file to the root of the repository which has markdown documentation you want linted. This file must contain a relative path to the directory which holds your documentation, and that path must end with a /
.
For example:
docs/en/
Warning
Only the first line of the file will be used.
Usage
Simply run the command. By default it will assume you're running it from the directory that holds the .doclintrc
file and that you want to lint markdown, php, and javascript within .md
files.
vendor/bin/doclint
To lint for a specific module (e.g. if you have multiple modules installed) you can pass the relative path to the folder containing the .doclintrc
file.
vendor/bin/doclint vendor/silverstripe/developer-docs
If you want to specifically only lint one of markdown syntax, PHP codeblocks, or JavaScript codeblocks, use the appropriate flag(s).
vendor/bin/doclint -jp
# or
vendor/bin/doclint --with-js --with-php
To automatically fix any problems that can be automatically fixed, pass the --fix
flag.
vendor/bin/doclint -f
# or
vendor/bin/doclint --fix
Flags
The following flags can be used with the doclint
script:
If any language flag is passed, only the languages that are passed will be linted (or fixed if --fix
is passed). If no language flags are passed, all languages will be linted.