diff --git a/lib/jsduck/accessors.rb b/lib/jsduck/accessors.rb index a92c217b8e2616c36df79f739fa41c6c0fac9d70..e59088768f02ae29b2d0eb542683c34e80ea6c6d 100644 --- a/lib/jsduck/accessors.rb +++ b/lib/jsduck/accessors.rb @@ -57,8 +57,7 @@ module JsDuck :owner => cfg[:owner], :files => cfg[:files], :id => "method-" + name, - :attributes => clone_attributes(cfg), - :meta => cfg[:meta], + :meta => clone_meta(cfg), } end @@ -80,8 +79,7 @@ module JsDuck :owner => cfg[:owner], :files => cfg[:files], :id => "method-" + name, - :attributes => clone_attributes(cfg), - :meta => cfg[:meta] + :meta => clone_meta(cfg), } end @@ -117,8 +115,7 @@ module JsDuck :owner => cfg[:owner], :files => cfg[:files], :id => "event-" + name, - :attributes => clone_attributes(cfg), - :meta => cfg[:meta] + :meta => clone_meta(cfg), } end @@ -126,12 +123,12 @@ module JsDuck str[0,1].upcase + str[1..-1] end - # Create copy of all attributes of config, except the :required - # attribute which only applies to configs and must not be + # Create copy of all meta attributes of config, except the + # :required which only applies to configs and must not be # propagated to methods or events. - def clone_attributes(cfg) + def clone_meta(cfg) h = {} - cfg[:attributes].each_pair do |key, value| + cfg[:meta].each_pair do |key, value| h[:key] = value unless key == :required end h diff --git a/lib/jsduck/aggregator.rb b/lib/jsduck/aggregator.rb index 561dfc89261b76ed33b343491dfc7d340debfda4..20d26ffd91d41571697bff388ea7b04d3e004c6a 100644 --- a/lib/jsduck/aggregator.rb +++ b/lib/jsduck/aggregator.rb @@ -92,12 +92,12 @@ module JsDuck [:mixins, :alternateClassNames, :files].each do |tag| old[tag] = old[tag] + new[tag] end - # Merge attribute hashes - new[:attributes].each_pair do |name, value| - old[:attributes][name] = old[:attributes][name] || value + # Merge meta hashes + new[:meta].each_pair do |name, value| + old[:meta][name] = old[:meta][name] || value end # Merge hashes of arrays - [:aliases, :meta].each do |tag| + [:aliases].each do |tag| new[tag].each_pair do |key, contents| old[tag][key] = (old[tag][key] || []) + contents end @@ -133,7 +133,7 @@ module JsDuck end def add_to_class(cls, member) - cls[member[:attributes][:static] ? :statics : :members][member[:tagname]] << member + cls[member[:meta][:static] ? :statics : :members][member[:tagname]] << member end def add_orphan(node) @@ -187,7 +187,6 @@ module JsDuck :members => Class.default_members_hash, :statics => Class.default_members_hash, :aliases => {}, - :attributes => {}, :meta => {}, :files => [{:filename => "", :linenr => 0, :href => ""}], }) diff --git a/lib/jsduck/app_exporter.rb b/lib/jsduck/app_exporter.rb index 1864f677ad2dc17015a8204d8215d53dc6ce4988..fc36b39b273680e604695cd578648f4514105298 100644 --- a/lib/jsduck/app_exporter.rb +++ b/lib/jsduck/app_exporter.rb @@ -45,7 +45,7 @@ module JsDuck def compact_member(m) m_copy = {} - [:name, :tagname, :owner, :attributes, :id].each do |key| + [:name, :tagname, :owner, :meta, :id].each do |key| m_copy[key] = m[key] end m_copy diff --git a/lib/jsduck/class.rb b/lib/jsduck/class.rb index 5f99c92e5d8ed97d498bc0818872a55b12f7e1c7..fd60a44cf6c05bbb1f4caa0e9c1c4f478bd8d9d8 100644 --- a/lib/jsduck/class.rb +++ b/lib/jsduck/class.rb @@ -174,7 +174,7 @@ module JsDuck ms = @members_map[name] || [] ms = ms.find_all {|m| m[:tagname] == type_name } if type_name - ms = ms.find_all {|m| m[:attributes][:static] } if static + ms = ms.find_all {|m| m[:meta][:static] } if static return ms end diff --git a/lib/jsduck/class_formatter.rb b/lib/jsduck/class_formatter.rb index 927e91560496c310d67761652daf4a7a2d0027e4..a140589bc0411073ae763b40908d9889a66780b9 100644 --- a/lib/jsduck/class_formatter.rb +++ b/lib/jsduck/class_formatter.rb @@ -36,8 +36,6 @@ module JsDuck def format_member(m) @formatter.doc_context = m[:files][0] m[:doc] = @formatter.format(m[:doc]) if m[:doc] - depr = m[:attributes][:deprecated] - depr[:text] = @formatter.format(depr[:text]) if depr if expandable?(m) || @formatter.too_long?(m[:doc]) m[:shortDoc] = @formatter.shorten(m[:doc]) end @@ -53,7 +51,7 @@ module JsDuck end def expandable?(m) - m[:params] || (m[:properties] && m[:properties].length > 0) || m[:default] || m[:attributes][:deprecated] || m[:attributes][:template] + m[:params] || (m[:properties] && m[:properties].length > 0) || m[:default] || m[:meta][:deprecated] || m[:meta][:template] end def format_item(it, is_css_tag) diff --git a/lib/jsduck/doc_formatter.rb b/lib/jsduck/doc_formatter.rb index 1ea35fe985290b7aa4cebe7278bd319aa482c36f..b38ea515dbf210492d6237ad80013e821f0af20a 100644 --- a/lib/jsduck/doc_formatter.rb +++ b/lib/jsduck/doc_formatter.rb @@ -152,12 +152,12 @@ module JsDuck # one when we ignore the static members. If there's more, # report ambiguity. If there's only static members, also # report ambiguity. - instance_ms = ms.find_all {|m| !m[:attributes][:static] } + instance_ms = ms.find_all {|m| !m[:meta][:static] } if instance_ms.length > 1 alternatives = instance_ms.map {|m| m[:tagname].to_s }.join(", ") Logger.instance.warn(:link_ambiguous, "#{input} is ambiguous: "+alternatives, file, line) elsif instance_ms.length == 0 - static_ms = ms.find_all {|m| m[:attributes][:static] } + static_ms = ms.find_all {|m| m[:meta][:static] } alternatives = static_ms.map {|m| "static " + m[:tagname].to_s }.join(", ") Logger.instance.warn(:link_ambiguous, "#{input} is ambiguous: "+alternatives, file, line) end @@ -234,8 +234,8 @@ module JsDuck def get_matching_member(cls, member, type=nil, static=false) ms = get_members(cls, member, type, static).find_all {|m| !m[:private] } if ms.length > 1 - instance_ms = ms.find_all {|m| !m[:attributes][:static] } - instance_ms.length > 0 ? instance_ms[0] : ms.find_all {|m| m[:attributes][:static] }[0] + instance_ms = ms.find_all {|m| !m[:meta][:static] } + instance_ms.length > 0 ? instance_ms[0] : ms.find_all {|m| m[:meta][:static] }[0] else ms[0] end diff --git a/lib/jsduck/doc_parser.rb b/lib/jsduck/doc_parser.rb index 547d3ea769561570c6fd0be86583634b09ecf18d..a8c98346bfcef396b4bbf14e94d1dfa563d8b436 100644 --- a/lib/jsduck/doc_parser.rb +++ b/lib/jsduck/doc_parser.rb @@ -134,8 +134,6 @@ module JsDuck at_inheritdoc elsif look(/@alias/) at_alias - elsif look(/@deprecated\b/) - at_deprecated elsif look(/@var\b/) at_var elsif look(/@inheritable\b/) @@ -146,16 +144,6 @@ module JsDuck boolean_at_tag(/@accessor/, :accessor) elsif look(/@evented\b/) boolean_at_tag(/@evented/, :evented) - elsif look(/@static\b/) - attribute_tag(/@static/, :static) - elsif look(/@protected\b/) - attribute_tag(/@protected/, :protected) - elsif look(/@template\b/) - attribute_tag(/@template/, :template) - elsif look(/@abstract\b/) - attribute_tag(/@abstract\b/, :abstract) - elsif look(/@readonly\b/) - attribute_tag(/@readonly\b/, :readonly) elsif look(/@markdown\b/) # this is detected just to be ignored boolean_at_tag(/@markdown/, :markdown) @@ -178,13 +166,21 @@ module JsDuck prev_tag = @current_tag add_tag(:meta) - @current_tag[:name] = match(/\w+/) + @current_tag[:name] = tag.key || tag.name + match(/\w+/) skip_horiz_white - # Fors singleline tags, scan to the end of line and finish the - # tag. For multiline tags we leave the tag open for :doc - # addition just like with built-in multiline tags. - unless tag.multiline + if tag.boolean + # For boolean tags, only scan the tag name and switch context + # back to previous tag. + skip_white + @current_tag = prev_tag + elsif tag.multiline + # For multiline tags we leave the tag open for :doc addition + # just like with built-in multiline tags. + else + # Fors singleline tags, scan to the end of line and finish the + # tag. @current_tag[:doc] = @input.scan(/.*$/).strip skip_white @current_tag = prev_tag @@ -356,17 +352,6 @@ module JsDuck skip_white end - # matches @deprecated some text ... newline - def at_deprecated - match(/@deprecated/) - add_tag(:deprecated) - skip_horiz_white - @current_tag[:version] = @input.scan(/[0-9.]+/) - skip_horiz_white - @current_tag[:text] = @input.scan(/.*$/) - skip_white - end - # Used to match @private, @ignore, @hide, ... def boolean_at_tag(regex, propname) match(regex) @@ -374,15 +359,6 @@ module JsDuck skip_white end - # Matches tag like @protected, @abstract, @readonly, @template - # Creates :attribute tag with that name - def attribute_tag(regex, attr_name) - match(regex) - add_tag(:attribute) - @current_tag[:name] = attr_name - skip_white - end - # matches {type} if possible and sets it on @current_tag def maybe_type skip_horiz_white diff --git a/lib/jsduck/inherit_doc.rb b/lib/jsduck/inherit_doc.rb index 1f6241d1625a37d05c10832e51b96da6ee18eb58..d8abd0616e41334e2bf0c11c7acd22e44b2f43ea 100644 --- a/lib/jsduck/inherit_doc.rb +++ b/lib/jsduck/inherit_doc.rb @@ -42,7 +42,7 @@ module JsDuck warn("@inheritdoc #{inherit[:cls]}##{inherit[:member]} - class not found", context) return m end - parent = parent_cls.get_members(inherit[:member], inherit[:type] || m[:tagname], inherit[:static] || m[:attributes][:static])[0] + parent = parent_cls.get_members(inherit[:member], inherit[:type] || m[:tagname], inherit[:static] || m[:meta][:static])[0] unless parent warn("@inheritdoc #{inherit[:cls]}##{inherit[:member]} - member not found", context) return m @@ -53,7 +53,7 @@ module JsDuck warn("@inheritdoc - parent class not found", context) return m end - parent = parent_cls.get_members(m[:name], m[:tagname], m[:attributes][:static])[0] + parent = parent_cls.get_members(m[:name], m[:tagname], m[:meta][:static])[0] unless parent warn("@inheritdoc - parent member not found", context) return m diff --git a/lib/jsduck/merger.rb b/lib/jsduck/merger.rb index 8f13feee7858f97b64bd1da86372ef8338a070ee..b08518c84d5e1c2826b49cf383c77cefbc3d1443 100644 --- a/lib/jsduck/merger.rb +++ b/lib/jsduck/merger.rb @@ -11,10 +11,12 @@ module JsDuck # Allow passing in filename and line for error reporting attr_accessor :filename attr_accessor :linenr + attr_accessor :meta_tags_map def initialize @filename = "" @linenr = 0 + @meta_tags_map = {} end def merge(docs, code) @@ -225,7 +227,6 @@ module JsDuck :private => !!doc_map[:private], :inheritable => !!doc_map[:inheritable], :inheritdoc => doc_map[:inheritdoc] ? doc_map[:inheritdoc].first : nil, - :attributes => detect_attributes(doc_map), :meta => detect_meta(doc_map), }) hash[:id] = create_member_id(hash) @@ -235,7 +236,7 @@ module JsDuck def create_member_id(m) # Sanitize $ in member names with something safer name = m[:name].gsub(/\$/, 'S-') - "#{m[:attributes][:static] ? 'static-' : ''}#{m[:tagname]}-#{name}" + "#{m[:meta][:static] ? 'static-' : ''}#{m[:tagname]}-#{name}" end def detect_name(tagname, doc_map, code, name_type = :last_name) @@ -361,6 +362,13 @@ module JsDuck meta[tag[:name]] = [] unless meta[tag[:name]] meta[tag[:name]] << tag[:doc] end + + meta.each_pair do |key, value| + tag = @meta_tags_map[key] + meta[key] = tag.to_value(tag.boolean ? true : value) + end + + meta[:required] = true if detect_required(doc_map) meta end @@ -368,18 +376,6 @@ module JsDuck !!(doc_map[:singleton] || code[:type] == :ext_define && code[:singleton]) end - def detect_attributes(doc_map) - attributes = {} - (doc_map[:attribute] || []).each do |tag| - attributes[tag[:name]] = true - end - # @deprecated and (required) are detected in special ways from - # doc-comment but merged into :attributes hash. - attributes[:deprecated] = doc_map[:deprecated].first if doc_map[:deprecated] - attributes[:required] = true if detect_required(doc_map) - attributes - end - def detect_required(doc_map) doc_map[:cfg] && doc_map[:cfg].first[:optional] == false end diff --git a/lib/jsduck/meta_tag.rb b/lib/jsduck/meta_tag.rb index fc3d2afa2ce20db493b0d472c3792033272b3a4f..b3d8dadbe109d26337548ed4964e4cc2600ea888 100644 --- a/lib/jsduck/meta_tag.rb +++ b/lib/jsduck/meta_tag.rb @@ -8,17 +8,40 @@ module JsDuck # Name of the tag (required) attr_reader :name + # The key under which to store this tag. Should be a symbol. + # By default the string :name is used as key. + attr_reader :key + + # The text to display in member signature. Must be a hash + # defining the short and long versions of the signature text: + # + # {:long => "something", :short => "SOM"} + # + attr_reader :signature + # True to include all lines up to next @tag as part of this meta-tag attr_reader :multiline + # True to ignore any text after the @tag, just record the + # existance of the tag. + attr_reader :boolean + + # It gets passed an array of contents gathered from all meta-tags + # of given type. It should return the value to be stored for this + # meta-tag at :key. The returned value is also passed to #to_html + # method. Returning nil will cause the tag to be ignored. By + # default the contents are returned unchanged. + def to_value(contents) + contents + end + # Override this to transform the content of meta-tag to HTML to be # included into documentation. # - # It gets passed an array of contents gathered from all meta-tags - # of given type. It should return an HTML string to inject into - # document. For help in that it can use the #format method to - # easily support Markdown and {@link/img} tags inside the contents - # of meta-tag. + # It gets passed the value returned by #to_value method. It should + # return an HTML string to inject into document. For help in that + # it can use the #format method to easily support Markdown and + # {@link/img} tags inside the contents of meta-tag. # # By default the method returns nil, which means the tag will not # be rendered at all. diff --git a/lib/jsduck/meta_tag_loader.rb b/lib/jsduck/meta_tag_loader.rb index 385015b99e23babea7914b95dd44f95d72e3ac86..70e76a8911a0df9a78507aac706a56a268dece08 100644 --- a/lib/jsduck/meta_tag_loader.rb +++ b/lib/jsduck/meta_tag_loader.rb @@ -1,11 +1,20 @@ require "jsduck/meta_tag" require 'jsduck/tag/author' require 'jsduck/tag/docauthor' +require 'jsduck/tag/static' +require 'jsduck/tag/protected' +require 'jsduck/tag/deprecated' +require 'jsduck/tag/required' +require 'jsduck/tag/template' +require 'jsduck/tag/abstract' +require 'jsduck/tag/readonly' module JsDuck # Loads user-defined meta-tags class MetaTagLoader + attr_reader :meta_tags + # instatiates builtin meta tags def initialize @classes = MetaTag.descendants diff --git a/lib/jsduck/renderer.rb b/lib/jsduck/renderer.rb index 2167ff0dce00366e6cdd6ccfefe5818dd9641af9..8f80cbbbc6900bcd3a20bba6bdb72a89db04b82b 100644 --- a/lib/jsduck/renderer.rb +++ b/lib/jsduck/renderer.rb @@ -40,7 +40,7 @@ module JsDuck return if meta_data.size == 0 @meta_tags.map do |tag| - contents = meta_data[tag.name] + contents = meta_data[tag.key || tag.name] if contents tag.to_html(contents) else @@ -224,7 +224,7 @@ module JsDuck after = "" Class.signature_attributes.each do |attribute| attr = attribute[:name] - after += "#{attr}" if m[:attributes][attr] + after += "#{attr}" if m[:meta][attr] end uri = "#!/api/#{m[:owner]}-#{m[:id]}" @@ -249,26 +249,6 @@ module JsDuck doc << "

