Skip to content

Commit 13d8760

Browse files
committed
Publish generated list of rules on documentation website
This will provide a convenient reference for information about the rules Arduino Lint applies to projects. - More verbose description of the rule than would be appropriate for the command line output. - Link to the reference information that will allow the reader to fully understand the cause of the rule violation and how to fix it. - Table showing the rule violation level (i.e., error/warning/disabled) vs. common tool configuration. I added a bespoke "Rules > Introduction" page to give some general information about the rule system. , but the "Sketch", "Library", "Platform", and "Package index" pages are all auto-generated from the Arduino Lint source code and will be automatically updated any time rules are added or modified without any additional effort. The rule documentation content is generated by the "ruledocsgen" Go program, which is a separate module, located in its own subfolder of the repository, similar to the standardized "docsgen" program that generates the command line reference.
1 parent 8aca928 commit 13d8760

21 files changed

+2553
-2
lines changed

Diff for: .github/workflows/check-go-task.yml

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
module:
6363
- path: ./
6464
- path: docsgen
65+
- path: ruledocsgen
6566

6667
steps:
6768
- name: Checkout repository
@@ -96,6 +97,7 @@ jobs:
9697
module:
9798
- path: ./
9899
- path: docsgen
100+
- path: ruledocsgen
99101

100102
steps:
101103
- name: Checkout repository
@@ -133,6 +135,7 @@ jobs:
133135
module:
134136
- path: ./
135137
- path: docsgen
138+
- path: ruledocsgen
136139

137140
steps:
138141
- name: Checkout repository
@@ -170,6 +173,7 @@ jobs:
170173
module:
171174
- path: ./
172175
- path: docsgen
176+
- path: ruledocsgen
173177

174178
steps:
175179
- name: Checkout repository
@@ -207,6 +211,7 @@ jobs:
207211
module:
208212
- path: ./
209213
- path: docsgen
214+
- path: ruledocsgen
210215

211216
steps:
212217
- name: Checkout repository

Diff for: .github/workflows/check-mkdocs-task.yml

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ on:
1818
- "pyproject.toml"
1919
- "docs/**"
2020
- "docsgen/**"
21+
- "ruledocsgen/**"
2122
- "**.go"
2223
pull_request:
2324
paths:
@@ -28,6 +29,7 @@ on:
2829
- "pyproject.toml"
2930
- "docs/**"
3031
- "docsgen/**"
32+
- "ruledocsgen/**"
3133
- "**.go"
3234
workflow_dispatch:
3335
repository_dispatch:

Diff for: .github/workflows/deploy-cobra-mkdocs-versioned-poetry.yml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ on:
2020
- "Taskfile.ya?ml"
2121
- "**.go"
2222
- "docsgen/**"
23+
- "ruledocsgen/**"
2324
- "mkdocs.ya?ml"
2425
- "poetry.lock"
2526
- "pyproject.toml"

Diff for: .github/workflows/test-go-task.yml

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ jobs:
6969
module:
7070
- path: ./
7171
codecov-flags: unit
72+
- path: ruledocsgen/
73+
codecov-flags: unit
7274

