Skip to content

Commit ee40282

Browse files
authored
Merge pull request #326 from per1234/html-escape-ruledocs
Escape raw rule documentation text for HTML
2 parents f7c0a9a + 3b05382 commit ee40282

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

ruledocsgen/main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ func generateRulesDocumentation(ruleConfigurations []ruleconfiguration.Type, out
5555
}
5656

5757
templateFunctions := template.FuncMap{
58-
// Some the rule config text is intended for use in both tool output and in the reference, so can't be formatted at
59-
// the source as Markdown. Incidental markup characters in that text must be escaped.
60-
"escape": escape.MarkdownCharacters,
58+
// Some of the rule config text is intended for use in both tool output and in the reference, so can't be formatted
59+
// at the source as Markdown. Incidental markup characters in that text must be escaped.
60+
"escape": func(rawText string) string {
61+
return escape.MarkdownCharacters(template.HTMLEscapeString(rawText))
62+
},
6163
}
6264

6365
projectRulesIntroTemplate := template.Must(template.New("messageTemplate").Parse(

ruledocsgen/main_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,23 @@ func TestAll(t *testing.T) {
108108
ErrorModes: []rulemode.Type{rulemode.Default},
109109
RuleFunction: rulefunction.BoardsTxtMissing,
110110
},
111+
{
112+
ProjectType: projecttype.Platform,
113+
SuperprojectType: projecttype.All,
114+
Category: "configuration files",
115+
Subcategory: "boards.txt",
116+
ID: "PF009",
117+
Brief: "use of compiler.<pattern type>.extra_flags & foo 'bar' \"baz\"",
118+
MessageTemplate: "Board ID(s) {{.}} use compiler.<pattern type>.extra_flags properties. These are intended to be left for use by the user.",
119+
Description: "A board definition in the platform's `boards.txt` configuration file is using one of the `compiler.<pattern type>.extra_flags` properties (e.g., `compiler.cpp.extra_flags`). These are intended to be left for use by the user as a standardized interface for customizing the compilation commands. The platform author can define as many arbitrary properties as they like, so there is no need for them to take the user's properties.",
120+
Reference: "",
121+
DisableModes: nil,
122+
EnableModes: []rulemode.Type{rulemode.Default},
123+
InfoModes: nil,
124+
WarningModes: []rulemode.Type{rulemode.Default},
125+
ErrorModes: []rulemode.Type{rulemode.Strict},
126+
RuleFunction: rulefunction.BoardsTxtUserExtraFlagsUsage,
127+
},
111128
{
112129
ProjectType: projecttype.PackageIndex,
113130
SuperprojectType: projecttype.All,

ruledocsgen/testdata/golden/platform.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Arduino Lint provides 1 rules for the [`platform`](https://arduino.github.io/arduino-cli/latest/platform-specification/) project type:
1+
Arduino Lint provides 2 rules for the [`platform`](https://arduino.github.io/arduino-cli/latest/platform-specification/) project type:
22

33
---
44

@@ -20,3 +20,24 @@ Subcategory: boards.txt
2020
| permissive | ERROR |
2121
| specification | ERROR |
2222
| strict | ERROR |
23+
24+
---
25+
26+
<a id="PF009"></a>
27+
28+
## use of compiler.&lt;pattern type&gt;.extra\_flags &amp; foo &#39;bar&#39; &#34;baz&#34; (`PF009`)
29+
30+
A board definition in the platform's `boards.txt` configuration file is using one of the `compiler.<pattern type>.extra_flags` properties (e.g., `compiler.cpp.extra_flags`). These are intended to be left for use by the user as a standardized interface for customizing the compilation commands. The platform author can define as many arbitrary properties as they like, so there is no need for them to take the user's properties.
31+
32+
33+
Enabled for superproject type: all<br />
34+
Category: configuration files<br />
35+
Subcategory: boards.txt
36+
37+
##### Rule levels
38+
39+
| `compliance` | Level |
40+
|---------------|---------|
41+
| permissive | WARNING |
42+
| specification | WARNING |
43+
| strict | ERROR |

0 commit comments

Comments
 (0)