Defaults to: " + CGI.escapeHTML(m[:default]) + "

" end - if m[:attributes][:deprecated] - depr = m[:attributes][:deprecated] - v = depr[:version] ? "since " + depr[:version] : "" - doc << [ - "
", - "

This #{m[:tagname]} has been deprecated #{v}

", - depr[:text], - "
", - ] - end - - if m[:attributes][:template] - doc << [ - "
", - "

This is a template method. A hook into the functionality of this class.", - "Feel free to override it in child classes.

", - "
", - ] - end - doc << render_meta_data(m[:meta]) doc << render_params_and_return(m) diff --git a/lib/jsduck/source_file.rb b/lib/jsduck/source_file.rb index 6cc4e559e927bab826f783cf34e82807a93e1ae3..1a7df9dfa8199e629835de25640606392096f050 100644 --- a/lib/jsduck/source_file.rb +++ b/lib/jsduck/source_file.rb @@ -24,12 +24,21 @@ module JsDuck merger = Merger.new merger.filename = @filename + merger.meta_tags_map = meta_tags_map @docs = parse.map do |docset| merger.linenr = docset[:linenr] link(docset[:linenr], merger.merge(docset[:comment], docset[:code])) end end + def meta_tags_map + map = {} + (@options[:meta_tags] || []).each do |tag| + map[tag.key || tag.name] = tag + end + map + end + # loops through each doc-object in file def each(&block) @docs.each(&block) diff --git a/lib/jsduck/tag/abstract.rb b/lib/jsduck/tag/abstract.rb new file mode 100644 index 0000000000000000000000000000000000000000..790b99df2dc6de3ef4e01b7b795036f7a627c23b --- /dev/null +++ b/lib/jsduck/tag/abstract.rb @@ -0,0 +1,14 @@ +require "jsduck/meta_tag" + +module JsDuck::Tag + # Implementation of @abstract tag + class Abstract < JsDuck::MetaTag + def initialize + @name = "abstract" + @key = :abstract + @signature = {:long => "abstract", :short => "ABS"} + @boolean = true + end + end +end + diff --git a/lib/jsduck/tag/deprecated.rb b/lib/jsduck/tag/deprecated.rb new file mode 100644 index 0000000000000000000000000000000000000000..8b2851d73f5fc203c5ba9d4e0077d304f9f6d449 --- /dev/null +++ b/lib/jsduck/tag/deprecated.rb @@ -0,0 +1,34 @@ +require "jsduck/meta_tag" +require "pp" + +module JsDuck::Tag + # Implementation of @deprecated tag + class Deprecated < JsDuck::MetaTag + def initialize + @name = "deprecated" + @key = :deprecated + @signature = {:long => "deprecated", :short => "DEP"} + @multiline = true + end + + def to_value(contents) + text = contents[0] + if text =~ /\A([0-9.]+)(.*)\Z/ + {:version => $1, :text => $2.strip} + else + {:text => text || ""} + end + end + + def to_html(depr) + v = depr[:version] ? "since " + depr[:version] : "" + <<-EOHTML +
+

