Class: Jazzy::SourceDocument

Inherits:
SourceDeclaration show all
Defined in:
lib/jazzy/source_document.rb

Instance Attribute Summary collapse

Attributes inherited from SourceDeclaration

#abstract, #access_control_level, #children, #column, #declaration, #default_impl_abstract, #discussion, #end_line, #file, #from_protocol_extension, #line, #mark, #name, #nav_order, #other_language_declaration, #parameters, #parent_in_code, #parent_in_docs, #return, #start_line, #type, #typename, #usr

Instance Method Summary collapse

Methods inherited from SourceDeclaration

#abstract_glob, #alternative_abstract, #alternative_abstract_file, #fully_qualified_name, #namespace_ancestors, #namespace_path, #objc_category_name, #render?, #type?

Instance Attribute Details

#overviewObject

Returns the value of attribute overview.



7
8
9
# File 'lib/jazzy/source_document.rb', line 7

def overview
  @overview
end

#readme_pathObject

Returns the value of attribute readme_path.



8
9
10
# File 'lib/jazzy/source_document.rb', line 8

def readme_path
  @readme_path
end

Instance Method Details

#configObject



10
11
12
# File 'lib/jazzy/source_document.rb', line 10

def config
  Config.instance
end

#config_readmeObject



27
28
29
# File 'lib/jazzy/source_document.rb', line 27

def config_readme
  readme_path.read if readme_path && readme_path.exist?
end

#content(source_module) ⇒ Object



18
19
20
21
# File 'lib/jazzy/source_document.rb', line 18

def content(source_module)
  return readme_content(source_module) if name == 'index'
  overview
end

#fallback_readmeObject



31
32
33
34
35
36
37
# File 'lib/jazzy/source_document.rb', line 31

def fallback_readme
  %w(README.md README.markdown README.mdown README).each do |potential_name|
    file = config.source_directory + potential_name
    return file.read if file.exist?
  end
  false
end

#generated_readme(source_module) ⇒ Object



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

def 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_content(source_module) ⇒ Object



23
24
25
# File 'lib/jazzy/source_document.rb', line 23

def readme_content(source_module)
  config_readme || fallback_readme || generated_readme(source_module)
end

#urlObject



14
15
16
# File 'lib/jazzy/source_document.rb', line 14

def url
  name.downcase.strip.tr(' ', '-').gsub(/[^\w-]/, '') + '.html'
end