Loading lib/jsduck/app.rb +18 −11 Original line number Diff line number Diff line Loading @@ -110,26 +110,33 @@ module JsDuck agr.aggregate(file) end agr.classify_orphans agr.create_global_class unless @opts.ignore_global agr.create_global_class agr.create_accessors agr.append_ext4_event_options agr.result end # Filters out class-documentations, converting them to Class objects. # For each other type, prints a warning message and discards it # Turns all aggregated data into Class objects. # Depending on --ignore-global either keeps or discards the global class. # Warnings for global members are printed regardless of that setting, # but of course can be turned off using --warnings=-global def filter_classes(docs) classes = [] docs.each do |d| if d[:tagname] == :class classes << Class.new(d) cls = Class.new(d) if d[:name] != "global" classes << cls else type = d[:tagname].to_s name = d[:name] file = d[:files][0] # This warning is shown when there are orphaned members, # but the creation of global class has been turned off. Logger.instance.warn(:global, "Ignoring #{type}: #{name}", file[:filename], file[:linenr]) # add global class only if --ignore-global not specified classes << cls unless @opts.ignore_global # Print warning for each global member cls.all_local_members.each do |m| type = m[:tagname].to_s name = m[:name] file = m[:files][0] Logger.instance.warn(:global, "Global #{type}: #{name}", file[:filename], file[:linenr]) end end end Relations.new(classes, @opts.external_classes) Loading lib/jsduck/app_data.rb +8 −1 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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 lib/jsduck/app_exporter.rb +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading lib/jsduck/class.rb +10 −10 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -121,28 +121,28 @@ module JsDuck return {} end all_members = parent ? parent.members_hash(type, context) : {} ms = parent ? parent.members_hash(type, context) : {} mixins.each do |mix| all_members.merge!(mix.members_hash(type, context)) {|k,o,n| store_overrides(k,o,n)} ms.merge!(mix.members_hash(type, context)) {|k,o,n| store_overrides(k,o,n)} end # For static members, exclude everything not explicitly marked as inheritable if context == :statics all_members.delete_if {|key, member| !member[:inheritable] } ms.delete_if {|key, member| !member[:inheritable] } end all_members.merge!(local_members_hash(type, context)) {|k,o,n| store_overrides(k,o,n)} ms.merge!(local_members_hash(type, context)) {|k,o,n| store_overrides(k,o,n)} # If singleton has static members, include them as if they were # instance members. Otherwise they will be completely excluded # from the docs, as the static members block is not created for # singletons. if @doc[:singleton] && @doc[:statics][type].length > 0 all_members.merge!(local_members_hash(type, :statics)) {|k,o,n| store_overrides(k,o,n)} ms.merge!(local_members_hash(type, :statics)) {|k,o,n| store_overrides(k,o,n)} end all_members ms end # Invoked when merge! finds two members with the same name. Loading Loading @@ -197,7 +197,7 @@ module JsDuck return ms end # Returns all public members of class, including the inherited and mixed in ones # Returns all members of class, including the inherited and mixed in ones def all_members all = [] [:members, :statics].each do |group| Loading @@ -208,12 +208,12 @@ module JsDuck all end # Returns all local public members of class # Returns all local members of class def all_local_members all = [] [:members, :statics].each do |group| @doc[group].each_value do |ms| all += ms.find_all {|m| !m[:private] } all += ms end end all Loading lib/jsduck/class_formatter.rb +3 −6 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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]) Loading Loading
lib/jsduck/app.rb +18 −11 Original line number Diff line number Diff line Loading @@ -110,26 +110,33 @@ module JsDuck agr.aggregate(file) end agr.classify_orphans agr.create_global_class unless @opts.ignore_global agr.create_global_class agr.create_accessors agr.append_ext4_event_options agr.result end # Filters out class-documentations, converting them to Class objects. # For each other type, prints a warning message and discards it # Turns all aggregated data into Class objects. # Depending on --ignore-global either keeps or discards the global class. # Warnings for global members are printed regardless of that setting, # but of course can be turned off using --warnings=-global def filter_classes(docs) classes = [] docs.each do |d| if d[:tagname] == :class classes << Class.new(d) cls = Class.new(d) if d[:name] != "global" classes << cls else type = d[:tagname].to_s name = d[:name] file = d[:files][0] # This warning is shown when there are orphaned members, # but the creation of global class has been turned off. Logger.instance.warn(:global, "Ignoring #{type}: #{name}", file[:filename], file[:linenr]) # add global class only if --ignore-global not specified classes << cls unless @opts.ignore_global # Print warning for each global member cls.all_local_members.each do |m| type = m[:tagname].to_s name = m[:name] file = m[:files][0] Logger.instance.warn(:global, "Global #{type}: #{name}", file[:filename], file[:linenr]) end end end Relations.new(classes, @opts.external_classes) Loading
lib/jsduck/app_data.rb +8 −1 Original line number Diff line number Diff line Loading @@ -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, Loading @@ -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
lib/jsduck/app_exporter.rb +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
lib/jsduck/class.rb +10 −10 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -121,28 +121,28 @@ module JsDuck return {} end all_members = parent ? parent.members_hash(type, context) : {} ms = parent ? parent.members_hash(type, context) : {} mixins.each do |mix| all_members.merge!(mix.members_hash(type, context)) {|k,o,n| store_overrides(k,o,n)} ms.merge!(mix.members_hash(type, context)) {|k,o,n| store_overrides(k,o,n)} end # For static members, exclude everything not explicitly marked as inheritable if context == :statics all_members.delete_if {|key, member| !member[:inheritable] } ms.delete_if {|key, member| !member[:inheritable] } end all_members.merge!(local_members_hash(type, context)) {|k,o,n| store_overrides(k,o,n)} ms.merge!(local_members_hash(type, context)) {|k,o,n| store_overrides(k,o,n)} # If singleton has static members, include them as if they were # instance members. Otherwise they will be completely excluded # from the docs, as the static members block is not created for # singletons. if @doc[:singleton] && @doc[:statics][type].length > 0 all_members.merge!(local_members_hash(type, :statics)) {|k,o,n| store_overrides(k,o,n)} ms.merge!(local_members_hash(type, :statics)) {|k,o,n| store_overrides(k,o,n)} end all_members ms end # Invoked when merge! finds two members with the same name. Loading Loading @@ -197,7 +197,7 @@ module JsDuck return ms end # Returns all public members of class, including the inherited and mixed in ones # Returns all members of class, including the inherited and mixed in ones def all_members all = [] [:members, :statics].each do |group| Loading @@ -208,12 +208,12 @@ module JsDuck all end # Returns all local public members of class # Returns all local members of class def all_local_members all = [] [:members, :statics].each do |group| @doc[group].each_value do |ms| all += ms.find_all {|m| !m[:private] } all += ms end end all Loading
lib/jsduck/class_formatter.rb +3 −6 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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]) Loading