Commit 685665d9 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Detect multiple code-less doc-comments in SCSS.

parent a45ef030
Loading
Loading
Loading
Loading
+15 −16
Original line number Diff line number Diff line
@@ -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
+14 −0
Original line number Diff line number Diff line
@@ -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