Sha256: 4be6574beef14f1c3c130220ff209d07e9676e47dd18d8a6049cc7c4fcba3563

Contents?: true

Size: 1.87 KB

Versions: 10

Compression:

Stored size: 1.87 KB

Contents

# This utility module will use jsdoc to create documentation from a SproutCore
# client.  Note that for this to work you must have Java installed (sudder).
module SproutCore

  module JSDoc

    # Creates the documentation for the specified set of clients, replacing
    # the contents of the output file.  Requires some of the following
    # options.
    #
    # :bundle => A Bundle instance - or -
    # :files  => Absolute paths to input files
    # :build_path => absolute path to the build root.  Uses the bundle if not provided.
    def self.generate(opts = {})
      bundle = opts[:bundle]
      build_path = opts[:build_path] || File.join(bundle.build_root, '-docs', 'data')
      raise "MISSING OPTION: :bundle => bundle or :build_path => path required for JSDoc" if build_path.nil?

      # get the list of files to build for.
      files = opts[:files]
      if files.nil?
        raise "MISSING OPTION: :bundle => bundle or :files => list of files required for JSDoc" if bundle.nil?
        entries = bundle.sorted_javascript_entries(:hidden => :include)
        files = entries.map { |x| x.composite? ? nil : x.source_path }.compact.uniq
      end

      # Ensure directory exists
      FileUtils.mkdir_p(build_path)

      # Now run jsdoc
      jsdoc_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'jsdoc'))
      jar_path = File.join(jsdoc_root, 'jsrun.jar')
      runjs_path = File.join(jsdoc_root, 'app', 'run.js')
      template_path = File.join(jsdoc_root, 'templates', 'sproutcore')
      
      # wrap files in quotes...
      # Note: using -server gives an approx. 25% speed boost over -client (the default)
      js_doc_cmd = %(java -server -Djsdoc.dir="#{jsdoc_root}" -jar "#{jar_path}" "#{runjs_path}" -t="#{template_path}" -d="#{build_path}" "#{ files * '" "' }" -v)

      puts "GENERATING: #{js_doc_cmd}"

      SC.logger.debug `#{js_doc_cmd}`
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sproutcore-0.9.14 lib/sproutcore/jsdoc.rb
sproutcore-0.9.15 lib/sproutcore/jsdoc.rb
sproutcore-0.9.18 lib/sproutcore/jsdoc.rb
sproutcore-0.9.19 lib/sproutcore/jsdoc.rb
sproutcore-0.9.17 lib/sproutcore/jsdoc.rb
sproutcore-0.9.16 lib/sproutcore/jsdoc.rb
sproutcore-0.9.23 lib/sproutcore/jsdoc.rb
sproutcore-0.9.21 lib/sproutcore/jsdoc.rb
sproutcore-0.9.22 lib/sproutcore/jsdoc.rb
sproutcore-0.9.20 lib/sproutcore/jsdoc.rb