This member has been deprecated #{v}

+ #{format(depr[:text])} +
+ EOHTML + end + end +end + diff --git a/lib/jsduck/tag/protected.rb b/lib/jsduck/tag/protected.rb new file mode 100644 index 0000000000000000000000000000000000000000..e9ad16625df598e5af6a1bebcba6925333a77b0e --- /dev/null +++ b/lib/jsduck/tag/protected.rb @@ -0,0 +1,14 @@ +require "jsduck/meta_tag" + +module JsDuck::Tag + # Implementation of @protected tag + class Protected < JsDuck::MetaTag + def initialize + @name = "protected" + @key = :protected + @signature = {:long => "protected", :short => "PRO"} + @boolean = true + end + end +end + diff --git a/lib/jsduck/tag/readonly.rb b/lib/jsduck/tag/readonly.rb new file mode 100644 index 0000000000000000000000000000000000000000..e90fca6ab9ca889eb918108484e21712fba071c7 --- /dev/null +++ b/lib/jsduck/tag/readonly.rb @@ -0,0 +1,14 @@ +require "jsduck/meta_tag" + +module JsDuck::Tag + # Implementation of @readonly tag + class Readonly < JsDuck::MetaTag + def initialize + @name = "readonly" + @key = :readonly + @signature = {:long => "readonly", :short => "R O"} + @boolean = true + end + end +end + diff --git a/lib/jsduck/tag/required.rb b/lib/jsduck/tag/required.rb new file mode 100644 index 0000000000000000000000000000000000000000..73769e92d0b9a99bdf3178a111b14df90dccd4ff --- /dev/null +++ b/lib/jsduck/tag/required.rb @@ -0,0 +1,21 @@ +require "jsduck/meta_tag" + +module JsDuck::Tag + # There is no @required tag. + # Instead the :required attribute is detected after @cfg: + # + # @cfg {Type} someName (required) + # + # This class is only used for displaying the required attribute, not + # for detecting it. The detection is done with custom logic in + # DocParser and Merger classes. + class Required < JsDuck::MetaTag + def initialize + @name = "--non-matching-requried-tag--" + @key = :required + @signature = {:long => "required", :short => "REQ"} + @boolean = true + end + end +end + diff --git a/lib/jsduck/tag/static.rb b/lib/jsduck/tag/static.rb new file mode 100644 index 0000000000000000000000000000000000000000..e42c86ea9852eb7854d01c310309ba51989d7dc6 --- /dev/null +++ b/lib/jsduck/tag/static.rb @@ -0,0 +1,14 @@ +require "jsduck/meta_tag" + +module JsDuck::Tag + # Implementation of @static tag + class Static < JsDuck::MetaTag + def initialize + @name = "static" + @key = :static + @signature = {:long => "static", :short => "STA"} + @boolean = true + end + end +end + diff --git a/lib/jsduck/tag/template.rb b/lib/jsduck/tag/template.rb new file mode 100644 index 0000000000000000000000000000000000000000..68a4380c7b0df5b7e66853d2546c705f26a9da0b --- /dev/null +++ b/lib/jsduck/tag/template.rb @@ -0,0 +1,23 @@ +require "jsduck/meta_tag" + +module JsDuck::Tag + # Implementation of @template tag + class Template < JsDuck::MetaTag + def initialize + @name = "template" + @key = :template + @signature = {:long => "template", :short => "TMP"} + @boolean = true + end + + def to_html(contents) + <<-EOHTML +
+

