Class: Jazzy::SourceDocument
Instance Attribute Summary collapse
#abstract, #access_control_level, #children, #column, #declaration, #default_impl_abstract, #discussion, #end_line, #file, #from_protocol_extension, #line, #mark, #modulename, #name, #nav_order, #other_language_declaration, #parameters, #parent_in_code, #parent_in_docs, #return, #start_line, #type, #typename, #url_name, #usr
Class Method Summary
collapse
Instance Method Summary
collapse
#abstract_glob, #alternative_abstract, #alternative_abstract_file, #fully_qualified_name, #namespace_ancestors, #namespace_path, #objc_category_name, #render?, #type?
Instance Attribute Details
#overview ⇒ Object
Returns the value of attribute overview.
7
8
9
|
# File 'lib/jazzy/source_document.rb', line 7
def overview
@overview
end
|
#readme_path ⇒ Object
Returns the value of attribute readme_path.
8
9
10
|
# File 'lib/jazzy/source_document.rb', line 8
def readme_path
@readme_path
end
|
Class Method Details
.make_index(readme_path) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/jazzy/source_document.rb', line 10
def self.make_index(readme_path)
SourceDocument.new.tap do |sd|
sd.name = 'index'
sd.children = []
sd.type = SourceDeclaration::Type.new 'document.markdown'
sd.readme_path = readme_path
end
end
|
Instance Method Details
#config ⇒ Object
19
20
21
|
# File 'lib/jazzy/source_document.rb', line 19
def config
Config.instance
end
|
#config_readme ⇒ Object
36
37
38
|
# File 'lib/jazzy/source_document.rb', line 36
def config_readme
readme_path.read if readme_path && readme_path.exist?
end
|
#content(source_module) ⇒ Object
27
28
29
30
|
# File 'lib/jazzy/source_document.rb', line 27
def content(source_module)
return readme_content(source_module) if name == 'index'
overview
end
|
#fallback_readme ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/jazzy/source_document.rb', line 40
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
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
|
# File 'lib/jazzy/source_document.rb', line 48
def generated_readme(source_module)
if podspec = config.podspec
<<-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
32
33
34
|
# File 'lib/jazzy/source_document.rb', line 32
def readme_content(source_module)
config_readme || fallback_readme || generated_readme(source_module)
end
|
#url ⇒ Object
23
24
25
|
# File 'lib/jazzy/source_document.rb', line 23
def url
name.downcase.strip.tr(' ', '-').gsub(/[^\w-]/, '') + '.html'
end
|