Sha256: 6df91a507a57a5d462393770a864254f86d371a20dcfdd70ac16516159dfdcb3

Contents?: true

Size: 1.14 KB

Versions: 5

Compression:

Stored size: 1.14 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

      rendered_readme = Jazzy.markdown.render(readme)
      "<div class='readme'>#{rendered_readme}</div>"
    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 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

5 entries across 5 versions & 1 rubygems

Version Path
jazzy-0.1.4 lib/jazzy/readme_generator.rb
jazzy-0.1.3 lib/jazzy/readme_generator.rb
jazzy-0.1.2 lib/jazzy/readme_generator.rb
jazzy-0.1.1 lib/jazzy/readme_generator.rb
jazzy-0.1.0 lib/jazzy/readme_generator.rb