Sha256: 4c4ac60f9496572847442c05b3b749b2663c8b06fbe14d952c1c554a8a5fe061

Contents?: true

Size: 1.07 KB

Versions: 15

Compression:

Stored size: 1.07 KB

Contents

require 'pathname'

require 'jazzy/jazzy_markdown'

module Jazzy
  module ReadmeGenerator
    extend Config::Mixin

    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

    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

    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
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
jazzy-0.8.2 lib/jazzy/readme_generator.rb
jazzy-0.8.1 lib/jazzy/readme_generator.rb
jazzy-0.8.0 lib/jazzy/readme_generator.rb
jazzy-0.7.5 lib/jazzy/readme_generator.rb
jazzy-0.7.4 lib/jazzy/readme_generator.rb
jazzy-0.7.3 lib/jazzy/readme_generator.rb
jazzy-0.7.2 lib/jazzy/readme_generator.rb
jazzy-0.7.1 lib/jazzy/readme_generator.rb
jazzy-0.7.0 lib/jazzy/readme_generator.rb
jazzy-0.6.3 lib/jazzy/readme_generator.rb
jazzy-0.6.2 lib/jazzy/readme_generator.rb
jazzy-0.6.1 lib/jazzy/readme_generator.rb
jazzy-0.6.0 lib/jazzy/readme_generator.rb
jazzy-0.5.0 lib/jazzy/readme_generator.rb
jazzy-0.4.1 lib/jazzy/readme_generator.rb