Commit 473b75bf authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Use standard name for --external option internally.

Instead of :external_classes, use :external - like the name of
the option itself, and like it is now with all other options.
parent 90ecf7f1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ module JsDuck
    # classes inside Relations container.
    def to_class_objects(docs, opts)
      classes = docs.map {|d| Class.new(d) }
      Relations.new(classes, opts.external_classes)
      Relations.new(classes, opts.external)
    end

    # Do all kinds of post-processing on Relations object.
+2 −2
Original line number Diff line number Diff line
@@ -474,7 +474,7 @@ module JsDuck
          @opts.ignore_global = on
        end

        attribute :external_classes, [
        attribute :external, [
          # JavaScript builtins
          "Object",
          "String",
@@ -520,7 +520,7 @@ module JsDuck
          "The wildcard '*' can be used to match a set of classes",
          "e.g. to ignore all classes of a particular namespace:",
          "--external='Foo.*'") do |classes|
          @opts.external_classes += classes
          @opts.external += classes
        end

        attribute :ext4_events
+3 −3
Original line number Diff line number Diff line
@@ -5,14 +5,14 @@ module JsDuck
  module Process

    class Overrides
      def initialize(classes_hash, opts = OpenStruct.new(:external_classes => []))
      def initialize(classes_hash, opts = OpenStruct.new(:external => []))
        @classes_hash = classes_hash
        @opts = opts
      end

      # Applies all override classes to target classes, then deletes
      # the overrides themselves from classes hash and adds the names
      # of all the processed overrides to external_classes list in
      # of all the processed overrides to external classes list in
      # options object.
      def process_all!
        overrides = []
@@ -29,7 +29,7 @@ module JsDuck
          @classes_hash.delete(cls[:name])
        end

        @opts.external_classes += overrides.map {|c| c[:name] }
        @opts.external += overrides.map {|c| c[:name] }
      end

      private
+6 −6
Original line number Diff line number Diff line
@@ -205,16 +205,16 @@ describe JsDuck::Options::Parser do
    end
  end

  describe :external_classes do
  describe :external do
    it "contains JavaScript builtins by default" do
      exts = parse().external_classes
      exts = parse().external
      %w(Object String Number Boolean RegExp Function Array Arguments Date).each do |name|
        exts.should include(name)
      end
    end

    it "contains JavaScript builtin error classes by default" do
      exts = parse().external_classes
      exts = parse().external
      exts.should include("Error")
      %w(Eval Range Reference Syntax Type URI).each do |name|
        exts.should include("#{name}Error")
@@ -222,17 +222,17 @@ describe JsDuck::Options::Parser do
    end

    it "contains the special anything-goes Mixed type" do
      parse().external_classes.should include("Mixed")
      parse().external.should include("Mixed")
    end

    it "can be used multiple times" do
      exts = parse("--external", "MyClass", "--external", "YourClass").external_classes
      exts = parse("--external", "MyClass", "--external", "YourClass").external
      exts.should include("MyClass")
      exts.should include("YourClass")
    end

    it "can be used with comma-separated list" do
      exts = parse("--external", "MyClass,YourClass").external_classes
      exts = parse("--external", "MyClass,YourClass").external
      exts.should include("MyClass")
      exts.should include("YourClass")
    end