Class: RDocF95::Generator::File

Inherits:
Context
  • Object
show all
Defined in:
lib/rdoc-f95/generator.rb

Overview

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.

Instance Attribute Summary collapse

Attributes inherited from Context

#context

Instance Method Summary collapse

Methods inherited from Context

#add_table_of_sections, #aref_to, #as_href, #build_alias_summary_list, build_class_list, #build_class_list, #build_constants_summary_list, #build_include_list, build_indicies, #build_method_detail_list, #build_method_summary_list, #build_requires_list, #collect_methods, #diagram_reference, #document_self, #find_file, #find_symbol, #href, #potentially_referenced_list, #url

Methods included from MarkUp

#cvs_url, #markup, #style_url

Constructor Details

#initialize(context, options, file_dir) ⇒ File

Returns a new instance of File.



708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
# File 'lib/rdoc-f95/generator.rb', line 708

def initialize(context, options, file_dir)
  super(context, options)

  @values = {}

  if options.all_one_file
    @path = filename_to_label
  else
    @path = http_url(file_dir)
  end

  @name = @context.file_relative_name

  collect_methods
  AllReferences.add(name, self)
  context.viewer = self
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



706
707
708
# File 'lib/rdoc-f95/generator.rb', line 706

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



705
706
707
# File 'lib/rdoc-f95/generator.rb', line 705

def path
  @path
end

Instance Method Details

#<=>(other) ⇒ Object



832
833
834
# File 'lib/rdoc-f95/generator.rb', line 832

def <=>(other)
  self.name <=> other.name
end

#file_attribute_valuesObject



813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
# File 'lib/rdoc-f95/generator.rb', line 813

def file_attribute_values
  full_path = @context.file_absolute_name
  short_name = ::File.basename full_path

  @values["title"] = CGI.escapeHTML("File: #{short_name}")

  if @context.diagram then
    @values["diagram"] = diagram_reference(@context.diagram)
  end

  @values["short_name"]   = CGI.escapeHTML(short_name)
  @values["full_path"]    = CGI.escapeHTML(full_path)
  @values["dtm_modified"] = @context.file_stat.mtime.to_s

  if @options.webcvs then
    @values["cvsurl"] = cvs_url @options.webcvs, @values["full_path"]
  end
end

#filename_to_labelObject



733
734
735
736
737
# File 'lib/rdoc-f95/generator.rb', line 733

def filename_to_label
  @context.file_relative_name.gsub(/%|\/|\?|\#/) do
    '%%%x' % $&[0].unpack('C')
  end
end

#http_url(file_dir) ⇒ Object



726
727
728
729
730
731
# File 'lib/rdoc-f95/generator.rb', line 726

def http_url(file_dir)
  suffix = ".html"
  suffix = ".xhtml" if @options.template == "xhtml"

  ::File.join file_dir, "#{@context.file_relative_name.tr '.', '_'}" + suffix
end

#index_nameObject



739
740
741
# File 'lib/rdoc-f95/generator.rb', line 739

def index_name
  name
end

#parent_nameObject



743
744
745
# File 'lib/rdoc-f95/generator.rb', line 743

def parent_name
  nil
end

#value_hashObject



747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
# File 'lib/rdoc-f95/generator.rb', line 747

def value_hash
  file_attribute_values
  add_table_of_sections

  @values["charset"]   = @options.charset
  @values["href"]      = path
  @values["style_url"] = style_url(path, @options.css)
  @values["mathml_xsl_url"] = style_url(path, "mathml.xsl")

  if @context.comment
    d = markup(@context.comment)
    @values["description"] = d if d.size > 0
  end

  ml = build_method_summary_list
  @values["methods"] = ml unless ml.empty?

  il = build_include_list(@context)
  @values["includes"] = il unless il.empty?

  rl = build_requires_list(@context)
  @values["requires"] = rl unless rl.empty?

  if @options.promiscuous
    file_context = nil
  else
    file_context = @context
  end


  @values["sections"] = @context.sections.map do |section|

    secdata = {
      "sectitle" => section.title,
      "secsequence" => section.sequence,
      "seccomment" => markup(section.comment)
    }

    cl = build_class_list(0, @context, section, file_context)
    @values["classlist"] = cl unless cl.empty?

    mdl = build_method_detail_list(section)
    secdata["method_list"] = mdl unless mdl.empty?

    al = build_alias_summary_list(section)
    secdata["aliases"] = al unless al.empty?

    co = build_constants_summary_list(section)
    @values["constants"] = co unless co.empty?

    secdata
  end

  @values
end

#write_on(f) ⇒ Object



803
804
805
806
807
808
809
810
811
# File 'lib/rdoc-f95/generator.rb', line 803

def write_on(f)
  value_hash

  template = RDocF95::TemplatePage.new(@template::BODY,
                                    @template::FILE_PAGE,
                                    @template::METHOD_LIST)

  template.write_html_on(f, @values)
end