Commit ea8ebe9f authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Allow dash in identifier names in doc-comments.

One can now write: @cfg foo-bar

Further more, the DocParser no more differenciates between CSS and JS
identifiers, using the same pattern for both.
parent fe073d7a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ module JsDuck
  class CssParser
    def initialize(input, options = {})
      @lex = Lexer.new(input)
      @doc_parser = DocParser.new(:css)
      @doc_parser = DocParser.new
      @docs = []
    end

+3 −4
Original line number Diff line number Diff line
@@ -24,10 +24,9 @@ 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) ? /\$?[\w-]+/ : /[$\w]\w*/
      @ident_chain_pattern = (mode == :css) ? /\$?[\w-]+(\.[\w-]+)*/ : /[$\w]\w*(\.\w+)*/
    def initialize
      @ident_pattern = /[$\w-]+/
      @ident_chain_pattern = /[$\w-]+(\.[$\w-]+)*/
      @meta_tags = MetaTagRegistry.instance
    end

+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ module JsDuck
  class JsParser < JsLiteralParser
    def initialize(input, options = {})
      super(input)
      @doc_parser = DocParser.new(:js)
      @doc_parser = DocParser.new
      @docs = []
      @ext_namespaces = options[:ext_namespaces] || ["Ext"]
    end
+14 −0
Original line number Diff line number Diff line
@@ -130,6 +130,20 @@ describe JsDuck::Aggregator do
    it_should_behave_like "cfg or property default type"
  end

  describe "@cfg with dash in name" do
    before do
      @doc = parse(<<-EOS)[0]
        /**
         * @cfg {String} foo-bar
         * Some documentation.
         */
      EOS
    end
    it "detects the name" do
      @doc[:name].should == "foo-bar"
    end
  end

  shared_examples_for "auto type" do
    it "should imply correct type" do
      @doc[:type].should == @type