Commit 61311a01 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Remove hard-coding of signature attributes.

List of attributes to show in signature is now kept in Class and
used by both front- and backend.
parent 14679f69
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ require 'jsduck/json_duck'
require 'jsduck/icons'
require 'jsduck/search_data'
require 'jsduck/stats'
require 'jsduck/class'

module JsDuck

@@ -25,6 +26,7 @@ module JsDuck
        :examples => @examples.to_array,
        :search => SearchData.new.create(@relations.classes),
        :stats => @opts.stats ? Stats.new.create(@relations.classes) : [],
        :signatureAttributes => Class.signature_attributes,
      }) + ";\n"
      File.open(filename, 'w') {|f| f.write(js) }
    end
+14 −0
Original line number Diff line number Diff line
@@ -255,6 +255,20 @@ module JsDuck
        :css_mixin => [],
      }
    end

    # Returns array of attributes to be shown in member signatures
    # (and in order they should be shown in).
    def self.signature_attributes
      return [
        :static,
        :protected,
        :deprecated,
        :required,
        :template,
        :abstract,
        :readonly,
      ]
    end
  end

end
+3 −20
Original line number Diff line number Diff line
require 'jsduck/class'
require 'cgi'

module JsDuck
@@ -221,26 +222,8 @@ module JsDuck
      end

      after = ""
      if m[:attributes][:protected]
        after += "<strong class='protected signature'>protected</strong>"
      end
      if m[:attributes][:static]
        after += "<strong class='static signature'>static</strong>"
      end
      if m[:attributes][:deprecated]
        after += "<strong class='deprecated signature'>deprecated</strong>"
      end
      if m[:attributes][:required]
        after += "<strong class='required signature'>required</strong>"
      end
      if m[:attributes][:template]
        after += "<strong class='template signature'>template</strong>"
      end
      if m[:attributes][:abstract]
        after += "<strong class='abstract signature'>abstract</strong>"
      end
      if m[:attributes][:readonly]
        after += "<strong class='readonly signature'>readonly</strong>"
      Class.signature_attributes.each do |attr|
        after += "<strong class='#{attr} signature'>#{attr}</strong>" if m[:attributes][attr]
      end

      uri = "#!/api/#{m[:owner]}-#{m[:id]}"
+2 −2
Original line number Diff line number Diff line
@@ -49,8 +49,8 @@ Ext.define('Docs.view.HoverMenu', {
                renderLink: function(values) {
                    var url = values.url || values.cls;
                    var label = values.label || values.cls;
                    var tags = Ext.Array.map(['static', 'protected', 'deprecated', 'template', 'required', 'abstract', 'readonly'], function(tag) {
                        return values[tag] ? '<span class="signature '+tag+'">'+tag+'</span>' : '';
                    var tags = Ext.Array.map(Docs.data.signatureAttributes, function(tag) {
                        return values.attributes[tag] ? '<span class="signature '+tag+'">'+tag+'</span>' : '';
                    }).join(' ');
                    return Ext.String.format('<a href="#!/api/{0}" rel="{0}" class="docClass">{1} {2}</a>', url, label, tags);
                }
+2 −8
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ Ext.define('Docs.view.cls.Toolbar', {
    // creates store tha holds link records
    createStore: function(records) {
        var store = Ext.create('Ext.data.Store', {
            fields: ['id', 'cls', 'url', 'label', 'inherited', 'static', 'deprecated', 'protected', 'abstract', 'template', 'readonly', 'required']
            fields: ['id', 'cls', 'url', 'label', 'inherited', 'attributes']
        });
        store.add(records);
        return store;
@@ -180,13 +180,7 @@ Ext.define('Docs.view.cls.Toolbar', {
            url: member ? (cls + "-" + member.id) : cls,
            label: member ? ((member.tagname === "method" && member.name === "constructor") ? "new "+cls : member.name) : cls,
            inherited: member ? member.owner !== cls : false,
            'static': member ? member.attributes['static'] : false,
            deprecated: member ? member.attributes['deprecated'] : false,
            'protected': member ? member.attributes['protected'] : false,
            'abstract': member ? member.attributes['abstract'] : false,
            template: member ? member.attributes['template'] : false,
            readonly: member ? member.attributes['readonly'] : false,
            required: member ? member.attributes['required'] : false
            attributes: member ? member.attributes : {}
        };
    },