This is a template method. A hook into the functionality of this class. + Feel free to override it in child classes.

+
+ EOHTML + end + end +end + diff --git a/spec/aggregator_attributes_spec.rb b/spec/aggregator_attributes_spec.rb index c0f2752d3493da988eab0ecbf6982faf6435cdbe..814b576a06d1c8ee5b5c707dd787d58027455953 100644 --- a/spec/aggregator_attributes_spec.rb +++ b/spec/aggregator_attributes_spec.rb @@ -2,10 +2,13 @@ require "jsduck/aggregator" require "jsduck/source_file" describe JsDuck::Aggregator do + before(:all) do + @opts = {:meta_tags => JsDuck::MetaTagLoader.new.meta_tags} + end def parse(string) agr = JsDuck::Aggregator.new - agr.aggregate(JsDuck::SourceFile.new(string)) + agr.aggregate(JsDuck::SourceFile.new(string, "", @opts)) agr.result end @@ -15,7 +18,7 @@ describe JsDuck::Aggregator do end it "gets protected attribute" do - @doc[:attributes][:protected].should == true + @doc[:meta][:protected].should == true end end @@ -25,7 +28,7 @@ describe JsDuck::Aggregator do end it "gets abstract attribute" do - @doc[:attributes][:abstract].should == true + @doc[:meta][:abstract].should == true end end @@ -35,7 +38,7 @@ describe JsDuck::Aggregator do end it "gets static attribute" do - @doc[:attributes][:static].should == true + @doc[:meta][:static].should == true end end @@ -45,7 +48,7 @@ describe JsDuck::Aggregator do end it "gets readonly attribute" do - @doc[:attributes][:readonly].should == true + @doc[:meta][:readonly].should == true end end @@ -60,7 +63,7 @@ describe JsDuck::Aggregator do EOS end it "gets template attribute" do - @doc[:attributes][:template].should == true + @doc[:meta][:template].should == true end end @@ -73,7 +76,7 @@ describe JsDuck::Aggregator do EOS end it "is not required by default" do - @doc[:attributes][:required].should_not == true + @doc[:meta][:required].should_not == true end end @@ -86,7 +89,7 @@ describe JsDuck::Aggregator do EOS end it "has required flag set to true" do - @doc[:attributes][:required].should == true + @doc[:meta][:required].should == true end end @@ -100,16 +103,16 @@ describe JsDuck::Aggregator do EOS end it "doesn't become a required class" do - @doc[:attributes][:required].should_not == true + @doc[:meta][:required].should_not == true end it "contains required config" do - @doc[:members][:cfg][0][:attributes][:required].should == true + @doc[:members][:cfg][0][:meta][:required].should == true end end describe "member with @deprecated" do before do - @deprecated = parse(<<-EOS)[0][:attributes][:deprecated] + @deprecated = parse(<<-EOS)[0][:meta][:deprecated] /** * @deprecated 4.0 Use escapeRegex instead. */ @@ -131,7 +134,7 @@ describe JsDuck::Aggregator do describe "member with @deprecated without version number" do before do - @deprecated = parse(<<-EOS)[0][:attributes][:deprecated] + @deprecated = parse(<<-EOS)[0][:meta][:deprecated] /** * @deprecated Use escapeRegex instead. */ diff --git a/spec/aggregator_id_spec.rb b/spec/aggregator_id_spec.rb index 218702898c48872cb080c79ce08e85c671df8afd..37b067991f9bd00d8ff3e4574388b7c75e83bb44 100644 --- a/spec/aggregator_id_spec.rb +++ b/spec/aggregator_id_spec.rb @@ -2,10 +2,13 @@ require "jsduck/aggregator" require "jsduck/source_file" describe JsDuck::Aggregator do + before(:all) do + @opts = {:meta_tags => JsDuck::MetaTagLoader.new.meta_tags} + end def parse(string) agr = JsDuck::Aggregator.new - agr.aggregate(JsDuck::SourceFile.new(string)) + agr.aggregate(JsDuck::SourceFile.new(string, "", @opts)) agr.result end diff --git a/spec/aggregator_inheritdoc_spec.rb b/spec/aggregator_inheritdoc_spec.rb index 465c6e8458c344968d0b793348292126b6c4cc0c..226ede533b4b74d9094337a707a094c1e7714755 100644 --- a/spec/aggregator_inheritdoc_spec.rb +++ b/spec/aggregator_inheritdoc_spec.rb @@ -6,14 +6,14 @@ require "jsduck/inherit_doc" require "jsduck/logger" describe JsDuck::Aggregator do - - before do + before(:all) do + @opts = {:meta_tags => JsDuck::MetaTagLoader.new.meta_tags} JsDuck::Logger.instance.set_warning(:inheritdoc, false) end def parse(string) agr = JsDuck::Aggregator.new - agr.aggregate(JsDuck::SourceFile.new(string)) + agr.aggregate(JsDuck::SourceFile.new(string, "", @opts)) relations = JsDuck::Relations.new(agr.result.map {|cls| JsDuck::Class.new(cls) }) JsDuck::InheritDoc.new(relations).resolve_all relations diff --git a/spec/aggregator_static_spec.rb b/spec/aggregator_static_spec.rb index 241fe8c38b09b8bda4e932dcecadf0bc880e6b8f..9d4da62c3f885cf34c97f2ec9bdb5057a3fdf69d 100644 --- a/spec/aggregator_static_spec.rb +++ b/spec/aggregator_static_spec.rb @@ -1,11 +1,15 @@ require "jsduck/aggregator" require "jsduck/source_file" +require "jsduck/meta_tag_loader" describe JsDuck::Aggregator do + before(:all) do + @opts = {:meta_tags => JsDuck::MetaTagLoader.new.meta_tags} + end def parse(string) agr = JsDuck::Aggregator.new - agr.aggregate(JsDuck::SourceFile.new(string)) + agr.aggregate(JsDuck::SourceFile.new(string, "", @opts)) agr.result end @@ -21,7 +25,7 @@ describe JsDuck::Aggregator do end it "labels that method as static" do - @doc[:attributes][:static].should == true + @doc[:meta][:static].should == true end it "doesn't detect inheritable property" do @@ -42,7 +46,7 @@ describe JsDuck::Aggregator do end it "labels that method as static" do - @doc[:attributes][:static].should == true + @doc[:meta][:static].should == true end it "detects the @inheritable property" do diff --git a/spec/doc_formatter_spec.rb b/spec/doc_formatter_spec.rb index 4a6689eaa36ae91f60187e951c19d8640e255ad6..2282416577a6d1e6928b2cc7072bffb63c929bb7 100644 --- a/spec/doc_formatter_spec.rb +++ b/spec/doc_formatter_spec.rb @@ -239,10 +239,10 @@ describe JsDuck::DocFormatter do JsDuck::Class.new({ :name => 'Foo', :members => { - :method => [{:tagname => :method, :name => "select", :id => "method-select", :attributes => {}}], + :method => [{:tagname => :method, :name => "select", :id => "method-select", :meta => {}}], }, :statics => { - :method => [{:tagname => :method, :name => "select", :id => "static-method-select", :attributes => {:static => true}}], + :method => [{:tagname => :method, :name => "select", :id => "static-method-select", :meta => {:static => true}}], } }) ]) diff --git a/template/app/view/HoverMenu.js b/template/app/view/HoverMenu.js index 63c30fdd9980a311c6dda91fa2d8bc673c87a350..33ab9e174e660ac584044b92de7a97ab22b2a400 100644 --- a/template/app/view/HoverMenu.js +++ b/template/app/view/HoverMenu.js @@ -50,7 +50,7 @@ Ext.define('Docs.view.HoverMenu', { var url = values.url || values.cls; var label = values.label || values.cls; var tags = Ext.Array.map(Docs.data.signatureAttributes, function(tag) { - return values.attributes[tag.name] ? ''+(tag["short"])+'' : ''; + return values.meta[tag.name] ? ''+(tag["short"])+'' : ''; }).join(' '); return Ext.String.format('{1} {2}', url, label, tags); } diff --git a/template/app/view/cls/Toolbar.js b/template/app/view/cls/Toolbar.js index f691fc22a80a9cff76a3f584f72ab13e954b0bb3..7ada1e523049d2a9bef716f8655cc551ec7e728e 100644 --- a/template/app/view/cls/Toolbar.js +++ b/template/app/view/cls/Toolbar.js @@ -167,7 +167,7 @@ Ext.define('Docs.view.cls.Toolbar', { // creates store tha holds link records createStore: function(records) { var store = Ext.create('Ext.data.Store', { - fields: ['id', 'cls', 'url', 'label', 'inherited', 'attributes'] + fields: ['id', 'cls', 'url', 'label', 'inherited', 'meta'] }); store.add(records); return store; @@ -180,7 +180,7 @@ Ext.define('Docs.view.cls.Toolbar', { url: member ? (cls + "-" + member.id) : cls, label: member ? ((member.tagname === "method" && member.name === "constructor") ? "new "+cls : member.name) : cls, inherited: member ? member.owner !== cls : false, - attributes: member ? member.attributes : {} + meta: member ? member.meta : {} }; },