lib/capitate/task_node.rb in capitate-0.1.9 vs lib/capitate/task_node.rb in capitate-0.2.1

- old
+ new

@@ -54,10 +54,16 @@ # def sorted_nodes nodes.sort_by(&:name) end + # Get tasks (sorted). + # + def sorted_tasks + tasks.sort_by(&:fully_qualified_name) # { |t| t.name.to_s } + end + # Iterate over ALL "child" nodes, depth first. # Yields |node, level|. # # ==== Options # +level+:: Current level @@ -85,12 +91,14 @@ # Return nil for top node name == "top" ? nil : name end - # Write doc for node (recursively) + # Write textile documentation for node (recursively). # + # Uses task desc attribute for task details. + # # ==== Options # +dir+:: Dir to write to # +file_name+:: File name to write to, defaults to full name # +title+:: Title and h1 for page, defaults to name # +options+:: Options @@ -124,25 +132,36 @@ file.puts %{ "home":../index.html > "recipes":index.html > #{links.reverse.join(" > ")} } # # Namespace # - unless sorted_nodes.empty? - file.puts "h2. Namespaces\n\n" + unless nodes.empty? + file.puts "\n\nh2. Namespaces\n\n" each_node do |snode, level| - li_level = (0..level).collect { "*" }.join - file.puts %{#{li_level} "#{snode.full_name(":")}":#{snode.full_name}.html \n} + #li_level = (0..level).collect { "*" }.join + if snode.tasks.length > 0 + file.puts %{* "#{snode.full_name(":")}":#{snode.full_name}.html (#{snode.tasks.length}) \n} + end end end # # Tasks + # + unless tasks.empty? + file.puts "\n\nh2. Tasks\n\n" + sorted_tasks.each do |task| + file.puts %{* "#{task.fully_qualified_name}":##{task.fully_qualified_name} \n} + end + end + # + # Task details + # unless tasks.empty? - file.puts "\n\n" - file.puts "h2. Tasks\n\n" - tasks.each do |task| - file.puts "h3. #{task.fully_qualified_name}\n\n" + file.puts "\n\nh2. Task documentation\n\n" + sorted_tasks.each do |task| + file.puts "h3(##{task.fully_qualified_name}). #{task.fully_qualified_name}\n\n" file.puts "#{unindent(task.desc)}\n\n\n\n" end end # \ No newline at end of file