Loading lib/jsduck/parser.rb +14 −1 Original line number Diff line number Diff line Loading @@ -67,12 +67,15 @@ module JsDuck # The following is a recursive-descent parser for JavaScript that # can possibly follow a doc-comment # <code-block> := <function> | <var-declaration> | <assignment> | <property-literal> # <code-block> := <function> | <var-declaration> | <ext-define> | # <assignment> | <property-literal> def code_block if look("function") function elsif look("var") var_declaration elsif look("Ext", ".", "define", "(") ext_define elsif look(:ident, ":") || look(:string, ":") property_literal elsif look(",", :ident, ":") || look(",", :string, ":") Loading Loading @@ -175,6 +178,16 @@ module JsDuck } end # <ext-define> := "Ext" "." "define" "(" <string> "," ... def ext_define match("Ext", ".", "define", "(") return { :type => :function, :name => look(:string) ? match(:string) : nil, :params => [] } end # <property-literal> := ( <ident> | <string> ) ":" <expression> def property_literal left = look(:ident) ? match(:ident) : match(:string) Loading spec/aggregator_classes_spec.rb +7 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,13 @@ describe JsDuck::Aggregator do end end describe "Ext.define() in code" do before do @doc = parse("/** */ Ext.define('MyClass', { });")[0] end it_should_behave_like "class" end describe "class with cfgs" do before do @doc = parse(<<-EOS)[0] Loading Loading
lib/jsduck/parser.rb +14 −1 Original line number Diff line number Diff line Loading @@ -67,12 +67,15 @@ module JsDuck # The following is a recursive-descent parser for JavaScript that # can possibly follow a doc-comment # <code-block> := <function> | <var-declaration> | <assignment> | <property-literal> # <code-block> := <function> | <var-declaration> | <ext-define> | # <assignment> | <property-literal> def code_block if look("function") function elsif look("var") var_declaration elsif look("Ext", ".", "define", "(") ext_define elsif look(:ident, ":") || look(:string, ":") property_literal elsif look(",", :ident, ":") || look(",", :string, ":") Loading Loading @@ -175,6 +178,16 @@ module JsDuck } end # <ext-define> := "Ext" "." "define" "(" <string> "," ... def ext_define match("Ext", ".", "define", "(") return { :type => :function, :name => look(:string) ? match(:string) : nil, :params => [] } end # <property-literal> := ( <ident> | <string> ) ":" <expression> def property_literal left = look(:ident) ? match(:ident) : match(:string) Loading
spec/aggregator_classes_spec.rb +7 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,13 @@ describe JsDuck::Aggregator do end end describe "Ext.define() in code" do before do @doc = parse("/** */ Ext.define('MyClass', { });")[0] end it_should_behave_like "class" end describe "class with cfgs" do before do @doc = parse(<<-EOS)[0] Loading