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

Ability to show/hide private members.

A bit experimental for now, but seems to work well.

:private is injected to :meta hash when data is exported for use in Docs app.
Inside there it's treated as just another meta-tag.
parent de986bec
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ module JsDuck
          :examples => @examples.to_array,
          :search => SearchData.new.create(@relations.classes),
          :stats => @opts.stats ? Stats.new.create(@relations.classes) : [],
          :signatures => MetaTagRegistry.instance.signatures,
          :signatures => signatures,
          :localStorageDb => @opts.local_storage_db,
          :showPrintButton => @opts.seo,
          :touchExamplesUi => @opts.touch_examples_ui,
@@ -36,6 +36,13 @@ module JsDuck
      File.open(filename, 'w') {|f| f.write(js) }
    end

    def signatures
      sigs = MetaTagRegistry.instance.signatures
      # Inject private to meta tag signatures list
      sigs << {:key => 'private', :long => 'private', :short => 'PRI'}
      sigs
    end

  end

end
+2 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ module JsDuck
      [:name, :tagname, :owner, :meta, :id].each do |key|
        m_copy[key] = m[key]
      end
      # Inject :private to meta.
      m_copy[:meta][:private] = true if m[:private]
      m_copy
    end

+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ module JsDuck
    #
    # See members_hash for details.
    def members(type, context=:members)
      ms = members_hash(type, context).values.find_all {|m| !m[:private] }
      ms = members_hash(type, context).values #.find_all {|m| !m[:private] }
      ms.sort! {|a,b| a[:name] <=> b[:name] }
      type == :method ? constructor_first(ms) : ms
    end
+3 −6
Original line number Diff line number Diff line
@@ -5,8 +5,7 @@ require 'jsduck/meta_tag_registry'
module JsDuck

  # Converts :doc properties of class from markdown to HTML, resolves
  # @links, and converts type definitions to HTML.  Also removes
  # private members.
  # @links, and converts type definitions to HTML.
  class ClassFormatter
    # Set to false to disable HTML-formatting of type definitions.
    attr_accessor :include_types
@@ -28,10 +27,8 @@ module JsDuck
      cls[:doc] = @formatter.format(cls[:doc]) if cls[:doc]
      [:members, :statics].each do |group|
        cls[group].each_pair do |type, members|
          # format all public members, but keep the private members
          # too - some of them might override public members and we
          # don't want to lose this information.
          cls[group][type] = members.map {|m| m[:private] ? m : format_member(m)  }
          # format all members
          cls[group][type] = members.map {|m| format_member(m) }
        end
      end
      cls[:html_meta] = format_meta_data(cls[:meta])
+2 −0
Original line number Diff line number Diff line
@@ -217,6 +217,8 @@ module JsDuck
      MetaTagRegistry.instance.signatures.each do |s|
        after += "<strong class='#{s[:key]} signature'>#{s[:long]}</strong>" if m[:meta][s[:key]]
      end
      # Special case for :private which isn't inside :meta.
      after += "<strong class='private signature'>private</strong>" if m[:private]

      uri = "#!/api/#{m[:owner]}-#{m[:id]}"

Loading