@@ -95,7 +95,11 @@ def see
9595
9696 # @return [Array] parameter tag hashes
9797 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
99103 end
100104
101105 # @return [Array] example tag hashes
@@ -151,7 +155,7 @@ def toc_info
151155
152156 # @return [String] makes the component name suitable for a GitHub markdown link
153157 def link
154- name . delete ( '::' ) . strip . gsub ( ' ' , '-' ) . downcase
158+ clean_link ( name )
155159 end
156160
157161 # 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)
195199 tags = @tags . select { |tag | tag [ :tag_name ] == name }
196200 tags . empty? ? nil : tags
197201 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
198214 end
199215end
0 commit comments