Loading lib/jsduck/doc_formatter.rb +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ module JsDuck # command line. For the actual effect of the options see # Inline::* classes. def initialize(opts={}) @opts = opts @inline_link = Inline::Link.new(opts) @inline_img = Inline::Img.new(opts) @inline_video = Inline::Video.new(opts) Loading Loading @@ -100,7 +101,7 @@ module JsDuck # Keep track of open HTML tags. We're not auto-detecting class # names when inside <a>. Also we want to close down the unclosed # tags. tags = HtmlStack.new(@doc_context) tags = HtmlStack.new(@opts[:ignore_html] || {}, @doc_context) while !s.eos? do if substitute = @inline_link.replace(s) Loading lib/jsduck/html_stack.rb +11 −2 Original line number Diff line number Diff line Loading @@ -18,14 +18,19 @@ module JsDuck # class HtmlStack def initialize(doc_context={}) # Initializes the stack with two optional parameters: # # @param ignore_html A hash of additional HTML tags that don't need closing. # @param doc_context Filename and linenr of the current doc-comment. def initialize(ignore_html={}, doc_context={}) @ignore_html = ignore_html @doc_context = doc_context @open_tags = [] end # Registers opening of a tag. Returns the tag. def open(tag) @open_tags.unshift(tag) unless VOID_TAGS[tag] @open_tags.unshift(tag) unless void?(tag) tag end Loading Loading @@ -61,6 +66,10 @@ module JsDuck Logger.warn(:html, "Unclosed HTML tag: #{tag_list}", ctx[:filename], ctx[:linenr]) end def void?(tag) VOID_TAGS[tag] || @ignore_html[tag] end # Tags that don't require closing VOID_TAGS = { "base" => true, Loading lib/jsduck/options.rb +17 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ module JsDuck attr_accessor :tests attr_accessor :comments_url attr_accessor :comments_domain attr_accessor :ignore_html # Debugging attr_accessor :template_dir Loading Loading @@ -116,6 +117,7 @@ module JsDuck @tests = false @comments_url = nil @comments_domain = nil @ignore_html = {} # Debugging @root_dir = File.dirname(File.dirname(File.dirname(__FILE__))) Loading Loading @@ -539,6 +541,21 @@ module JsDuck @touch_examples_ui = true end opts.on('--ignore-html=TAG', "Ignore a particular unclosed HTML tag.", "", "Normally all tags like <foo> that aren't followed at some", "point with </foo> will get automatically closed by JSDuck", "and a warning will be generated. Except standard void tags", "like <img> and <br>. Use this option to specify additional", "tags not requirering a closing tag.", "", "Useful for ignoring the ExtJS preprocessor directives", "<locale> and <debug> which would otherwise be reported", "as unclosed tags.") do |tag| @ignore_html[tag] = true end opts.separator "" opts.separator "Debugging:" opts.separator "" Loading Loading
lib/jsduck/doc_formatter.rb +2 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ module JsDuck # command line. For the actual effect of the options see # Inline::* classes. def initialize(opts={}) @opts = opts @inline_link = Inline::Link.new(opts) @inline_img = Inline::Img.new(opts) @inline_video = Inline::Video.new(opts) Loading Loading @@ -100,7 +101,7 @@ module JsDuck # Keep track of open HTML tags. We're not auto-detecting class # names when inside <a>. Also we want to close down the unclosed # tags. tags = HtmlStack.new(@doc_context) tags = HtmlStack.new(@opts[:ignore_html] || {}, @doc_context) while !s.eos? do if substitute = @inline_link.replace(s) Loading
lib/jsduck/html_stack.rb +11 −2 Original line number Diff line number Diff line Loading @@ -18,14 +18,19 @@ module JsDuck # class HtmlStack def initialize(doc_context={}) # Initializes the stack with two optional parameters: # # @param ignore_html A hash of additional HTML tags that don't need closing. # @param doc_context Filename and linenr of the current doc-comment. def initialize(ignore_html={}, doc_context={}) @ignore_html = ignore_html @doc_context = doc_context @open_tags = [] end # Registers opening of a tag. Returns the tag. def open(tag) @open_tags.unshift(tag) unless VOID_TAGS[tag] @open_tags.unshift(tag) unless void?(tag) tag end Loading Loading @@ -61,6 +66,10 @@ module JsDuck Logger.warn(:html, "Unclosed HTML tag: #{tag_list}", ctx[:filename], ctx[:linenr]) end def void?(tag) VOID_TAGS[tag] || @ignore_html[tag] end # Tags that don't require closing VOID_TAGS = { "base" => true, Loading
lib/jsduck/options.rb +17 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ module JsDuck attr_accessor :tests attr_accessor :comments_url attr_accessor :comments_domain attr_accessor :ignore_html # Debugging attr_accessor :template_dir Loading Loading @@ -116,6 +117,7 @@ module JsDuck @tests = false @comments_url = nil @comments_domain = nil @ignore_html = {} # Debugging @root_dir = File.dirname(File.dirname(File.dirname(__FILE__))) Loading Loading @@ -539,6 +541,21 @@ module JsDuck @touch_examples_ui = true end opts.on('--ignore-html=TAG', "Ignore a particular unclosed HTML tag.", "", "Normally all tags like <foo> that aren't followed at some", "point with </foo> will get automatically closed by JSDuck", "and a warning will be generated. Except standard void tags", "like <img> and <br>. Use this option to specify additional", "tags not requirering a closing tag.", "", "Useful for ignoring the ExtJS preprocessor directives", "<locale> and <debug> which would otherwise be reported", "as unclosed tags.") do |tag| @ignore_html[tag] = true end opts.separator "" opts.separator "Debugging:" opts.separator "" Loading