Class: Jazzy::SourceDocument
Overview
Standalone markdown docs including index.html
Instance Attribute Summary collapse
#abstract, #access_control_level, #children, #column, #declaration, #default_impl_abstract, #deprecated, #deprecation_message, #discussion, #end_line, #file, #from_protocol_extension, #line, #mark, #modulename, #name, #nav_order, #objc_name, #other_language_declaration, #parameters, #parent_in_code, #parent_in_docs, #return, #start_line, #type, #typename, #unavailable, #unavailable_message, #url_name, #usr
Class Method Summary
collapse
Instance Method Summary
collapse
#abstract_glob, #alternative_abstract, #alternative_abstract_file, #display_declaration, #display_other_language_declaration, #fully_qualified_name, #fully_qualified_name_regexp, #namespace_ancestors, #namespace_path, #objc_category_name, #usage_discouraged?
Constructor Details
Returns a new instance of SourceDocument.
11
12
13
14
15
16
17
18
|
# File 'lib/jazzy/source_document.rb', line 11
def initialize
super
self.children = []
self.parameters = []
self.abstract = ''
self.type = SourceDeclaration::Type.markdown
self.mark = SourceMark.new
end
|
Instance Attribute Details
#overview ⇒ Object
Returns the value of attribute overview.
8
9
10
|
# File 'lib/jazzy/source_document.rb', line 8
def overview
@overview
end
|
#readme_path ⇒ Object
Returns the value of attribute readme_path.
9
10
11
|
# File 'lib/jazzy/source_document.rb', line 9
def readme_path
@readme_path
end
|
Class Method Details
.make_index(readme_path) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/jazzy/source_document.rb', line 20
def self.make_index(readme_path)
SourceDocument.new.tap do |sd|
sd.name = 'index'
sd.readme_path = readme_path
end
end
|
Instance Method Details
#config ⇒ Object
35
36
37
|
# File 'lib/jazzy/source_document.rb', line 35
def config
Config.instance
end
|
#config_readme ⇒ Object
52
53
54
|
# File 'lib/jazzy/source_document.rb', line 52
def config_readme
readme_path.read if readme_path && readme_path.exist?
end
|
#content(source_module) ⇒ Object
43
44
45
46
|
# File 'lib/jazzy/source_document.rb', line 43
def content(source_module)
return readme_content(source_module) if name == 'index'
overview
end
|
#fallback_readme ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/jazzy/source_document.rb', line 56
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/jazzy/source_document.rb', line 64
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
|
#omit_content_from_parent? ⇒ Boolean
31
32
33
|
# File 'lib/jazzy/source_document.rb', line 31
def omit_content_from_parent?
true
end
|
#readme_content(source_module) ⇒ Object
48
49
50
|
# File 'lib/jazzy/source_document.rb', line 48
def readme_content(source_module)
config_readme || fallback_readme || generated_readme(source_module)
end
|
#render_as_page? ⇒ Boolean
27
28
29
|
# File 'lib/jazzy/source_document.rb', line 27
def render_as_page?
true
end
|
#url ⇒ Object
39
40
41
|
# File 'lib/jazzy/source_document.rb', line 39
def url
name.downcase.strip.tr(' ', '-').gsub(/[^\w-]/, '') + '.html'
end
|