Skip to content

Commit ee9bf58

Browse files
authored
cmd/makedocs: fix headers formatting (go-critic#803)
The problem was caused by checker params list that included (for some reason) the next header. To avoid whitespace-driven decisions, use HTML elements to emit lists, so they are closed before next checker heading starts. Also added octalLiteral checker docs. Fixes go-critic#802 Signed-off-by: Iskander Sharipov <[email protected]>
1 parent 765907a commit ee9bf58

File tree

2 files changed

+123
-13
lines changed

2 files changed

+123
-13
lines changed

docs/overview.md

Lines changed: 112 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ They also detect code that may be correct, but looks suspicious.
9595
<a href="#nilValReturn-ref">nilValReturn</a>
9696
</td>
9797
<td>Detects return statements those results evaluate to nil</td>
98+
</tr><tr>
99+
<td nowrap>:white_check_mark:
100+
<a href="#octalLiteral-ref">octalLiteral</a>
101+
</td>
102+
<td>Detects octal literals passed to functions</td>
98103
</tr><tr>
99104
<td nowrap>:white_check_mark:
100105
<a href="#offBy1-ref">offBy1</a>
@@ -557,7 +562,15 @@ func f(in int, out *int) (err error) {}
557562

558563

559564
Checker parameters:
560-
* `@captLocal.paramsOnly` whether to restrict checker to params only (default true)
565+
<ul>
566+
<li>
567+
568+
`@captLocal.paramsOnly` whether to restrict checker to params only (default true)
569+
570+
</li>
571+
572+
</ul>
573+
561574

562575
<a name="caseOrder-ref"></a>
563576
## caseOrder
@@ -937,7 +950,15 @@ if cond1 {
937950

938951

939952
Checker parameters:
940-
* `@elseif.skipBalanced` whether to skip balanced if-else pairs (default true)
953+
<ul>
954+
<li>
955+
956+
`@elseif.skipBalanced` whether to skip balanced if-else pairs (default true)
957+
958+
</li>
959+
960+
</ul>
961+
941962

942963
<a name="emptyFallthrough-ref"></a>
943964
## emptyFallthrough
@@ -1161,7 +1182,15 @@ func f(x *[1024]int) {}
11611182

11621183

11631184
Checker parameters:
1164-
* `@hugeParam.sizeThreshold` size in bytes that makes the warning trigger (default 80)
1185+
<ul>
1186+
<li>
1187+
1188+
`@hugeParam.sizeThreshold` size in bytes that makes the warning trigger (default 80)
1189+
1190+
</li>
1191+
1192+
</ul>
1193+
11651194

11661195
<a name="ifElseChain-ref"></a>
11671196
## ifElseChain
@@ -1345,7 +1374,15 @@ for _, v := range a {
13451374

13461375

13471376
Checker parameters:
1348-
* `@nestingReduce.bodyWidth` min number of statements inside a branch to trigger a warning (default 5)
1377+
<ul>
1378+
<li>
1379+
1380+
`@nestingReduce.bodyWidth` min number of statements inside a branch to trigger a warning (default 5)
1381+
1382+
</li>
1383+
1384+
</ul>
1385+
13491386

13501387
<a name="nilValReturn-ref"></a>
13511388
## nilValReturn
@@ -1381,6 +1418,31 @@ if err != nil {
13811418

13821419

13831420

1421+
<a name="octalLiteral-ref"></a>
1422+
## octalLiteral
1423+
1424+
[
1425+
**diagnostic**
1426+
**experimental** ]
1427+
1428+
Detects octal literals passed to functions.
1429+
1430+
1431+
1432+
1433+
1434+
**Before:**
1435+
```go
1436+
foo(02)
1437+
```
1438+
1439+
**After:**
1440+
```go
1441+
foo(2)
1442+
```
1443+
1444+
1445+
13841446
<a name="offBy1-ref"></a>
13851447
## offBy1
13861448

@@ -1488,8 +1550,20 @@ for _, x := range &xs { // No copy
14881550

14891551

14901552
Checker parameters:
1491-
* `@rangeExprCopy.sizeThreshold` size in bytes that makes the warning trigger (default 512)
1492-
* `@rangeExprCopy.skipTestFuncs` whether to check test functions (default true)
1553+
<ul>
1554+
<li>
1555+
1556+
`@rangeExprCopy.sizeThreshold` size in bytes that makes the warning trigger (default 512)
1557+
1558+
</li>
1559+
<li>
1560+
1561+
`@rangeExprCopy.skipTestFuncs` whether to check test functions (default true)
1562+
1563+
</li>
1564+
1565+
</ul>
1566+
14931567

14941568
<a name="rangeValCopy-ref"></a>
14951569
## rangeValCopy
@@ -1522,8 +1596,20 @@ for i := range xs {
15221596

15231597

15241598
Checker parameters:
1525-
* `@rangeValCopy.sizeThreshold` size in bytes that makes the warning trigger (default 128)
1526-
* `@rangeValCopy.skipTestFuncs` whether to check test functions (default true)
1599+
<ul>
1600+
<li>
1601+
1602+
`@rangeValCopy.sizeThreshold` size in bytes that makes the warning trigger (default 128)
1603+
1604+
</li>
1605+
<li>
1606+
1607+
`@rangeValCopy.skipTestFuncs` whether to check test functions (default true)
1608+
1609+
</li>
1610+
1611+
</ul>
1612+
15271613

15281614
<a name="regexpMust-ref"></a>
15291615
## regexpMust
@@ -1810,7 +1896,15 @@ v := a[5]
18101896

18111897

18121898
Checker parameters:
1813-
* `@underef.skipRecvDeref` whether to skip (*x).method() calls where x is a pointer receiver (default true)
1899+
<ul>
1900+
<li>
1901+
1902+
`@underef.skipRecvDeref` whether to skip (*x).method() calls where x is a pointer receiver (default true)
1903+
1904+
</li>
1905+
1906+
</ul>
1907+
18141908

18151909
<a name="unlabelStmt-ref"></a>
18161910
## unlabelStmt
@@ -1896,7 +1990,15 @@ func f() (x, y float64)
18961990

18971991

18981992
Checker parameters:
1899-
* `@unnamedResult.checkExported` whether to check exported functions (default false)
1993+
<ul>
1994+
<li>
1995+
1996+
`@unnamedResult.checkExported` whether to check exported functions (default false)
1997+
1998+
</li>
1999+
2000+
</ul>
2001+
19002002

19012003
<a name="unnecessaryBlock-ref"></a>
19022004
## unnecessaryBlock

docs/templates/checker.partial.tmpl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,17 @@
2727

2828
{{ if .Params }}
2929
Checker parameters:
30+
<ul>
31+
3032
{{- range $key, $_ := .Params }}
31-
* `@{{$.Name}}.{{$key}}` {{.Usage}} (default {{.Value}})
32-
{{- end }}
33+
<li>
34+
35+
`@{{$.Name}}.{{$key}}` {{.Usage}} (default {{.Value}})
36+
37+
</li>
3338
{{- end }}
3439

35-
{{- end }}
40+
</ul>
41+
{{ end }}
42+
43+
{{- end }}

0 commit comments

Comments
 (0)