@@ -40,33 +40,39 @@ def schema_type
4040 # @param name [String]
4141 # @param data [Hash<String, Object]
4242 def initialize ( ext , name , data )
43+ raise ArgumentError , "Expecting Extension but got #{ ext . class } " unless ext . is_a? ( Extension )
44+ raise ArgumentError , "Expecting String but got #{ name . class } " unless name . is_a? ( String )
45+ raise ArgumentError , "Expecting Hash but got #{ data . class } " unless data . is_a? ( Hash )
46+
4347 @arch = ext . arch
4448 @data = data
4549 @name = name
4650 @desc = data [ "description" ]
4751 @schema = Schema . new ( data [ "schema" ] )
4852 @extra_validation = data [ "extra_validation" ]
49- also_defined_in = [ ]
50- unless data [ "also_defined_in" ] . nil?
51- if data [ "also_defined_in" ] . is_a? ( String )
52- other_ext = @arch . extension ( data [ "also_defined_in" ] )
53- raise "Definition error in #{ ext . name } .#{ name } : #{ data [ 'also_defined_in' ] } is not a known extension" if other_ext . nil?
54-
55- also_defined_in << other_ext
53+ also_defined_in_array = [ ]
54+ also_defined_in_data = data [ "also_defined_in" ]
55+ unless also_defined_in_data . nil?
56+ if also_defined_in_data . is_a? ( String )
57+ other_ext_name = also_defined_in_data
58+ other_ext = @arch . extension ( other_ext_name )
59+ raise "Definition error in #{ ext . name } .#{ name } : #{ other_ext_name } is not a known extension" if other_ext . nil?
60+
61+ also_defined_in_array << other_ext
5662 else
57- unless data [ "also_defined_in" ] . is_a? ( Array ) && data [ "also_defined_in" ] . all? { |e | e . is_a? ( String ) }
63+ unless also_defined_in_data . is_a? ( Array ) && also_defined_in_data . all? { |e | e . is_a? ( String ) }
5864 raise "schema error: also_defined_in should be a string or array of strings"
5965 end
6066
61- data [ "also_defined_in" ] . each do |other_ext_name |
67+ also_defined_in_data . each do |other_ext_name |
6268 other_ext = @arch . extension ( other_ext_name )
63- raise "Definition error in #{ ext . name } .#{ name } : #{ data [ 'also_defined_in' ] } is not a known extension" if other_ext . nil?
69+ raise "Definition error in #{ ext . name } .#{ name } : #{ also_defined_in_data } is not a known extension" if other_ext . nil?
6470
65- also_defined_in << other_ext
71+ also_defined_in_array << other_ext
6672 end
6773 end
6874 end
69- @exts = [ ext ] + also_defined_in
75+ @exts = [ ext ] + also_defined_in_array
7076 @idl_type = @schema . to_idl_type . make_const . freeze
7177 end
7278
@@ -81,22 +87,15 @@ def defined_in_extension_version?(version)
8187 end
8288 end
8389
84- # @param ext [Extension] Extension that defines this parameter.
85- # @return [String] Text that includes the parameter name and a link to the parameter definition.
86- # Should only be called if there is only one in-scope extension that defines the parameter.
87- def name_with_link ( ext )
88- link_to_udb_doc_ext_param ( ext . name , name )
89- end
90-
9190 # @param exts [Array<Extension>] List of all in-scope extensions that define this parameter.
92- # @return [String] Text that includes the parameter name and a link to the parameter definition
91+ # @return [String] Text to create a link to the parameter definition with the link text the parameter name.
9392 # if only one extension defines the parameter, otherwise just the parameter name.
9493 def name_potentially_with_link ( in_scope_exts )
95- raise ArgumentError , "Expecting Array" unless in_scope_exts . is_a? ( Array )
94+ raise ArgumentError , "Expecting Array but got #{ in_scope_exts . class } " unless in_scope_exts . is_a? ( Array )
9695 raise ArgumentError , "Expecting Array[Extension]" unless in_scope_exts [ 0 ] . is_a? ( Extension )
9796
9897 if in_scope_exts . size == 1
99- link_to_udb_doc_ext_param ( in_scope_exts [ 0 ] . name , name )
98+ link_to_udb_doc_ext_param ( in_scope_exts [ 0 ] . name , name , name )
10099 else
101100 name
102101 end
0 commit comments