Loading lib/jsduck/css_parser.rb +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ module JsDuck class CssParser def initialize(input) @lex = Lexer.new(input) @doc_parser = DocParser.new @doc_parser = DocParser.new(:css) @docs = [] end Loading lib/jsduck/doc_parser.rb +9 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,11 @@ module JsDuck # @see and {@link} are parsed separately in JsDuck::DocFormatter. # class DocParser # Pass in :css to be able to parse CSS doc-comments def initialize(mode = :js) @ident_pattern = (mode == :css) ? /\$[a-zA-Z0-9_-]*/ : /\w+/ end def parse(input) @tags = [] @input = StringScanner.new(purify(input)) Loading Loading @@ -186,7 +191,7 @@ module JsDuck match(/@var/) add_tag(:css_var) maybe_type maybe_name(/\$[a-zA-Z0-9_-]*/) maybe_name skip_white end Loading Loading @@ -248,10 +253,10 @@ module JsDuck end # matches identifier name if possible and sets it on @current_tag def maybe_name(pattern = /\w+/) def maybe_name skip_horiz_white if look(pattern) @current_tag[:name] = @input.scan(pattern) if look(@ident_pattern) @current_tag[:name] = @input.scan(@ident_pattern) end end Loading lib/jsduck/merger.rb +1 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,7 @@ module JsDuck :name => detect_name(:css_mixin, doc_map, code), :member => detect_member(doc_map), :doc => detect_doc(docs), :params => detect_params(docs, code), :private => !!doc_map[:private], :static => !!doc_map[:static], } Loading spec/aggregator_css_spec.rb +15 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,9 @@ describe JsDuck::Aggregator do @doc = parse(<<-EOCSS)[0] /** * Creates an awesome button. * * @param {string} $ui-label The name of the UI being created. * @param {color} $color Base color for the UI. */ @mixin my-button { } Loading @@ -57,6 +60,18 @@ describe JsDuck::Aggregator do it "detects mixin description" do @doc[:doc].should == "Creates an awesome button." end it "detects mixin parameters" do @doc[:params].length.should == 2 end it "detects mixin param name" do @doc[:params][0][:name].should == "$ui-label" end it "detects mixin param type" do @doc[:params][0][:type].should == "string" end it "detects mixin param description" do @doc[:params][0][:doc].should == "The name of the UI being created." end end end Loading Loading
lib/jsduck/css_parser.rb +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ module JsDuck class CssParser def initialize(input) @lex = Lexer.new(input) @doc_parser = DocParser.new @doc_parser = DocParser.new(:css) @docs = [] end Loading
lib/jsduck/doc_parser.rb +9 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,11 @@ module JsDuck # @see and {@link} are parsed separately in JsDuck::DocFormatter. # class DocParser # Pass in :css to be able to parse CSS doc-comments def initialize(mode = :js) @ident_pattern = (mode == :css) ? /\$[a-zA-Z0-9_-]*/ : /\w+/ end def parse(input) @tags = [] @input = StringScanner.new(purify(input)) Loading Loading @@ -186,7 +191,7 @@ module JsDuck match(/@var/) add_tag(:css_var) maybe_type maybe_name(/\$[a-zA-Z0-9_-]*/) maybe_name skip_white end Loading Loading @@ -248,10 +253,10 @@ module JsDuck end # matches identifier name if possible and sets it on @current_tag def maybe_name(pattern = /\w+/) def maybe_name skip_horiz_white if look(pattern) @current_tag[:name] = @input.scan(pattern) if look(@ident_pattern) @current_tag[:name] = @input.scan(@ident_pattern) end end Loading
lib/jsduck/merger.rb +1 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,7 @@ module JsDuck :name => detect_name(:css_mixin, doc_map, code), :member => detect_member(doc_map), :doc => detect_doc(docs), :params => detect_params(docs, code), :private => !!doc_map[:private], :static => !!doc_map[:static], } Loading
spec/aggregator_css_spec.rb +15 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,9 @@ describe JsDuck::Aggregator do @doc = parse(<<-EOCSS)[0] /** * Creates an awesome button. * * @param {string} $ui-label The name of the UI being created. * @param {color} $color Base color for the UI. */ @mixin my-button { } Loading @@ -57,6 +60,18 @@ describe JsDuck::Aggregator do it "detects mixin description" do @doc[:doc].should == "Creates an awesome button." end it "detects mixin parameters" do @doc[:params].length.should == 2 end it "detects mixin param name" do @doc[:params][0][:name].should == "$ui-label" end it "detects mixin param type" do @doc[:params][0][:type].should == "string" end it "detects mixin param description" do @doc[:params][0][:doc].should == "The name of the UI being created." end end end Loading