| Class | Generators::HtmlFile |
| In: |
generators/html_generator.rb
|
| Parent: | ContextUser |
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.
| name | [R] | |
| path | [R] |
# File generators/html_generator.rb, line 819
819: def initialize(context, options, file_dir)
820: super(context, options)
821:
822: @values = {}
823:
824: if options.all_one_file
825: @path = filename_to_label
826: else
827: @path = http_url(file_dir)
828: end
829:
830: @name = @context.file_relative_name
831:
832: collect_methods
833: AllReferences.add(name, self)
834: context.viewer = self
835: end
# File generators/html_generator.rb, line 936
936: def <=>(other)
937: self.name <=> other.name
938: end
# File generators/html_generator.rb, line 917
917: def file_attribute_values
918: full_path = @context.file_absolute_name
919: short_name = File.basename(full_path)
920:
921: @values["title"] = CGI.escapeHTML("File: #{short_name}")
922:
923: if @context.diagram
924: @values["diagram"] = diagram_reference(@context.diagram)
925: end
926:
927: @values["short_name"] = CGI.escapeHTML(short_name)
928: @values["full_path"] = CGI.escapeHTML(full_path)
929: @values["dtm_modified"] = @context.file_stat.mtime.to_s
930:
931: if @options.webcvs
932: @values["cvsurl"] = cvs_url( @options.webcvs, @values["full_path"] )
933: end
934: end
# File generators/html_generator.rb, line 842
842: def filename_to_label
843: @context.file_relative_name.gsub(/%|\/|\?|\#/) {|s| '%' + ("%x" % s[0]) }
844: end
# File generators/html_generator.rb, line 837
837: def http_url(file_dir)
838: File.join(file_dir, @context.file_relative_name.tr('.', '_')) +
839: '.' + @options.template
840: end
# File generators/html_generator.rb, line 854
854: def value_hash
855: file_attribute_values
856: add_table_of_sections
857:
858: @values["charset"] = @options.charset
859: @values["href"] = path
860: @values["style_url"] = style_url(path, @options.css)
861:
862: if @context.comment
863: d = markup(@context.comment)
864: @values["description"] = d if d.size > 0
865: end
866:
867: ml = build_method_summary_list
868: @values["methods"] = ml unless ml.empty?
869:
870: il = build_include_list(@context)
871: @values["includes"] = il unless il.empty?
872:
873: rl = build_requires_list(@context)
874: @values["requires"] = rl unless rl.empty?
875:
876: if @options.promiscuous
877: file_context = nil
878: else
879: file_context = @context
880: end
881:
882:
883: @values["sections"] = @context.sections.map do |section|
884:
885: secdata = {
886: "sectitle" => section.title,
887: "secsequence" => section.sequence,
888: "seccomment" => markup(section.comment)
889: }
890:
891: cl = build_class_list(0, @context, section, file_context)
892: @values["classlist"] = cl unless cl.empty?
893:
894: mdl = build_method_detail_list(section)
895: secdata["method_list"] = mdl unless mdl.empty?
896:
897: al = build_alias_summary_list(section)
898: secdata["aliases"] = al unless al.empty?
899:
900: co = build_constants_summary_list(section)
901: @values["constants"] = co unless co.empty?
902:
903: secdata
904: end
905:
906: @values
907: end