Sha256: e44dd1496b121e74dc331c31c9a3588ea26716811a660f14252b8e5f35b98017

Contents?: true

Size: 1.25 KB

Versions: 10

Compression:

Stored size: 1.25 KB

Contents

module Distil

  DOC_COMMENT_REGEX= /(\/\*\*.*?)\*\//m
  DOC_VALID_FLAGS= [:topic, :deprecated]
  
  module JavascriptDocumentationGenerator

    include ErrorReporter

    def extract_doc_comments_from(file)
      comments= []
      
      file.content.scan(DOC_COMMENT_REGEX).each { |m|
        lines= m[0].split
        comment= {
          :ebnf => lines[1],
          :text => lines[2..-1].join("\n")
        }
        
        # Remove comment characters (otherwise, the string doesn't split
        # correctly when the line after the comment is empty). Flags are a comma
        # separated list of options for this comment.
        flags= lines[0][3..-1]
        flags.split(',').each { |flag|
          key, value= flag.split(/\s*:\s*/)
          if !DOC_VALID_FLAGS.include?(key.to_sym)
            warning "Invalid documentation qualifier: #{key}", file
            next
          end
          comment[key.to_sym]= case key.to_sym
            when :topic
              value
            when :deprecated
              true
            end
        }
        
        # Add the comment to the collection
        comments << comment
      }

      comments
    end
    
    def document_file(file)
      comments= extract_doc_comments_from(file)
    end
      
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
distil-0.14.4 lib/distil/javascript-documentation-generator.rb
distil-0.14.3 lib/distil/javascript-documentation-generator.rb
distil-0.14.2 lib/distil/javascript-documentation-generator.rb
distil-0.14.2.a lib/distil/javascript-documentation-generator.rb
distil-0.14.1 lib/distil/javascript-documentation-generator.rb
distil-0.14.1.a lib/distil/javascript-documentation-generator.rb
distil-0.14.0 lib/distil/javascript-documentation-generator.rb
distil-0.14.0.i lib/distil/javascript-documentation-generator.rb
distil-0.14.0.h lib/distil/javascript-documentation-generator.rb
distil-0.14.0.g lib/distil/javascript-documentation-generator.rb