Loading lib/jsduck/tag/deprecated.rb→lib/jsduck/builtins/deprecated.rb +36 −0 Original line number Diff line number Diff line require "jsduck/meta_tag" require "jsduck/builtins/tag" module JsDuck::Tag # Implementation of @deprecated tag class Deprecated < JsDuck::MetaTag module JsDuck::Builtins class Deprecated < Tag def initialize @name = "deprecated" @pattern = "deprecated" @key = :deprecated @signature = {:long => "deprecated", :short => "DEP"} @html_position = :bottom @multiline = true end def to_value(contents) text = contents[0] if text =~ /\A([0-9.]+)(.*)\Z/ {:version => $1, :text => $2.strip} else {:text => text || ""} def parse(p) p.add_tag(:deprecated) p.skip_horiz_white p.current_tag[:version] = p.match(/[0-9.]+/) if p.look(/[0-9]/) end def process_doc(tags) v = {:text => tags[0][:doc] || ""} v[:version] = tags[0][:version] if tags[0][:version] v end def to_html(depr) def to_html(depr, formatter) v = depr[:version] ? "since " + depr[:version] : "" <<-EOHTML <div class='signature-box deprecated'> <p>This #{@context[:tagname]} has been <strong>deprecated</strong> #{v}</p> #{format(depr[:text])} #{formatter.format(depr[:text])} </div> EOHTML end end end lib/jsduck/builtins/tag.rb +6 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,10 @@ module JsDuck::Builtins # For example: "cfg" attr_reader :pattern # True to include all lines up to next @tag as part of this tag's # :doc property. attr_reader :multiline # Called by DocParser when the @tag is reached to do the parsing # from that point forward. Gets passed an instance of DocParser. def parse(p) Loading Loading @@ -62,6 +66,8 @@ module JsDuck::Builtins def to_html(data, formatter) end attr_accessor :context # Returns all descendants of JsDuck::Builtins::Tag class. def self.descendants result = [] Loading lib/jsduck/builtins_registry.rb +7 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ module JsDuck def initialize @patterns = {} @multiliners = [] @ext_define_patterns = {} @ext_define_defaults = {} @keys = {} Loading @@ -30,6 +31,9 @@ module JsDuck Array(tag.pattern).each do |pattern| @patterns[pattern] = tag end if tag.multiline @multiliners << tag end Array(tag.ext_define_pattern).each do |pattern| @ext_define_patterns[pattern] = tag end Loading @@ -54,6 +58,9 @@ module JsDuck @patterns[name] end # Returns all multiline tags. attr_reader :multiliners # Accesses tag by Ext.define pattern def get_ext_define(name) @ext_define_patterns[name] Loading lib/jsduck/class_formatter.rb +1 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ module JsDuck result = {} BuiltinsRegistry.get_html_renderers.each do |tag| if context[tag.key] tag.context = context result[tag.key] = tag.to_html(context[tag.key], @formatter) end end Loading lib/jsduck/doc_ast.rb +1 −1 Original line number Diff line number Diff line Loading @@ -289,7 +289,7 @@ module JsDuck # Combines :doc-s of most tags # Ignores tags that have doc comment themselves and subproperty tags def detect_doc(docs) ignore_tags = [:param, :return, :throws, :meta] ignore_tags = [:param, :return, :throws, :meta] + BuiltinsRegistry.multiliners.map {|t| t.key } doc_tags = docs.find_all { |tag| !ignore_tags.include?(tag[:tagname]) && !subproperty?(tag) } doc_tags.map { |tag| tag[:doc] }.compact.join(" ") end Loading Loading
lib/jsduck/tag/deprecated.rb→lib/jsduck/builtins/deprecated.rb +36 −0 Original line number Diff line number Diff line require "jsduck/meta_tag" require "jsduck/builtins/tag" module JsDuck::Tag # Implementation of @deprecated tag class Deprecated < JsDuck::MetaTag module JsDuck::Builtins class Deprecated < Tag def initialize @name = "deprecated" @pattern = "deprecated" @key = :deprecated @signature = {:long => "deprecated", :short => "DEP"} @html_position = :bottom @multiline = true end def to_value(contents) text = contents[0] if text =~ /\A([0-9.]+)(.*)\Z/ {:version => $1, :text => $2.strip} else {:text => text || ""} def parse(p) p.add_tag(:deprecated) p.skip_horiz_white p.current_tag[:version] = p.match(/[0-9.]+/) if p.look(/[0-9]/) end def process_doc(tags) v = {:text => tags[0][:doc] || ""} v[:version] = tags[0][:version] if tags[0][:version] v end def to_html(depr) def to_html(depr, formatter) v = depr[:version] ? "since " + depr[:version] : "" <<-EOHTML <div class='signature-box deprecated'> <p>This #{@context[:tagname]} has been <strong>deprecated</strong> #{v}</p> #{format(depr[:text])} #{formatter.format(depr[:text])} </div> EOHTML end end end
lib/jsduck/builtins/tag.rb +6 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,10 @@ module JsDuck::Builtins # For example: "cfg" attr_reader :pattern # True to include all lines up to next @tag as part of this tag's # :doc property. attr_reader :multiline # Called by DocParser when the @tag is reached to do the parsing # from that point forward. Gets passed an instance of DocParser. def parse(p) Loading Loading @@ -62,6 +66,8 @@ module JsDuck::Builtins def to_html(data, formatter) end attr_accessor :context # Returns all descendants of JsDuck::Builtins::Tag class. def self.descendants result = [] Loading
lib/jsduck/builtins_registry.rb +7 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ module JsDuck def initialize @patterns = {} @multiliners = [] @ext_define_patterns = {} @ext_define_defaults = {} @keys = {} Loading @@ -30,6 +31,9 @@ module JsDuck Array(tag.pattern).each do |pattern| @patterns[pattern] = tag end if tag.multiline @multiliners << tag end Array(tag.ext_define_pattern).each do |pattern| @ext_define_patterns[pattern] = tag end Loading @@ -54,6 +58,9 @@ module JsDuck @patterns[name] end # Returns all multiline tags. attr_reader :multiliners # Accesses tag by Ext.define pattern def get_ext_define(name) @ext_define_patterns[name] Loading
lib/jsduck/class_formatter.rb +1 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ module JsDuck result = {} BuiltinsRegistry.get_html_renderers.each do |tag| if context[tag.key] tag.context = context result[tag.key] = tag.to_html(context[tag.key], @formatter) end end Loading
lib/jsduck/doc_ast.rb +1 −1 Original line number Diff line number Diff line Loading @@ -289,7 +289,7 @@ module JsDuck # Combines :doc-s of most tags # Ignores tags that have doc comment themselves and subproperty tags def detect_doc(docs) ignore_tags = [:param, :return, :throws, :meta] ignore_tags = [:param, :return, :throws, :meta] + BuiltinsRegistry.multiliners.map {|t| t.key } doc_tags = docs.find_all { |tag| !ignore_tags.include?(tag[:tagname]) && !subproperty?(tag) } doc_tags.map { |tag| tag[:doc] }.compact.join(" ") end Loading