Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8972

Show
Ignore:
Timestamp:
03/02/08 23:26:18 (4 months ago)
Author:
tobie
Message:

pdoc: Make PDoc::Generators::Html::Website#render accept an output directory as argument.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/pdoc/trunk/CHANGELOG

    r8971 r8972  
     1* Make PDoc::Generators::Html::Website#render accept an output directory as argument. [Tobie] 
     2 
    13* Remove usage of class_eval to enable easier documentation by rdoc. Start documenting the code. [Tobie] 
    24 
  • spinoffs/pdoc/trunk/lib/pdoc/generators/html/helpers.rb

    r8944 r8972  
    3232          name = short ? obj.name : obj.full_name 
    3333          name = "<code>#{name}</code>" unless obj.is_a?(Documentation::Section) 
    34           link_to(name, path_to(obj), {:title => "#{obj.full_name} (#{obj.type})"}.merge(attributes)) 
     34          link_to(name, path_to(obj), { :title => "#{obj.full_name} (#{obj.type})" }.merge(attributes)) 
    3535        end 
    3636         
  • spinoffs/pdoc/trunk/lib/pdoc/generators/html/website.rb

    r8971 r8972  
    33    module Html 
    44      class Website 
    5         def initialize(file, output = OUTPUT_DIR
     5        def initialize(file
    66          @file = file 
    77          string = File.open(@file){ |f| f.read } 
    88          @root = Parser.new(string).parse 
    99          @depth = 0 
    10           @output = File.expand_path(output) 
    11           Dir.chdir(@output) 
    1210        end 
    1311         
    14         def render 
     12        # Generates the website to the specified directory. 
     13        def render(output = OUTPUT_DIR) 
     14          Dir.chdir(File.expand_path(output)) 
    1515          Page.new("index", "layout", variables).render_to_file("index.html") 
    1616           
     
    2929        end 
    3030         
    31         # Copies the the content of assets folder to the generated website's 
     31        # Copies the content of the assets folder to the generated website's 
    3232        # root directory. 
    3333        def copy_assets 
  • spinoffs/pdoc/trunk/lib/pdoc/parser/documentation_nodes.rb

    r8971 r8972  
    44 
    55    def each 
    6       elements.first.elements.map{|e| e.elements.last }.each { |tag| yield tag } 
     6      elements.first.elements.map { |e| e.elements.last }.each { |tag| yield tag } 
    77    end 
    88     
    99    # Returns an array of all deprecated object. 
    1010    def deprecated 
    11       select{|e| e.deprecated? } 
     11      select { |e| e.deprecated? } 
    1212    end 
    1313     
    1414    # Returns an array of all documented aliases. 
    1515    def aliases 
    16       select{|e| e.alias? } 
     16      select { |e| e.alias? } 
    1717    end 
    1818     
     
    8484    # Returns an array of all documented instances which are global variables. 
    8585    def globals 
    86       select{ |e| e.global? }.sort_by {|e| e.name } 
     86      select { |e| e.global? }.sort_by { |e| e.name } 
    8787    end 
    8888    alias children globals 
     
    9090    # Returns an array of all documented Section instances. 
    9191    def sections 
    92       select{ |e| e.is_a?(Section) }.sort_by {|e| e.name } 
     92      select { |e| e.is_a?(Section) }.sort_by { |e| e.name } 
    9393    end 
    9494     
     
    111111    # True if the instance was tagged as deprecated. 
    112112    def deprecated? 
    113       tags.include?("deprecated") || ancestors.any?{ |a| a.deprecated? } 
     113      tags.include?("deprecated") || ancestors.any? { |a| a.deprecated? } 
    114114    end 
    115115     
     
    128128    def alias_of 
    129129      if alias? 
    130         a = tags.find{|tag| tag.name == "alias of" }.value 
     130        a = tags.find { |tag| tag.name == "alias of" }.value 
    131131        root.find_by_name(a) 
    132132      else 
     
    137137    # Returns an array of all aliases of this instance. 
    138138    def aliases 
    139       root.select{ |a| a.alias_of == self } 
     139      root.select { |a| a.alias_of == self } 
    140140    end 
    141141     
     
    177177    def section 
    178178      if tags.include?("section") 
    179         value = tags.find{|tag| tag.name == "section" }.value 
    180         root.sections.find{|s| s.name == value } 
     179        value = tags.find { |tag| tag.name == "section" }.value 
     180        root.sections.find { |s| s.name == value } 
    181181      else 
    182182        namespace.section 
     
    208208    # Returns all direct descendants of instance. 
    209209    def children 
    210       root.descendants.select{|d| d.namespace === self }.sort_by {|e| e.name } 
     210      root.descendants.select { |d| d.namespace === self }.sort_by { |e| e.name } 
    211211    end 
    212212     
     
    298298     
    299299    def children 
    300       root.children.select{|d| d.section === self }.sort_by {|e| e.name } 
     300      root.children.select { |d| d.section === self }.sort_by { |e| e.name } 
    301301    end 
    302302     
    303303    def descendants 
    304       root.descendants.select{|d| d.section === self }.sort_by {|e| e.name } 
     304      root.descendants.select { |d| d.section === self }.sort_by { |e| e.name } 
    305305    end 
    306306     
     
    317317     
    318318    def ebnf_expressions 
    319       ebnf.elements.map{|e| e.elements.last } 
     319      ebnf.elements.map { |e| e.elements.last } 
    320320    end 
    321321 
     
    372372    def related_to 
    373373      if tags.include?("related to") 
    374         namespace = tags.find{|tag| tag.name == "related to" }.value 
     374        namespace = tags.find { |tag| tag.name == "related to" }.value 
    375375        root.find_by_name(namespace) 
    376376      else 
     
    383383        r.section 
    384384      elsif tags.include?("section") 
    385         value = tags.find{|tag| tag.name == "section" }.value 
    386         root.sections.find{|s| s.name == value } 
     385        value = tags.find { |tag| tag.name == "section" }.value 
     386        root.sections.find { |s| s.name == value } 
    387387      else 
    388388        nil 
     
    452452    # Returns a sorted array of KlassProperty 
    453453    def klass_properties 
    454       root.klass_properties.select{ |e| e.namespace === self }.sort_by { |e| e.name } 
     454      root.klass_properties.select { |e| e.namespace === self }.sort_by { |e| e.name } 
    455455    end 
    456456 
    457457    # Returns a sorted array of KlassMethod 
    458458    def klass_methods 
    459       root.klass_methods.select{ |e| e.namespace === self }.sort_by { |e| e.name } 
     459      root.klass_methods.select { |e| e.namespace === self }.sort_by { |e| e.name } 
    460460    end 
    461461 
    462462    # Returns a sorted array of InstanceProperty 
    463463    def instance_properties 
    464       root.instance_properties.select{ |e| e.namespace === self }.sort_by { |e| e.name } 
     464      root.instance_properties.select { |e| e.namespace === self }.sort_by { |e| e.name } 
    465465    end 
    466466 
    467467    # Returns a sorted array of InstanceMethod 
    468468    def instance_methods 
    469       root.instance_methods.select{ |e| e.namespace === self }.sort_by { |e| e.name } 
     469      root.instance_methods.select { |e| e.namespace === self }.sort_by { |e| e.name } 
    470470    end 
    471471 
    472472    # Returns a sorted array of Constant 
    473473    def constants 
    474       root.constants.select{ |e| e.namespace === self }.sort_by { |e| e.name } 
     474      root.constants.select { |e| e.namespace === self }.sort_by { |e| e.name } 
    475475    end 
    476476     
     
    480480     
    481481    def children 
    482       root.descendants.select{|e| e.namespace === self }.sort_by { |e| e.name } 
     482      root.descendants.select { |e| e.namespace === self }.sort_by { |e| e.name } 
    483483    end 
    484484     
    485485    def related_utilities 
    486       root.utilities.select{|e| e.related_to === self}.sort_by { |e| e.name } 
     486      root.utilities.select { |e| e.related_to === self }.sort_by { |e| e.name } 
    487487    end 
    488488     
     
    523523    def all_methods 
    524524      c = constructor  
    525       c ? (super << c).sort_by {|e| e.name } : super 
     525      c ? (super << c).sort_by { |e| e.name } : super 
    526526    end 
    527527