WebRI  Syckle::Plugins::WebRI

[Validate]
Generated with WebRI Redfish 1.2

WebRI

WebRI documentation plugin generates WebRI-based RDocs for your project.

By default it generates the documentaiton at doc/webri, unless an ‘webri’ directory exists in the project’s root directory, in which case the documentation will be stored there (unless an alternative is specified).

This plugin provides the following cycle-phases:

  main:document  - generate rdocs
  main:reset     - mark rdocs out-of-date
  main:clean     - remove rdocs

  site:document  - generate rdocs
  site:reset     - mark rdocs out-of-date
  site:clean     - remove rdocs

WebRI service will be available automatically if the project has a doc/webri or webri directory.

Constants

DEFAULT_OUTPUT

Default location to store rdoc documentation files.

DEFAULT_OUTPUT_MATCH

Locations to check for existance in deciding where to store rdoc documentation.

DEFAULT_MAIN

Default main file.

DEFAULT_TEMPLATE

Default rdoc template to use.

DEFAULT_EXTRA

Deafult extra options to add to rdoc call.

Attributes

title[RW]

Title of documents. Defaults to general metadata title field.

output[RW]

Where to save rdoc files (doc/rdoc).

template[RW]

Template to use (defaults to ENV[‘RDOC_TEMPLATE’] or ‘darkfish’)

main[RW]

Main file. This can be a file pattern. (README{,.*})

files[RW]

Which files to document.

exclude[RW]

Paths to specifically exclude.

extra[RW]

Additional options passed to the rdoc command.

Public Instance Methods

clean() click to toggle source

Remove rdocs products.

# File lib/plugins/syckle/webri.rb, line 197
    def clean
      if File.directory?(output)
        rm_r(output)
        status "removed #{output}" #unless dryrun?
      end
    end
document(options=nil) click to toggle source

Generate Rdoc documentation. Settings are the same as the rdoc command’s option, with two exceptions: inline for inline-source and output for op.

# File lib/plugins/syckle/webri.rb, line 114
    def document(options=nil)
      options ||= {}

      # TODO: get rid of options (?) originally they were used for commanline overrides,
      # but that's not being used anymore, and it's probably better that way.
      title    = options['title']    || self.title
      output   = options['output']   || self.output
      main     = options['main']     || self.main
      template = options['template'] || self.template
      files    = options['files']    || self.files
      exclude  = options['exclude']  || self.exclude
      #adfile   = options['adfile']   || self.adfile
      extra    = options['extra']    || self.extra
      root     = options['root']     || self.root

      # NOTE: Due to a bug in RDOC this needs to be done so that
      # alternate templates can be used.
      begin
        gem('rdoc')
        #gem(templib || template)
      rescue LoadError
      end

      require 'rdoc/rdoc'

      #output = File.expand_path(output)

      # you can specify more than one possibility, first match wins
      #adfile = [adfile].flatten.compact.find do |f|
      #  File.exist?(f)
      #end

      main = Dir.glob(main, File::FNM_CASEFOLD).first

      include_files = files.to_list.uniq
      exclude_files = exclude.to_list.uniq

      if mfile = project.manifest_file
        exclude_files << mfile.basename.to_s # TODO: I think base name should retun a string?
      end

      filelist = amass(include_files, exclude_files)
      filelist = filelist.select{ |fname| File.file?(fname) }

      if outofdate?(output, *filelist) or force?
        status "Generating #{output}"

        #target_main = Dir.glob(target['main'].to_s, File::FNM_CASEFOLD).first
        #target_main   = File.expand_path(target_main) if target_main
        #target_output = File.expand_path(File.join(output, subdir))
        #target_output = File.join(output, subdir)

        argv = []
        argv.concat(extra.split(/\s+/))
        argv.concat ['--op', output]
        argv.concat ['--main', main] if main
        argv.concat ['--template', template] if template
        argv.concat ['--title', title] if title

        exclude_files.each do |file|
          argv.concat ['--exclude', file]
        end

        argv = argv + filelist #include_files

        rdoc_target(output, include_files, argv)
        #rdoc_insert_ads(output, adfile)

        touch(output)
      else
        status "WebRI RDocs are current (#{output})."
      end
    end
main_document click to toggle source

Generate rdocs in main cycle.

# File lib/plugins/syckle/webri.rb, line 29
    cycle :main, :document
reset() click to toggle source

Reset output directory, marking it as out-of-date.

# File lib/plugins/syckle/webri.rb, line 189
    def reset
      if File.directory?(output)
        File.utime(0,0,output)
        report "reset #{output}" #unless dryrun?
      end
    end

Private Instance Methods

initialize_defaults() click to toggle source

Setup default attribute values.

# File lib/plugins/syckle/webri.rb, line 68
    def initialize_defaults
      @title    = metadata.title
      @files    = metadata.loadpath + ['[A-Z]*', 'bin'] # DEFAULT_FILES
      @output   = Dir[DEFAULT_OUTPUT_MATCH].first || DEFAULT_OUTPUT
      @extra    = DEFAULT_EXTRA
      @main     = Dir[DEFAULT_MAIN].first
      @template = ENV['RDOC_TEMPLATE'] || DEFAULT_TEMPLATE
    end
rdoc_target(output, input, argv=[]) click to toggle source

Generate rdocs for input targets.

TODO: Use RDoc programmatically rather than via shell.

# File lib/plugins/syckle/webri.rb, line 210
    def rdoc_target(output, input, argv=[])
      #if outofdate?(output, *input) or force?
        rm_r(output) if exist?(output) and safe?(output)  # remove old rdocs

        #rdocopt['op'] = output

        #if template == 'hanna'
        #  cmd = "hanna #{extra} " + [input, rdocopt].to_console
        #else
        #  cmd = "rdoc #{extra} " + [input, rdocopt].to_console
        #end

        #argv = ("#{extra}" + [input, rdocopt].to_console).split(/\s+/)

        if verbose? or dryrun?
          puts "webri " + argv.join(" ")
          #sh(cmd) #shell(cmd)
        else
          cmd = "webri " + argv.join(" ")
          puts cmd  #if trace?
          #rdoc = ::RDoc::RDoc.new
          #rdoc.document(argv)
          #silently do
            sh(cmd) #shell(cmd)
          #end
        end
      #else
      #  puts "RDocs are current -- #{output}"
      #end
    end

Disabled; run with --debug to generate this.