Commit baf5336
(#300) Fix anchor links in Markdown docs
Previously, anchors in generated Markdown were not unique. There were
two problems:
1. Each parameter in a class, type, function, etc. had its own anchor,
but the `name` of the anchor was just the normalized name of the
parameter. This meant that all parameters with the same name would
have the same anchor.
2. Classes, types, etc. had their `::`s removed, whiched opened the
(rare) possibility of having non-unique anchor names for unique
type names.
This fixes those problems by:
1. Using the full name of the parameter, e.g. `$my::class::param`, to
generate an anchor name.
2. Using a better anchor normalization routine. Each invalid
character, i.e. not `[a-zA-Z0-9_-]`, is converted to `-`. This
should always result in unique anchor names for standard Puppet
identifiers, since the only invalid characters sequences are `::`
and `$` (which only appears once at the beginning of the string).
Furthermore, `-` never appears in a valid Puppet identifier, so
those two cases are the only way for it to be generated.1 parent 5fe07ba commit baf5336
File tree
6 files changed
+33
-11
lines changed- lib/puppet-strings/markdown
- templates
- spec/unit/puppet-strings/markdown
6 files changed
+33
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
| |||
151 | 155 | | |
152 | 156 | | |
153 | 157 | | |
154 | | - | |
| 158 | + | |
155 | 159 | | |
156 | 160 | | |
157 | 161 | | |
| |||
195 | 199 | | |
196 | 200 | | |
197 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
198 | 214 | | |
199 | 215 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
38 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
0 commit comments