Class: Jazzy::SourceDocument

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

Overview

Standalone markdown docs including index.html

Instance Attribute Summary collapse

Attributes inherited from SourceDeclaration

#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

Methods inherited from SourceDeclaration

#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

#initializeSourceDocument

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

#overviewObject

Returns the value of attribute overview.



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

def overview
  @overview
end

#readme_pathObject

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

#configObject



35
36
37
# File 'lib/jazzy/source_document.rb', line 35

def config
  Config.instance
end

#config_readmeObject



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_readmeObject



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

#omit_content_from_parent?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


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

def render_as_page?
  true
end

#urlObject



39
40
41
# File 'lib/jazzy/source_document.rb', line 39

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