Module: Jazzy::ReadmeGenerator

Extended by:
Config::Mixin
Defined in:
lib/jazzy/readme_generator.rb

Class Method Summary collapse

Methods included from Config::Mixin

config

Class Method Details

.generate(source_module) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/jazzy/readme_generator.rb', line 9

def self.generate(source_module)
  readme = readme_path

  unless readme && readme.exist? && readme = readme.read
    readme = generated_readme(source_module)
  end

  Jazzy.markdown.render(readme)
end

.generated_readme(source_module) ⇒ Object



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
# File 'lib/jazzy/readme_generator.rb', line 28

def self.generated_readme(source_module)
  if podspec = config.podspec
    ### License

    # <a href="#{license[:url]}">#{license[:license]}</a>
    <<-EOS
# #{podspec.name}

### #{podspec.summary}

#{podspec.description}

### Installation

```ruby
pod '#{podspec.name}'
```

### Authors

#{source_module.author_name}
EOS
  else
    <<-EOS
# #{source_module.name}

### Authors

#{source_module.author_name}
EOS
  end
end

.readme_pathObject



19
20
21
22
23
24
25
26
# File 'lib/jazzy/readme_generator.rb', line 19

def self.readme_path
  return config.readme_path if config.readme_path
  %w[README.md README.markdown README.mdown README].each do |potential_name|
    file = config.source_directory + potential_name
    return file if file.exist?
  end
  nil
end