Class: RDoc::Generator::SHtml

Inherits:
Object
  • Object
show all
Includes:
ERB::Util, SDoc::GitHub, SDoc::Helpers, SDoc::Templatable
Defined in:
lib/wpdoc/generator/shtml.rb

Defined Under Namespace

Classes: FilesTree

Constant Summary collapse

GENERATOR_DIRS =
[File.join('wpdoc', 'generator'), File.join('rdoc', 'generator')]
TYPE_CLASS =

Used in js to reduce index sizes

1
TYPE_METHOD =
2
TYPE_FILE =
3
TREE_FILE =
File.join 'panel', 'tree.js'
SEARCH_INDEX_FILE =
File.join 'panel', 'search_index.js'
FILE_DIR =
'files'
CLASS_DIR =
'classes'
RESOURCES_DIR =
File.join('resources', '.')

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SDoc::Helpers

#each_letter_group

Methods included from SDoc::Templatable

#eval_template, #include_template, #render_template

Methods included from SDoc::GitHub

#github_url

Constructor Details

#initialize(options) ⇒ SHtml

Returns a new instance of SHtml.

Raises:

  • (RDoc::Error)


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/wpdoc/generator/shtml.rb', line 63

def initialize(options)
  @options = options
  if @options.respond_to?('diagram=')
    @options.diagram = false
  end
  @github_url_cache = {}

  template = 'direct'

  templ_dir = self.class.template_dir template

  raise RDoc::Error, "could not find template #{template.inspect}" unless
  templ_dir

  @template_dir = Pathname.new File.expand_path(templ_dir)
  @basedir = Pathname.pwd.expand_path
end

Instance Attribute Details

#basedirObject (readonly)

Returns the value of attribute basedir.



47
48
49
# File 'lib/wpdoc/generator/shtml.rb', line 47

def basedir
  @basedir
end

Class Method Details

.for(options) ⇒ Object



49
50
51
# File 'lib/wpdoc/generator/shtml.rb', line 49

def self.for(options)
  self.new(options)
end

.template_dir(template) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/wpdoc/generator/shtml.rb', line 53

def self.template_dir template
  $LOAD_PATH.map do |path|
    GENERATOR_DIRS.map do |dir|
      File.join path, dir, 'template', template
    end
  end.flatten.find do |dir|
    File.directory? dir
  end
end

Instance Method Details

#class_dirObject



95
96
97
# File 'lib/wpdoc/generator/shtml.rb', line 95

def class_dir
  CLASS_DIR
end

#file_dirObject



99
100
101
# File 'lib/wpdoc/generator/shtml.rb', line 99

def file_dir
  FILE_DIR
end

#generate(top_levels) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/wpdoc/generator/shtml.rb', line 81

def generate( top_levels )
  @outputdir = Pathname.new( @options.op_dir ).expand_path( @basedir )
  @files = top_levels.sort
  @classes = RDoc::TopLevel.all_classes_and_modules.sort

  # Now actually write the output
  copy_resources
  generate_class_tree
  generate_search_index
  generate_file_files
  generate_class_files
  generate_index_file
end