Module: Processor

Defined in:
lib/processor.rb

Defined Under Namespace

Classes: RenderTask

Constant Summary collapse

@@render_tasks =
{}

Combined Stages collapse

Stage #1 - FileProcessor collapse

Stage #2 - CommentProcessor collapse

Stage #3 - TemplateProcessor collapse

Stage #4 - Document Processor collapse

RenderTask-Setup collapse

Class Method Summary collapse

Class Method Details

.parse_files(files = nil) ⇒ Object

Parsing Files and creating comment stream



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/processor.rb', line 30

def self.parse_files(files = nil)
  files ||= Configs.files
      
  return if files.nil?    

  files = [files] unless files.is_a? Array
  comments = []
  
  files.each do |file|  
    Logger.info "Processing file #{file}"      
    comments += Parser::Parser.parse_file(file)
  end
  
  return comments
end

.perform_all_tasksObject

command line:

$~ jsdoc render_tasks
Registered Rendertasks:
- typed:     renders objects type-dependant
- overview:  renders an overview
- files:     converts specified markdown files and renders them


73
74
75
# File 'lib/processor.rb', line 73

def self.perform_all_tasks
  perform_tasks @@render_tasks.keys
end

.perform_tasks(tasks) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/processor.rb', line 77

def self.perform_tasks(tasks)

  tasks = [tasks] unless tasks.is_a? Array
  
  tasks.each do |task|
    task = task.to_sym
    raise Exception, "No render-task registered with name '#{task}'" unless @@render_tasks.has_key? task
    
    Logger.debug "Rendering task '#{task}'"
    @@render_tasks[task].new.perform
  end
end

.prepare_documentsObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/processor.rb', line 92

def self.prepare_documents
  # underscores will be replaced with whitespaces as title
  Configs.docs.each do |doc|
  
    doc_path = File.expand_path(doc, Configs.wdir)    
    Logger.debug "Working with Document #{doc_path}"
    
    contents = File.read(doc_path)
    
    # Those documents get registered in a special {Dom::Node} Dom.docs
    document = Document::Document.new(doc_path, contents)
    Dom.docs.add_node(document.path, document)
    
    # The docs can be accessed via Dom later on
  end
end

.process_and_renderObject



18
19
20
21
# File 'lib/processor.rb', line 18

def self.process_and_render
  process_files_to_dom
  perform_all_tasks
end

.process_comments(comments) ⇒ Object

Processing comment-stream and convert to CodeObjects This stage also adds the CodeObjects to Dom.



50
51
52
53
54
55
56
57
58
59
# File 'lib/processor.rb', line 50

def self.process_comments(comments)
  
  comments = [comments] unless comments.is_a? Array
  
  comments.each do |comment|    
    code_object = comment.to_code_object            # convert to code_object
    Logger.debug "Adding to Dom: #{code_object}"
    Dom.add_node(code_object.path, code_object)     # add to dom
  end
end

.process_files_to_dom(files = nil) ⇒ Object



23
24
25
# File 'lib/processor.rb', line 23

def self.process_files_to_dom(files = nil)
  process_comments parse_files(files)
end

.register_render_task(name, klass) ⇒ Object



113
114
115
# File 'lib/processor.rb', line 113

def self.register_render_task(name, klass)
  @@render_tasks[name.to_sym] = klass 
end

.render_tasksObject

Accessor Method for RenderTasks



12
13
14
# File 'lib/processor.rb', line 12

def self.render_tasks
  @@render_tasks
end

.unregister_render_task(name) ⇒ Object



117
118
119
# File 'lib/processor.rb', line 117

def self.unregister_render_task(name)
  @@render_tasks.delete(name.to_sym)
end