Commit 7935a409 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Turn @private tag from MetaTag to Builtin.

Builtins::Tag now supports the @signature attribute like MetaTag.
For now the signature logic is duplicated as both tag groups support it.

In search data and class data export the data for builtin tags is
added to :meta field, so the frontend logic can stay the same.

On the good side, @private no more needs to be duplicated in both
member[:private] and member[:meta][:private] - just the former will do.
parent b5a74aac
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
require 'jsduck/util/json'
require 'jsduck/icons'
require 'jsduck/search_data'
require 'jsduck/builtins_registry'
require 'jsduck/meta_tag_registry'

module JsDuck
@@ -23,7 +24,7 @@ module JsDuck
          :examples => @assets.examples.to_array,
          :search => SearchData.new.create(@relations.classes, @assets),
          :tests => @opts.tests,
          :signatures => MetaTagRegistry.instance.signatures,
          :signatures => BuiltinsRegistry.signatures + MetaTagRegistry.instance.signatures,
          :localStorageDb => @opts.local_storage_db,
          :showPrintButton => @opts.seo,
          :touchExamplesUi => @opts.touch_examples_ui,
+11 −0
Original line number Diff line number Diff line
require "jsduck/builtins/boolean_tag"

module JsDuck::Builtins
  class Private < BooleanTag
    def initialize
      @key = :private
      @signature = {:long => "private", :short => "PRI"}
      super
    end
  end
end
+9 −0
Original line number Diff line number Diff line
@@ -21,6 +21,15 @@ module JsDuck::Builtins
    def process_doc(docs)
    end

    # The text to display in member signature.  Must be a hash
    # defining the short and long versions of the signature text:
    #
    #     {:long => "something", :short => "SOM"}
    #
    # Additionally the hash can contain a :tooltip which is the text
    # to be shown when the signature bubble is hovered over in docs.
    attr_reader :signature

    # Defines the name of object property in Ext.define()
    # configuration which, when encountered, will cause the
    # #parse_ext_define method to be invoked.
+9 −0
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ module JsDuck
      @ext_define_patterns = {}
      @ext_define_defaults = {}
      @keys = {}
      @signatures = []
      load_tag_classes(File.dirname(__FILE__) + "/builtins")
      instantiate_tags
    end
@@ -37,6 +38,10 @@ module JsDuck
        if tag.key
          @keys[tag.key] = tag
        end
        if tag.signature
          tag.signature[:key] = tag.key
          @signatures << tag.signature
        end
      end
    end

@@ -58,6 +63,10 @@ module JsDuck
    def get_by_key(key)
      @keys[key]
    end

    # Array of attributes to be shown in member signatures
    # (and in order they should be shown in).
    attr_reader :signatures
  end

end
+23 −0
Original line number Diff line number Diff line
require 'jsduck/builtins_registry'

module JsDuck

  # Performs the rendering of builtin tags (for now just the signature data).
  class BuiltinsRenderer

    # Renders the signatures for a class member.
    # Returns a string.
    def self.render_signature(member)
      html = []
      BuiltinsRegistry.signatures.each do |s|
        if member[s[:key]]
          title = s[:tooltip] ? "title='#{s[:tooltip]}'" : ""
          html << "<strong class='#{s[:key]} signature' #{title}>#{s[:long]}</strong>"
        end
      end
      html.join
    end

  end

end
Loading