module Sprout # # The AsDoc Task provides Rake support for the asdoc documentation engine. # If a MXMLCTask or COMPCTask are found as prerequisites # to the AsDoc task, AsDoc will inherit the source_path and library_path # from those tasks. You can also configure AsDoc normally if you wish. # # This configuration might look something like this: # # # Create a remote library dependency on the corelib swc. # library :corelib # # # Alias the compilation task with one that is easier to type # # task :compile => 'SomeProject.swf' # # AsDoc tasks can be created and configured directly like any other rake task. # # # Create a simple, standard asdoc task # asdoc :doc do |t| # t.source_path << 'src' # t.library_path << 'lib/corelib.swc' # t.doc_classes = 'SomeProject' # t.main_title = 'Some Project Title' # t.footer = 'This is the footer for your project docs' # end # # # Create an MXMLCTask named for the output file that it creates. This task depends on the # # corelib library and will automatically add the corelib.swc to it's library_path # mxmlc 'bin/SomeProject.swf' => :corelib do |t| # t.input = 'src/SomeProject.as' # t.default_size = '800 600' # t.default_background_color = "#FFFFFF" # t.source_path << 'src' # t.source_path << 'lib/asunit' # t.source_path << 'test' # end # # desc "Generate documentation" # asdoc :doc => 'bin/SomeProject.swf' # # This configuration will generate documentation in the relative path, 'doc', but only if # The contents of the documentation directory are older than the sources referenced by the compiler. # # For more information about using the asdoc command line compiler, check livedocs at: # http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=asdoc_127_1.html # class AsDocTask < ToolTask def initialize_task super @default_gem_name = 'sprout-flex3sdk-tool' @default_gem_path = 'bin/asdoc' add_param(:actionscript_file_encoding, :string) do |p| p.description = "Sets the file encoding for ActionScript files. For more information see: http://livedocs.adobe.com/flex/2/docs/00001503.html#149244" end add_param(:benchmark, :boolean) do |p| p.value = true p.show_on_false = true p.description = "Prints detailed compile times to the standard output. The default value is true." end add_param(:doc_classes, :strings) do |p| p.description =< e if(e.message.index('Warning:')) # MXMLC sends warnings to stderr.... Log.puts(e.message.gsub('[ERROR]', '[WARNING]')) else raise e end end end # The AsDoc package includes an asDocHelper binary that is packaged up without # the executable flag, calling Sprout::get_executable with this target will # automatically chmod it to 744. def update_helper_mode exe = Sprout.get_executable(gem_name, 'asdoc/templates/asDocHelper', gem_version) end def resolve_library(library_task) #TODO: Add support for libraries that don't get # copied into the project path = library_task.project_path if(path.match(/.swc$/)) library_path << library_task.project_path else source_path << library_task.project_path end end # Requires that @exclude_expressions is not nil. def apply_exclusions_from_expression FileList[@exclude_expressions].each do |file_path| import_file = remove_source_path_from_file_path(file_path) || file_path import_class = filename_to_import_class(import_file) exclude_classes << import_class unless import_class.nil? end end def remove_source_path_from_file_path(file) source_path.each do |source_dir| import_file = file.sub(Regexp.new("^#{source_dir}"),"") return import_file if import_file != file end return file end def filename_to_import_class(filename) name = filename.scan(/\w+/) # Ignore the AS file extension. name[0..-2].join('.') unless name[-1] != 'as' end end end def asdoc(args, &block) return Sprout::AsDocTask.define_task(args, &block) end