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

Refactor #process_code to take just one param again.

Instead of modifying the passed-in hash, the method now creates
a hash by its own and returns it.
parent 5fcb3ac4
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -35,9 +35,7 @@ module JsDuck

    # Applies processing to extract fields relevant to the member type.
    def process_code(tagname, code)
      result = {}
      TagRegistry.get_by_name(tagname).process_code(result, code)
      result
      TagRegistry.get_by_name(tagname).process_code(code)
    end

    # Invokes the #merge methods of tags registered for the given
+3 −2
Original line number Diff line number Diff line
@@ -47,12 +47,13 @@ module JsDuck::Tag
      h[:name] = nested[:name]
    end

    def process_code(h, code)
      super(h, code)
    def process_code(code)
      h = super(code)
      h[:type] = code[:type]
      h[:default] = code[:default]
      h[:accessor] = code[:accessor]
      h[:evented] = code[:evented]
      h
    end

    def to_html(cfg, cls)
+3 −3
Original line number Diff line number Diff line
@@ -25,11 +25,11 @@ module JsDuck::Tag
    #
    # If we did detect code as a class use all the auto-detected
    # fields, otherwise use only the name field.
    def process_code(h, code)
    def process_code(code)
      if code[:tagname] == :class
        h.merge!(code)
        code
      else
        h[:name] = code[:name]
        {:name => code[:name] }
      end
    end

+3 −2
Original line number Diff line number Diff line
@@ -27,10 +27,11 @@ module JsDuck::Tag
      h[:default] = p[:default]
    end

    def process_code(h, code)
      super(h, code)
    def process_code(code)
      h = super(code)
      h[:type] = code[:type]
      h[:default] = code[:default]
      h
    end

    def to_html(var, cls)
+19 −16
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ module JsDuck::Tag
    MEMBER_POS_CSS_MIXIN = 6

    # Extracts the fields auto-detected from code that are relevant to
    # the member type and saves them to the context hash.
    # the member type and returns a hash with them.
    #
    # The implementation here extracts fields applicable to all member
    # types.  When additional member-specific fields are to be
@@ -67,24 +67,27 @@ module JsDuck::Tag
    # For example inside Method tag we might additionally want to
    # extract :type and :default:
    #
    #     def process_code(context, code)
    #       super(context, code)
    #       context[:type] = code[:type]
    #       context[:default] = code[:default]
    #     def process_code(code)
    #       h = super(code)
    #       h[:type] = code[:type]
    #       h[:default] = code[:default]
    #       h
    #     end
    #
    def process_code(context, code)
      context[:tagname] = code[:tagname]
    def process_code(code)
      return {
        :tagname => code[:tagname],
        # An auto-detected name might be "MyClass.prototype.myMethod" -
        # for member name we only want the last "myMethod" part.
      context[:name] = code[:name] ? code[:name].split(/\./).last : nil
        :name => code[:name] ? code[:name].split(/\./).last : nil,

      context[:autodetected] = code[:autodetected]
      context[:inheritdoc] = code[:inheritdoc]
      context[:static] = code[:static]
      context[:private] = code[:private]
      context[:inheritable] = code[:inheritable]
      context[:linenr] = code[:linenr]
        :autodetected => code[:autodetected],
        :inheritdoc => code[:inheritdoc],
        :static => code[:static],
        :private => code[:private],
        :inheritable => code[:inheritable],
        :linenr => code[:linenr],
      }
    end

    # This method defines the signature-line of the member.
Loading