Class: RDoc::Generator::SolarFish

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc/generator/solarfish.rb

Overview

SolarFish generator. Registers command line options and generates HTML and/or JSON output for given RDoc documentation and options.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(store, options) ⇒ SolarFish

Returns a new instance of SolarFish.



93
94
95
96
# File 'lib/rdoc/generator/solarfish.rb', line 93

def initialize(store, options)
  @store = store
  @options = options
end

Class Method Details

.setup_options(rdoc_options) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/rdoc/generator/solarfish.rb', line 27

def self.setup_options(rdoc_options)
  rdoc_options.sf_htmlfile = Settings::DEFAULT_HTMLFILE

  opt = rdoc_options.option_parser
  opt.separator 'SolarFish generator options:'

  opt.separator nil
  opt.on('--sf-htmlfile=FILE', String,
         'Set output HTML file name.',
         "Defaults to '#{Settings::DEFAULT_HTMLFILE}'.") do |value|
    rdoc_options.sf_htmlfile = value
  end

  opt.separator nil
  opt.on('--sf-jsonfile=FILE', String,
         'Set output JSON file name.',
         'Empty by default.') do |value|
    rdoc_options.sf_jsonfile = value
  end

  opt.separator nil
  opt.on('--sf-template=NAME', String,
         "Set template. Defaults to '#{Settings::DEFAULT_TEMPLATE}'.",
         "If name contains slash, it's a path, and",
         "otherwise it's a name of installed template.",
         'Installed templates:',
         *(TemplateLoader.templates_list
           .map { |s| " - #{s}" })) do |value|
    rdoc_options.sf_template = TemplateLoader.template_path(value)
  end

  opt.separator nil
  opt.on('--sf-theme=NAME', String,
         "Set theme. Defaults to '#{Settings::DEFAULT_THEME}'. Specify",
         'multiple times to merge several themes. Every',
         'next theme overwrites options set by previous',
         "themes. If name contains slash, it's a path,",
         "and otherwise it's a name of installed theme.",
         'Installed themes:',
         *(ThemeLoader.themes_list
            .map { |s| " - #{s}" })) do |value|
    rdoc_options.sf_themes ||= []
    rdoc_options.sf_themes << ThemeLoader.theme_path(value)
  end

  opt.separator nil
  opt.on('--sf-prefix=PREFIX', String,
         'Set URL prefix for links to stylesheets and',
         'scripts in generated HTML. Empty by default.') do |value|
    rdoc_options.sf_prefix = value
  end

  opt.separator nil
  opt.on('--sf-filter-classes=REGEX', String,
         'Include only classes and modules that',
         'match regex.') do |value|
    rdoc_options.sf_filter_classes = Regexp.new(value)
  end

  opt.separator nil
  opt.on('--sf-filter-members=REGEX', String,
         'Include only members that match regex.') do |value|
    rdoc_options.sf_filter_members = Regexp.new(value)
  end
end

Instance Method Details

#class_dirObject



98
99
100
# File 'lib/rdoc/generator/solarfish.rb', line 98

def class_dir
  nil
end

#file_dirObject



102
103
104
# File 'lib/rdoc/generator/solarfish.rb', line 102

def file_dir
  nil
end

#generateObject



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/rdoc/generator/solarfish.rb', line 106

def generate
  @options.sf_themes ||= [ThemeLoader.theme_path(Settings::DEFAULT_THEME)]
  @options.sf_template ||= TemplateLoader.template_path(Settings::DEFAULT_TEMPLATE)

  doc_loader = DocLoader.new(@options, @store)
  classes = doc_loader.load

  theme_loader = ThemeLoader.new(@options)
  theme, theme_files = theme_loader.load

  data = {
    title:   @options.title,
    theme:   theme,
    classes: classes
  }

  if @options.sf_jsonfile
    json_writer = JSONWriter.new(@options)
    json_writer.write(data)
  end

  if @options.sf_htmlfile
    template_loader = TemplateLoader.new(@options)
    template = template_loader.load

    html_writer = HTMLWriter.new(@options)
    html_writer.write(data, theme_files, template)
  end
end