Loading jsduck.rb +17 −2 Original line number Diff line number Diff line Loading @@ -102,9 +102,11 @@ module JsDuck # sets the name and properties of the default at-tag def set_default(tagname, attrs={}) if !@tags[tagname] then @tags[tagname] = attrs @tags[tagname][:doc] = @tags[:default][:doc] end end def [](tagname) @tags[tagname] Loading Loading @@ -133,6 +135,8 @@ module JsDuck at_return elsif look(/@param\b/) then at_param elsif look(/@function\b/) then at_function elsif look(/@/) then @current_tag[:doc] += @input.scan(/@/) elsif look(/[^@]/) then Loading Loading @@ -172,6 +176,17 @@ module JsDuck skip_white end # matches @return {type} ... def at_function match(/@function/) @current_tag = @tags[:function] = {:doc => ""} skip_white if look(/\w/) then @current_tag[:name] = ident end skip_white end # matches {...} and returns text inside brackets def typedef match(/\{/) Loading tc_jsduck.rb +25 −0 Original line number Diff line number Diff line Loading @@ -117,5 +117,30 @@ function foo() { ") assert_equal([], docs) end def test_explicit_function_doc docs = JsDuck.parse(" /** * @function hello * Just some function */ eval('hello = new Function();'); ") assert_equal("hello", docs[0][:function][:name]) assert_equal("Just some function", docs[0][:function][:doc]) end def test_explicit_function_doc_overrides_implicit_code docs = JsDuck.parse(" /** * @function hello * Just some function */ function goodby(){} ") assert_equal("hello", docs[0][:function][:name]) assert_equal("Just some function", docs[0][:function][:doc]) end end Loading
jsduck.rb +17 −2 Original line number Diff line number Diff line Loading @@ -102,9 +102,11 @@ module JsDuck # sets the name and properties of the default at-tag def set_default(tagname, attrs={}) if !@tags[tagname] then @tags[tagname] = attrs @tags[tagname][:doc] = @tags[:default][:doc] end end def [](tagname) @tags[tagname] Loading Loading @@ -133,6 +135,8 @@ module JsDuck at_return elsif look(/@param\b/) then at_param elsif look(/@function\b/) then at_function elsif look(/@/) then @current_tag[:doc] += @input.scan(/@/) elsif look(/[^@]/) then Loading Loading @@ -172,6 +176,17 @@ module JsDuck skip_white end # matches @return {type} ... def at_function match(/@function/) @current_tag = @tags[:function] = {:doc => ""} skip_white if look(/\w/) then @current_tag[:name] = ident end skip_white end # matches {...} and returns text inside brackets def typedef match(/\{/) Loading
tc_jsduck.rb +25 −0 Original line number Diff line number Diff line Loading @@ -117,5 +117,30 @@ function foo() { ") assert_equal([], docs) end def test_explicit_function_doc docs = JsDuck.parse(" /** * @function hello * Just some function */ eval('hello = new Function();'); ") assert_equal("hello", docs[0][:function][:name]) assert_equal("Just some function", docs[0][:function][:doc]) end def test_explicit_function_doc_overrides_implicit_code docs = JsDuck.parse(" /** * @function hello * Just some function */ function goodby(){} ") assert_equal("hello", docs[0][:function][:name]) assert_equal("Just some function", docs[0][:function][:doc]) end end