Commit 7d2f17d9 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Skip implicit parameters if explicit ones exist.

For example with code like this:

    /**
     * My Function
     * @param {Number} foo
     */
    function blah(foo, bar) {
    }

The previous behaviour of JSDuck was to include both parameters
to documentation.  After this change only the first parameter
will be documented, allowing us to easily have hidden parameters
for internal use, which is quite common in ExtJS.
parent 095b088d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -304,8 +304,9 @@ module JsDuck
      implicit = detect_implicit_params(code)
      explicit = detect_explicit_params(docs)
      # Override implicit parameters with explicit ones
      # But if explicit ones exist, don't append the implicit ones.
      params = []
      [implicit.length, explicit.length].max.times do |i|
      (explicit.length > 0 ? explicit.length : implicit.length).times do |i|
        im = implicit[i] || {}
        ex = explicit[i] || {}
        doc = ex[:doc] || im[:doc] || ""
+2 −1
Original line number Diff line number Diff line
@@ -211,8 +211,9 @@ describe JsDuck::Aggregator do
        /**
         * Some function
         * @param {String} x
         * @param {Number} y
         */
        function foo(q, y) {}
        function foo(q, v, z) {}
      EOS
    end
    it_should_behave_like "method documentation"