Sha256: e131e7430e486795a7ac6790be24b5e246be6c359a78b58387b7b454c37caea9

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 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.entries_for(:javascript, :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, 'app', 'js.jar')
      runjs_path = File.join(jsdoc_root, 'app', 'run.js')
      template_path = File.join(jsdoc_root, 'templates', 'sproutcore')
      
      SC.logger.debug `java -Djsdoc.dir=#{jsdoc_root} -jar #{jar_path} #{runjs_path} -t=#{template_path} -d=#{build_path} #{files * ' '} -v`
    
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sproutcore-0.9.1 lib/sproutcore/jsdoc.rb
sproutcore-0.9.0 lib/sproutcore/jsdoc.rb