7375
runs-on: ${{ matrix.operating-system }}
7476

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@ coverage_unit.txt
1818
/docsgen/arduino-cli
1919
/docsgen/arduino-cli.exe
2020
/docs/commands/*.md
21+
/ruledocsgen/ruledocsgen
22+
/ruledocsgen/ruledocsgen.exe
23+
/docs/rules/
2124

2225
/dist

Diff for: .prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
/internal/project/projectdata/testdata/packageindexes/invalid-JSON/package_foo_index.json
1010
/internal/rule/rulefunction/testdata/packageindexes/invalid-JSON/package_foo_index.json
1111
/internal/rule/rulefunction/testdata/sketches/InvalidJSONMetadataFile/sketch.json
12+
/ruledocsgen/testdata/golden

Diff for: Taskfile.yml

+17
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ tasks:
106106
desc: Create all generated documentation content
107107
deps:
108108
- task: go:cli-docs
109+
- task: go:rule-docs
109110
# Make the formatting consistent with the non-generated Markdown
110111
- task: general:format-prettier
111112

@@ -198,6 +199,20 @@ tasks:
198199
{{default "-min_confidence 0.8 -set_exit_status" .GO_LINT_FLAGS}} \
199200
{{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}
200201
202+
go:rule-docs:
203+
desc: Generate rules documentation
204+
dir: ./ruledocsgen
205+
deps:
206+
- task: go:rule-docs:build
207+
cmds:
208+
- ./ruledocsgen ../docs/rules
209+
210+
go:rule-docs:build:
211+
desc: Generate rules documentation
212+
dir: ./ruledocsgen
213+
cmds:
214+
- go build
215+
201216
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/test-go-task/Taskfile.yml
202217
go:test:
203218
desc: Run unit tests
@@ -217,9 +232,11 @@ tasks:
217232
desc: Run integration tests
218233
deps:
219234
- task: go:build
235+
- task: go:rule-docs:build
220236
- task: poetry:install-deps
221237
cmds:
222238
- poetry run pytest tests
239+
- poetry run pytest ruledocsgen/tests
223240

224241
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
225242
go:vet:

Diff for: docs/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
**Arduino Lint** is a command line tool that checks for common problems with [Arduino](https://www.arduino.cc/)
22
projects.
33

4-
Its focus is on the structure, metadata, and configuration of Arduino projects, rather than the code. Rules cover
5-
specification compliance, Library Manager submission requirements, and best practices.
4+
Its focus is on the structure, metadata, and configuration of Arduino projects, rather than the code. [Rules](rules.md)
5+
cover specification compliance, Library Manager submission requirements, and best practices.
66

77
## Installation
88

Diff for: docs/rules.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
**Arduino Lint** inspects Arduino projects for common problems. This is done by checking the project against a series of
2+
"rules", each of which is targeted to detecting a specific potential issue. Only the rules of relevance to the project
3+
being linted are applied.
4+
5+
## Rule documentation
6+
7+
Additional information is available for each of the **Arduino Lint** rules, organized by project type:
8+
9+
- [Sketch](rules/sketch.md)
10+
- [Library](rules/library.md)
11+
- [Boards platform](rules/platform.md)
12+
- [Package index](rules/package-index.md)
13+
14+
## Rule ID
15+
16+
In order to allow particular rules to be referenced unequivocally, each has been assigned a permanent unique
17+
identification code (e.g., `SS001`).
18+
19+
## Rule level
20+
21+
In addition to checking for critical flaws, **Arduino Lint** also advocates for best practices in Arduino projects. For
22+
this reason, not all rule violations are treated as fatal linting errors.
23+
24+
A violation of a rule is assigned a level according to its severity. In cases where a rule violation indicates a serious
25+
problem with the project, the violation is treated as an error, and will result in a non-zero exit status from the
26+
`arduino-lint` command. In cases where the violation indicates a possible problem, or where the rule is a recommendation
27+
for an optional improvement to enhance the project user's experience, the violation is treated as a warning. It is hoped
28+
that these warning-level violations will be given consideration by the user, but they do not affect the `arduino-lint`
29+
exit status.
30+
31+
Of the hundreds of rules provided by **Arduino Lint**, only the ones relevant to the current target project are applied,
32+
with the rest disabled.
33+
34+
The rule levels and enabled subset of rules is dependent on the target project type and how the user has configured
35+
Arduino Lint via the [command line flags](commands/arduino-lint.md) and
36+
[environment variables](index.md#environment-variables).
37+
38+
## Projects and "superprojects"
39+
40+
Arduino projects may contain other Arduino projects as subprojects. For example, the libraries
41+
[bundled](https://arduino.github.io/arduino-cli/latest/platform-specification/#platform-bundled-libraries) with an
42+
Arduino boards platform. These subprojects may, in turn, contain their own subprojects, such as the example sketches
43+
included with a platform bundled library.
44+
45+
**Arduino Lint** also lints any subprojects the target project might contain. The type of the top level "superproject"
46+
is a factor in the configuration of some rules. For example, there is no need to take Library Manager requirements into
47+
consideration in the case of a platform bundled library, since it will never be distributed via that system.

Diff for: mkdocs.yml

+7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ markdown_extensions:
2222
guess_lang: false
2323
- markdown.extensions.toc:
2424
permalink: true
25+
toc_depth: 4
2526
- mdx_truly_sane_lists:
2627
nested_indent: 2
2728
truly_sane: true
@@ -44,6 +45,12 @@ nav:
4445
- Home: index.md
4546
- installation.md
4647
- Command reference: commands/arduino-lint.md
48+
- Rules:
49+
- Introduction: rules.md
50+
- Sketch: rules/sketch.md
51+
- Library: rules/library.md
52+
- Platform: rules/platform.md
53+
- Package index: rules/package-index.md
4754
- CONTRIBUTING.md
4855

4956
extra:

Diff for: ruledocsgen/go.mod

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module github.com/arduino/arduino-lint/ruledocsgen
2+
3+
go 1.16
4+
5+
replace github.com/arduino/arduino-lint => ../
6+
7+
require (
8+
github.com/arduino/arduino-lint v0.0.0
9+
github.com/arduino/go-paths-helper v1.6.1
10+
github.com/olekukonko/tablewriter v0.0.5
11+
github.com/stretchr/testify v1.7.0
12+
)

0 commit comments

Comments
 (0)