Loading lib/jsduck/css/sass_parser.rb +15 −16 Original line number Diff line number Diff line Loading @@ -26,34 +26,33 @@ module JsDuck prev_comment = nil nodes.each do |node| if prev_comment @docs << make_docset(prev_comment, node) prev_comment = nil end if node.class == Sass::Tree::CommentNode if node.type == :normal && node.value[0] =~ /\A\/\*\*/ prev_comment = node else prev_comment = nil end elsif prev_comment @docs << { :comment => prev_comment.value[0], :linenr => prev_comment.line, :code => analyze_code(node), :type => :doc_comment, } prev_comment = nil end find_doc_comments(node.children) end if prev_comment @docs << { @docs << make_docset(prev_comment) end end def make_docset(prev_comment, node=nil) return { :comment => prev_comment.value[0], :linenr => prev_comment.line, :code => {:tagname => :property}, :code => analyze_code(node), :type => :doc_comment, } end end def analyze_code(node) if node.class == Sass::Tree::VariableNode Loading spec/css_sass_parser_spec.rb +14 −0 Original line number Diff line number Diff line Loading @@ -168,4 +168,18 @@ describe JsDuck::Css::SassParser do end end describe "parsing doc-comments without any SCSS code afterwards" do let(:docs) do parse(<<-EOCSS) /** My docs #1 */ /** My docs #2 */ EOCSS end it "detects two docsets" do docs.length.should == 2 end end end Loading
lib/jsduck/css/sass_parser.rb +15 −16 Original line number Diff line number Diff line Loading @@ -26,34 +26,33 @@ module JsDuck prev_comment = nil nodes.each do |node| if prev_comment @docs << make_docset(prev_comment, node) prev_comment = nil end if node.class == Sass::Tree::CommentNode if node.type == :normal && node.value[0] =~ /\A\/\*\*/ prev_comment = node else prev_comment = nil end elsif prev_comment @docs << { :comment => prev_comment.value[0], :linenr => prev_comment.line, :code => analyze_code(node), :type => :doc_comment, } prev_comment = nil end find_doc_comments(node.children) end if prev_comment @docs << { @docs << make_docset(prev_comment) end end def make_docset(prev_comment, node=nil) return { :comment => prev_comment.value[0], :linenr => prev_comment.line, :code => {:tagname => :property}, :code => analyze_code(node), :type => :doc_comment, } end end def analyze_code(node) if node.class == Sass::Tree::VariableNode Loading
spec/css_sass_parser_spec.rb +14 −0 Original line number Diff line number Diff line Loading @@ -168,4 +168,18 @@ describe JsDuck::Css::SassParser do end end describe "parsing doc-comments without any SCSS code afterwards" do let(:docs) do parse(<<-EOCSS) /** My docs #1 */ /** My docs #2 */ EOCSS end it "detects two docsets" do docs.length.should == 2 end end end