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

Skip examples export for classes without examples.

parent 7314307e
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ module JsDuck
    private

    def write_stdout
      json = @parallel.map(@relations.classes) {|cls| @exporter.export(cls) }
      json = @parallel.map(@relations.classes) {|cls| @exporter.export(cls) }.compact
      puts JsonDuck.generate(json)
    end

@@ -34,6 +34,8 @@ module JsDuck
        filename = dir + "/" + cls[:name] + extension
        Logger.instance.log("Writing docs", filename)
        json = @exporter.export(cls)
        # skip file if exporter returned nil
        if json
          if extension == ".json"
            JsonDuck.write_json(filename, json)
          elsif extension == ".js"
@@ -43,6 +45,7 @@ module JsDuck
          end
        end
      end
    end

  end

+9 −4
Original line number Diff line number Diff line
@@ -24,10 +24,15 @@ module JsDuck

    # Returns hash of class name and inline examples
    def export(cls)
      examples = @inline_examples.extract(cls[:doc])
      if examples.length > 0
        {
          :name => cls[:name],
          :examples => @inline_examples.extract(cls[:doc]),
        }
      else
        nil
      end
    end

  end