@@ -95,7 +95,11 @@ def see
95
95
96
96
# @return [Array] parameter tag hashes
97
97
def params
98
- select_tags ( 'param' )
98
+ tags = @tags . select { |tag | tag [ :tag_name ] == 'param' } . map do |param |
99
+ param [ :link ] = clean_link ( "$#{ name } ::#{ param [ :name ] } " )
100
+ param
101
+ end
102
+ tags . empty? ? nil : tags
99
103
end
100
104
101
105
# @return [Array] example tag hashes
@@ -151,7 +155,7 @@ def toc_info
151
155
152
156
# @return [String] makes the component name suitable for a GitHub markdown link
153
157
def link
154
- name . delete ( '::' ) . strip . gsub ( ' ' , '-' ) . downcase
158
+ clean_link ( name )
155
159
end
156
160
157
161
# Some return, default, or valid values need to be in backticks. Instead of fu in the handler or code_object, this just does the change on the front.
@@ -195,5 +199,17 @@ def select_tags(name)
195
199
tags = @tags . select { |tag | tag [ :tag_name ] == name }
196
200
tags . empty? ? nil : tags
197
201
end
202
+
203
+ # Convert an input into a string appropriate for an anchor name.
204
+ #
205
+ # This converts any character not suitable for an id attribute into a '-'. Generally we're running this on Puppet identifiers for types and
206
+ # variables, so we only need to worry about the special characters ':' and '$'. With namespaces Puppet variables this should always be produce a
207
+ # unique result from a unique input, since ':' only appears in pairs, '$' only appears at the beginning, and '-' never appears.
208
+ #
209
+ # @param [String] the input to convert
210
+ # @return [String] the anchor-safe string
211
+ def clean_link ( input )
212
+ input . tr ( '^a-zA-Z0-9_-' , '-' )
213
+ end
198
214
end
199
215
end
0 commit comments