Commit 5fcb3ac4 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Change #process_code to take two params.

Instead of just returning the hash, process_code will now add fields
To the supplied context hash, with implementation in MemberTag covering
the base case and subclasses adding their extra logic on top of that.

Transformation of member name from "foo.bar.baz" to "baz" now
happens within MemberTag#process_code, while Class#process_code leaves
the name as is.

The #process_code now gets called for every time - both when the member
type was detected correctly and when it was not.
parent 40fe7098
Loading
Loading
Loading
Loading
+4 −11
Original line number Original line Diff line number Diff line
@@ -33,19 +33,12 @@ module JsDuck


    private
    private


    # When code was detected with the correct member type, leaves it
    # Applies processing to extract fields relevant to the member type.
    # as is, otherwise applies processing to extract fields relevant
    # to the member type
    def process_code(tagname, code)
    def process_code(tagname, code)
      if code[:tagname] == tagname
      result = {}
        code
      TagRegistry.get_by_name(tagname).process_code(result, code)
      else
        result = TagRegistry.get_by_name(tagname).process_code(code)
        result[:tagname] = code[:tagname]
        result[:autodetected] = code[:autodetected]
      result
      result
    end
    end
    end


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


    def process_code(code)
    def process_code(h, code)
      return {
      super(h, code)
        :name => code[:name],
      h[:type] = code[:type]
        :type => code[:type],
      h[:default] = code[:default]
        :default => code[:default],
      h[:accessor] = code[:accessor]
      }
      h[:evented] = code[:evented]
    end
    end


    def to_html(cfg, cls)
    def to_html(cfg, cls)
+10 −4
Original line number Original line Diff line number Diff line
@@ -21,10 +21,16 @@ module JsDuck::Tag
    end
    end


    # Although class is not a member, it also has the auto-detected
    # Although class is not a member, it also has the auto-detected
    # part from code.  So we need this method to say that when we
    # part from code. So this method gets called by Merger.
    # didn't detect code as a class, we only take the name from code.
    #
    def process_code(code)
    # If we did detect code as a class use all the auto-detected
      {:name => code[:name]}
    # fields, otherwise use only the name field.
    def process_code(h, code)
      if code[:tagname] == :class
        h.merge!(code)
      else
        h[:name] = code[:name]
      end
    end
    end


    # Ensure the empty members array.
    # Ensure the empty members array.
+1 −0
Original line number Original line Diff line number Diff line
@@ -7,6 +7,7 @@ module JsDuck::Tag
  # :css_mixin.
  # :css_mixin.
  class CssMixin < MemberTag
  class CssMixin < MemberTag
    def initialize
    def initialize
      @tagname = :css_mixin
      @member_type = {
      @member_type = {
        :name => :css_mixin,
        :name => :css_mixin,
        :category => :method_like,
        :category => :method_like,
+4 −6
Original line number Original line Diff line number Diff line
@@ -27,12 +27,10 @@ module JsDuck::Tag
      h[:default] = p[:default]
      h[:default] = p[:default]
    end
    end


    def process_code(code)
    def process_code(h, code)
      return {
      super(h, code)
        :name => code[:name],
      h[:type] = code[:type]
        :type => code[:type],
      h[:default] = code[:default]
        :default => code[:default],
      }
    end
    end


    def to_html(var, cls)
    def to_html(var, cls)
Loading