# File lib/Getopt/Declare.rb, line 1308
  def usage(*opt)

    t = @usage

    lastflag = nil
    lastdesc = nil
    usage = ''

    while t.length() > 0

      # COMMENT:

      t.sub!(/\A[ \t]*#.*\n/,".") and next

      # TYPE DIRECTIVE:

      se  = DelimScanner::new( t )

      if t =~ /\A\s*\[pvtype:/
        if action = se.extractBracketed("[")
          t.sub!(Regexp::quote( action ).to_re,'')
          t.sub!(/\A[ \t]*\n/,"")  
          next
        end
      end

      # ACTION

      codeblockDelimiters = {
        '{'     => '}'
      }
      se  = DelimScanner::new( t )
      if action = se.extractCodeblock(codeblockDelimiters)
        t.sub!(Regexp::quote( action ).to_re,'')
        t.sub!(/\A[ \t]*\n/,"")
        decfirst = 0 unless !decfirst.nil?
        next
      end


      # ARG + DESC:

      if t.sub!(re_argument,"")
        decfirst = 0 unless !decfirst.nil?
        spec = "#$1".expand_tabs!()
        desc = "#$2".expand_tabs!()

        while t.gsub!(re_more_desc, '')
          desc += "#$1".expand_tabs!
        end

        next if desc =~ /\[\s*undocumented\s*\]/i

        uoff = 0
        spec.gsub!(/(<[a-zA-Z]\w*):([^>]+)>/e) { |i|
          uoff += 1 + "#$2".length() and "#$1>"
        }
        spec.gsub!(/\t/,"=")

        ditto = desc =~ /\A\s*\[ditto\]/
        desc.gsub!(/^\s*\[.*?\]\s*\n/m,"")
        desc.gsub!(BracketDirectives,'')
        #desc.gsub!(/\[.*?\]/,"")


        
        if ditto
          desc = (lastdesc ? _ditto(lastflag,lastdesc,desc) : "" )
        elsif desc =~ /\A\s*\Z/
          next
        else
          lastdesc = desc
        end

        spec =~ /\A\s*(\S+)/ and lastflag = "#$1"
        
        desc.sub!(/\s+\Z/, "\n")
        usage += spec + ' ' * uoff + desc
        next
      end

      

      # OTHERWISE, DECORATION

      if t.sub!(/((?:(?!\[pvtype:).)*)(\n|(?=\[pvtype:))/,"")
        desc = "#$1"+("#$2"||'')
        #desc.gsub!(/^(\s*\[.*?\])+\s*\n/m,'')

        #desc.gsub!(/\[.*?\]/,'')  # eliminates anything in brackets

        if @tight || desc !~ /\A\s*\Z/
          desc.gsub!(BracketDirectives,'')
          next if desc =~ /\A\s*\Z/
        end
        decfirst = 1 unless !decfirst.nil? or desc =~ /\A\s*\Z/
        usage += desc
        usage.rstrip!
      end

    end  #while


    required = ''
    
    for arg in @args
      required += ' ' + arg.desc + ' '  if arg.required
    end
      
    usage.gsub!(/\255/,"[/") # REINSTATE ESCAPED '['s

      
    required.gsub!(/<([a-zA-Z]\w*):[^>]+>/,'<\1>')
    required.rstrip!
    
    helpcmd = Getopt::Declare::Arg::besthelp
    versioncmd = Getopt::Declare::Arg::bestversion
    
      
    header = ''
    unless @source.nil?
      header << version()
      prog = "#{$0}"
      prog.sub!(%r#.*/#,'')
      header <<  "Usage: #{prog} [options]#{required}\n"
      header <<  "       #{prog} #{helpcmd}\n" if helpcmd
      header <<  "       #{prog} #{versioncmd}\n" if versioncmd
      header <<  "\n" unless decfirst && decfirst == 1 && usage =~ /\A[ \t]*\n/
    end
    
    header << "Options:\n" unless decfirst && decfirst == 1
    
    if opt.empty?
      return header + usage + "\n"
    end

    pager = $stdout
    #begin

    #  eval('require "IO/Pager";')

    #  pager = IO::Pager.new()

    #rescue

    #end


    pager.puts "#{header}#{usage}"
    exit(opt[0]) if opt[0]
  end