Class: Jazzy::SourceDeclaration
- Inherits:
-
Object
- Object
- Jazzy::SourceDeclaration
- Defined in:
- lib/jazzy/source_declaration.rb,
lib/jazzy/source_declaration/type.rb,
lib/jazzy/source_declaration/access_control_level.rb
Direct Known Subclasses
Defined Under Namespace
Classes: AccessControlLevel, Type
Instance Attribute Summary collapse
-
#abstract ⇒ Object
Returns the value of attribute abstract.
-
#access_control_level ⇒ Object
Returns the value of attribute access_control_level.
-
#children ⇒ Object
counterpart of parent_in_docs.
-
#column ⇒ Object
Returns the value of attribute column.
-
#declaration ⇒ Object
Returns the value of attribute declaration.
-
#default_impl_abstract ⇒ Object
Returns the value of attribute default_impl_abstract.
-
#deprecated ⇒ Object
Returns the value of attribute deprecated.
-
#deprecation_message ⇒ Object
Returns the value of attribute deprecation_message.
-
#discussion ⇒ Object
Returns the value of attribute discussion.
-
#end_line ⇒ Object
Returns the value of attribute end_line.
-
#file ⇒ Object
Returns the value of attribute file.
-
#from_protocol_extension ⇒ Object
Returns the value of attribute from_protocol_extension.
-
#line ⇒ Object
Returns the value of attribute line.
-
#mark ⇒ Object
Returns the value of attribute mark.
-
#modulename ⇒ Object
Returns the value of attribute modulename.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nav_order ⇒ Object
Returns the value of attribute nav_order.
-
#objc_name ⇒ Object
Returns the value of attribute objc_name.
-
#other_language_declaration ⇒ Object
Returns the value of attribute other_language_declaration.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#parent_in_code ⇒ Object
Element containing this declaration in the code.
-
#parent_in_docs ⇒ Object
Logical parent in the documentation.
-
#return ⇒ Object
Returns the value of attribute return.
-
#start_line ⇒ Object
Returns the value of attribute start_line.
-
#type ⇒ Object
kind of declaration (e.g. class, variable, function).
-
#typename ⇒ Object
static type of declared element (e.g. String.Type -> ()).
-
#unavailable ⇒ Object
Returns the value of attribute unavailable.
-
#unavailable_message ⇒ Object
Returns the value of attribute unavailable_message.
-
#url ⇒ Object
Returns the value of attribute url.
-
#url_name ⇒ Object
Returns the value of attribute url_name.
-
#usr ⇒ Object
Returns the value of attribute usr.
Instance Method Summary collapse
- #abstract_glob ⇒ Object
- #alternative_abstract ⇒ Object
- #alternative_abstract_file ⇒ Object
- #display_declaration ⇒ Object
- #display_other_language_declaration ⇒ Object
- #fully_qualified_name ⇒ Object
-
#fully_qualified_name_regexp ⇒ Object
:name doesn’t include any generic type params.
- #namespace_ancestors ⇒ Object
-
#namespace_path ⇒ Object
Chain of parent_in_code from top level to self.
-
#objc_category_name ⇒ Object
If this declaration is an objc category, returns an array with the name of the extended objc class and the category name itself, i.e.
-
#omit_content_from_parent? ⇒ Boolean
When referencing this item from its parent category, include the content or just link to it directly?.
-
#render_as_page? ⇒ Boolean
Give the item its own page or just inline into parent?.
- #usage_discouraged? ⇒ Boolean
Instance Attribute Details
#abstract ⇒ Object
Returns the value of attribute abstract.
92 93 94 |
# File 'lib/jazzy/source_declaration.rb', line 92 def abstract @abstract end |
#access_control_level ⇒ Object
Returns the value of attribute access_control_level.
100 101 102 |
# File 'lib/jazzy/source_declaration.rb', line 100 def access_control_level @access_control_level end |
#children ⇒ Object
counterpart of parent_in_docs
30 31 32 |
# File 'lib/jazzy/source_declaration.rb', line 30 def children @children end |
#column ⇒ Object
Returns the value of attribute column.
85 86 87 |
# File 'lib/jazzy/source_declaration.rb', line 85 def column @column end |
#declaration ⇒ Object
Returns the value of attribute declaration.
90 91 92 |
# File 'lib/jazzy/source_declaration.rb', line 90 def declaration @declaration end |
#default_impl_abstract ⇒ Object
Returns the value of attribute default_impl_abstract.
93 94 95 |
# File 'lib/jazzy/source_declaration.rb', line 93 def default_impl_abstract @default_impl_abstract end |
#deprecated ⇒ Object
Returns the value of attribute deprecated.
105 106 107 |
# File 'lib/jazzy/source_declaration.rb', line 105 def deprecated @deprecated end |
#deprecation_message ⇒ Object
Returns the value of attribute deprecation_message.
106 107 108 |
# File 'lib/jazzy/source_declaration.rb', line 106 def @deprecation_message end |
#discussion ⇒ Object
Returns the value of attribute discussion.
95 96 97 |
# File 'lib/jazzy/source_declaration.rb', line 95 def discussion @discussion end |
#end_line ⇒ Object
Returns the value of attribute end_line.
102 103 104 |
# File 'lib/jazzy/source_declaration.rb', line 102 def end_line @end_line end |
#file ⇒ Object
Returns the value of attribute file.
83 84 85 |
# File 'lib/jazzy/source_declaration.rb', line 83 def file @file end |
#from_protocol_extension ⇒ Object
Returns the value of attribute from_protocol_extension.
94 95 96 |
# File 'lib/jazzy/source_declaration.rb', line 94 def from_protocol_extension @from_protocol_extension end |
#line ⇒ Object
Returns the value of attribute line.
84 85 86 |
# File 'lib/jazzy/source_declaration.rb', line 84 def line @line end |
#mark ⇒ Object
Returns the value of attribute mark.
99 100 101 |
# File 'lib/jazzy/source_declaration.rb', line 99 def mark @mark end |
#modulename ⇒ Object
Returns the value of attribute modulename.
87 88 89 |
# File 'lib/jazzy/source_declaration.rb', line 87 def modulename @modulename end |
#name ⇒ Object
Returns the value of attribute name.
88 89 90 |
# File 'lib/jazzy/source_declaration.rb', line 88 def name @name end |
#nav_order ⇒ Object
Returns the value of attribute nav_order.
103 104 105 |
# File 'lib/jazzy/source_declaration.rb', line 103 def nav_order @nav_order end |
#objc_name ⇒ Object
Returns the value of attribute objc_name.
89 90 91 |
# File 'lib/jazzy/source_declaration.rb', line 89 def objc_name @objc_name end |
#other_language_declaration ⇒ Object
Returns the value of attribute other_language_declaration.
91 92 93 |
# File 'lib/jazzy/source_declaration.rb', line 91 def other_language_declaration @other_language_declaration end |
#parameters ⇒ Object
Returns the value of attribute parameters.
97 98 99 |
# File 'lib/jazzy/source_declaration.rb', line 97 def parameters @parameters end |
#parent_in_code ⇒ Object
Element containing this declaration in the code
23 24 25 |
# File 'lib/jazzy/source_declaration.rb', line 23 def parent_in_code @parent_in_code end |
#parent_in_docs ⇒ Object
Logical parent in the documentation. May differ from parent_in_code because of top-level categories and merged extensions.
27 28 29 |
# File 'lib/jazzy/source_declaration.rb', line 27 def parent_in_docs @parent_in_docs end |
#return ⇒ Object
Returns the value of attribute return.
96 97 98 |
# File 'lib/jazzy/source_declaration.rb', line 96 def return @return end |
#start_line ⇒ Object
Returns the value of attribute start_line.
101 102 103 |
# File 'lib/jazzy/source_declaration.rb', line 101 def start_line @start_line end |
#type ⇒ Object
kind of declaration (e.g. class, variable, function)
7 8 9 |
# File 'lib/jazzy/source_declaration.rb', line 7 def type @type end |
#typename ⇒ Object
static type of declared element (e.g. String.Type -> ())
9 10 11 |
# File 'lib/jazzy/source_declaration.rb', line 9 def typename @typename end |
#unavailable ⇒ Object
Returns the value of attribute unavailable.
107 108 109 |
# File 'lib/jazzy/source_declaration.rb', line 107 def unavailable @unavailable end |
#unavailable_message ⇒ Object
Returns the value of attribute unavailable_message.
108 109 110 |
# File 'lib/jazzy/source_declaration.rb', line 108 def @unavailable_message end |
#url ⇒ Object
Returns the value of attribute url.
98 99 100 |
# File 'lib/jazzy/source_declaration.rb', line 98 def url @url end |
#url_name ⇒ Object
Returns the value of attribute url_name.
104 105 106 |
# File 'lib/jazzy/source_declaration.rb', line 104 def url_name @url_name end |
#usr ⇒ Object
Returns the value of attribute usr.
86 87 88 |
# File 'lib/jazzy/source_declaration.rb', line 86 def usr @usr end |
Instance Method Details
#abstract_glob ⇒ Object
127 128 129 130 131 132 |
# File 'lib/jazzy/source_declaration.rb', line 127 def abstract_glob return [] unless Config.instance.abstract_glob_configured && Config.instance.abstract_glob Config.instance.abstract_glob.select { |e| File.file? e } end |
#alternative_abstract ⇒ Object
114 115 116 117 118 |
# File 'lib/jazzy/source_declaration.rb', line 114 def alternative_abstract if file = alternative_abstract_file Pathname(file).read end end |
#alternative_abstract_file ⇒ Object
120 121 122 123 124 125 |
# File 'lib/jazzy/source_declaration.rb', line 120 def alternative_abstract_file abstract_glob.select do |f| # allow Structs.md or Structures.md [name, url_name].include?(File.basename(f).split('.').first) end.first end |
#display_declaration ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/jazzy/source_declaration.rb', line 70 def display_declaration if Config.instance.hide_declarations == 'objc' other_language_declaration else declaration end end |
#display_other_language_declaration ⇒ Object
78 79 80 81 |
# File 'lib/jazzy/source_declaration.rb', line 78 def display_other_language_declaration other_language_declaration unless %w[swift objc].include? Config.instance.hide_declarations end |
#fully_qualified_name ⇒ Object
51 52 53 |
# File 'lib/jazzy/source_declaration.rb', line 51 def fully_qualified_name namespace_path.map(&:name).join('.') end |
#fully_qualified_name_regexp ⇒ Object
:name doesn’t include any generic type params. This regexp matches any generic type params in parent names.
57 58 59 60 61 |
# File 'lib/jazzy/source_declaration.rb', line 57 def fully_qualified_name_regexp Regexp.new(namespace_path.map(&:name) .map { |n| Regexp.escape(n) } .join('(?:<.*?>)?\.')) end |
#namespace_ancestors ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/jazzy/source_declaration.rb', line 43 def namespace_ancestors if parent_in_code parent_in_code.namespace_path else [] end end |
#namespace_path ⇒ Object
Chain of parent_in_code from top level to self. (Includes self.)
39 40 41 |
# File 'lib/jazzy/source_declaration.rb', line 39 def namespace_path namespace_ancestors + [self] end |
#objc_category_name ⇒ Object
If this declaration is an objc category, returns an array with the name of the extended objc class and the category name itself, i.e. [“NSString”, “MyMethods”], nil otherwise.
66 67 68 |
# File 'lib/jazzy/source_declaration.rb', line 66 def objc_category_name name.split(/[\(\)]/) if type.objc_category? end |
#omit_content_from_parent? ⇒ Boolean
When referencing this item from its parent category, include the content or just link to it directly?
18 19 20 |
# File 'lib/jazzy/source_declaration.rb', line 18 def omit_content_from_parent? false end |
#render_as_page? ⇒ Boolean
Give the item its own page or just inline into parent?
12 13 14 |
# File 'lib/jazzy/source_declaration.rb', line 12 def render_as_page? children.any? end |
#usage_discouraged? ⇒ Boolean
110 111 112 |
# File 'lib/jazzy/source_declaration.rb', line 110 def usage_discouraged? unavailable || deprecated end |