Class | RDoc::Generator::File |
In: |
generator.rb
doc-tmp/rdoc/generator.rb |
Parent: | Context |
Handles the mapping of a file‘s information to HTML. In reality, a file corresponds to a TopLevel object, containing modules, classes, and top-level methods. In theory it could contain attributes and aliases, but we ignore these for now.
# File doc-tmp/rdoc/generator.rb, line 708 708: def initialize(context, options, file_dir) 709: super(context, options) 710: 711: @values = {} 712: 713: if options.all_one_file 714: @path = filename_to_label 715: else 716: @path = http_url(file_dir) 717: end 718: 719: @name = @context.file_relative_name 720: 721: collect_methods 722: AllReferences.add(name, self) 723: context.viewer = self 724: end
# File generator.rb, line 708 708: def initialize(context, options, file_dir) 709: super(context, options) 710: 711: @values = {} 712: 713: if options.all_one_file 714: @path = filename_to_label 715: else 716: @path = http_url(file_dir) 717: end 718: 719: @name = @context.file_relative_name 720: 721: collect_methods 722: AllReferences.add(name, self) 723: context.viewer = self 724: end
# File doc-tmp/rdoc/generator.rb, line 832 832: def <=>(other) 833: self.name <=> other.name 834: end
# File doc-tmp/rdoc/generator.rb, line 813 813: def file_attribute_values 814: full_path = @context.file_absolute_name 815: short_name = ::File.basename full_path 816: 817: @values["title"] = CGI.escapeHTML("File: #{short_name}") 818: 819: if @context.diagram then 820: @values["diagram"] = diagram_reference(@context.diagram) 821: end 822: 823: @values["short_name"] = CGI.escapeHTML(short_name) 824: @values["full_path"] = CGI.escapeHTML(full_path) 825: @values["dtm_modified"] = @context.file_stat.mtime.to_s 826: 827: if @options.webcvs then 828: @values["cvsurl"] = cvs_url @options.webcvs, @values["full_path"] 829: end 830: end
# File generator.rb, line 813 813: def file_attribute_values 814: full_path = @context.file_absolute_name 815: short_name = ::File.basename full_path 816: 817: @values["title"] = CGI.escapeHTML("File: #{short_name}") 818: 819: if @context.diagram then 820: @values["diagram"] = diagram_reference(@context.diagram) 821: end 822: 823: @values["short_name"] = CGI.escapeHTML(short_name) 824: @values["full_path"] = CGI.escapeHTML(full_path) 825: @values["dtm_modified"] = @context.file_stat.mtime.to_s 826: 827: if @options.webcvs then 828: @values["cvsurl"] = cvs_url @options.webcvs, @values["full_path"] 829: end 830: end
# File generator.rb, line 733 733: def filename_to_label 734: @context.file_relative_name.gsub(/%|\/|\?|\#/) do 735: '%%%x' % $&[0].unpack('C') 736: end 737: end
# File doc-tmp/rdoc/generator.rb, line 733 733: def filename_to_label 734: @context.file_relative_name.gsub(/%|\/|\?|\#/) do 735: '%%%x' % $&[0].unpack('C') 736: end 737: end
# File generator.rb, line 726 726: def http_url(file_dir) 727: suffix = ".html" 728: suffix = ".xhtml" if @options.template == "xhtml" 729: 730: ::File.join file_dir, "#{@context.file_relative_name.tr '.', '_'}" + suffix 731: end
# File doc-tmp/rdoc/generator.rb, line 726 726: def http_url(file_dir) 727: suffix = ".html" 728: suffix = ".xhtml" if @options.template == "xhtml" 729: 730: ::File.join file_dir, "#{@context.file_relative_name.tr '.', '_'}" + suffix 731: end
# File generator.rb, line 747 747: def value_hash 748: file_attribute_values 749: add_table_of_sections 750: 751: @values["charset"] = @options.charset 752: @values["href"] = path 753: @values["style_url"] = style_url(path, @options.css) 754: @values["mathml_xsl_url"] = style_url(path, "mathml.xsl") 755: 756: if @context.comment 757: d = markup(@context.comment) 758: @values["description"] = d if d.size > 0 759: end 760: 761: ml = build_method_summary_list 762: @values["methods"] = ml unless ml.empty? 763: 764: il = build_include_list(@context) 765: @values["includes"] = il unless il.empty? 766: 767: rl = build_requires_list(@context) 768: @values["requires"] = rl unless rl.empty? 769: 770: if @options.promiscuous 771: file_context = nil 772: else 773: file_context = @context 774: end 775: 776: 777: @values["sections"] = @context.sections.map do |section| 778: 779: secdata = { 780: "sectitle" => section.title, 781: "secsequence" => section.sequence, 782: "seccomment" => markup(section.comment) 783: } 784: 785: cl = build_class_list(0, @context, section, file_context) 786: @values["classlist"] = cl unless cl.empty? 787: 788: mdl = build_method_detail_list(section) 789: secdata["method_list"] = mdl unless mdl.empty? 790: 791: al = build_alias_summary_list(section) 792: secdata["aliases"] = al unless al.empty? 793: 794: co = build_constants_summary_list(section) 795: @values["constants"] = co unless co.empty? 796: 797: secdata 798: end 799: 800: @values 801: end
# File doc-tmp/rdoc/generator.rb, line 747 747: def value_hash 748: file_attribute_values 749: add_table_of_sections 750: 751: @values["charset"] = @options.charset 752: @values["href"] = path 753: @values["style_url"] = style_url(path, @options.css) 754: @values["mathml_xsl_url"] = style_url(path, "mathml.xsl") 755: 756: if @context.comment 757: d = markup(@context.comment) 758: @values["description"] = d if d.size > 0 759: end 760: 761: ml = build_method_summary_list 762: @values["methods"] = ml unless ml.empty? 763: 764: il = build_include_list(@context) 765: @values["includes"] = il unless il.empty? 766: 767: rl = build_requires_list(@context) 768: @values["requires"] = rl unless rl.empty? 769: 770: if @options.promiscuous 771: file_context = nil 772: else 773: file_context = @context 774: end 775: 776: 777: @values["sections"] = @context.sections.map do |section| 778: 779: secdata = { 780: "sectitle" => section.title, 781: "secsequence" => section.sequence, 782: "seccomment" => markup(section.comment) 783: } 784: 785: cl = build_class_list(0, @context, section, file_context) 786: @values["classlist"] = cl unless cl.empty? 787: 788: mdl = build_method_detail_list(section) 789: secdata["method_list"] = mdl unless mdl.empty? 790: 791: al = build_alias_summary_list(section) 792: secdata["aliases"] = al unless al.empty? 793: 794: co = build_constants_summary_list(section) 795: @values["constants"] = co unless co.empty? 796: 797: secdata 798: end 799: 800: @values 801: end
# File doc-tmp/rdoc/generator.rb, line 803 803: def write_on(f) 804: value_hash 805: 806: template = RDoc::TemplatePage.new(@template::BODY, 807: @template::FILE_PAGE, 808: @template::METHOD_LIST) 809: 810: template.write_html_on(f, @values) 811: end