Class: YARD::Tags::DefaultFactory
- Inherits:
-
Object
- Object
- YARD::Tags::DefaultFactory
- Defined in:
- lib/yard/tags/default_factory.rb
Constant Summary collapse
- TYPELIST_OPENING_CHARS =
'[({<'
- TYPELIST_CLOSING_CHARS =
'>})]'
Instance Method Summary collapse
-
#parse_tag(tag_name, text) ⇒ Tag
Parses tag text and creates a new tag with descriptive text.
-
#parse_tag_with_name(tag_name, text) ⇒ Tag
Parses tag text and creates a new tag with a key name and descriptive text.
- #parse_tag_with_options(tag_name, text) ⇒ Object
- #parse_tag_with_title_and_text(tag_name, text) ⇒ Object
-
#parse_tag_with_types(tag_name, text) ⇒ Tag
Parses tag text and creates a new tag with formally declared types and descriptive text.
-
#parse_tag_with_types_and_name(tag_name, text) ⇒ Tag
Parses tag text and creates a new tag with formally declared types, a key name and descriptive text.
-
#parse_tag_with_types_and_title(tag_name, text) ⇒ Tag
Parses tag text and creates a new tag with formally declared types, a title on the first line and descriptive text.
- #parse_tag_with_types_name_and_default(tag_name, text) ⇒ Object
Instance Method Details
#parse_tag(tag_name, text) ⇒ Tag
Parses tag text and creates a new tag with descriptive text
13 14 15 |
# File 'lib/yard/tags/default_factory.rb', line 13 def parse_tag(tag_name, text) Tag.new(tag_name, text.strip) end |
#parse_tag_with_name(tag_name, text) ⇒ Tag
Parses tag text and creates a new tag with a key name and descriptive text
22 23 24 25 |
# File 'lib/yard/tags/default_factory.rb', line 22 def parse_tag_with_name(tag_name, text) name, text = *extract_name_from_text(text) Tag.new(tag_name, text, nil, name) end |
#parse_tag_with_options(tag_name, text) ⇒ Object
89 90 91 92 |
# File 'lib/yard/tags/default_factory.rb', line 89 def (tag_name, text) name, text = *extract_name_from_text(text) OptionTag.new(tag_name, name, parse_tag_with_types_name_and_default(tag_name, text)) end |
#parse_tag_with_title_and_text(tag_name, text) ⇒ Object
70 71 72 73 |
# File 'lib/yard/tags/default_factory.rb', line 70 def parse_tag_with_title_and_text(tag_name, text) title, desc = *extract_title_and_desc_from_text(text) Tag.new(tag_name, desc, nil, title) end |
#parse_tag_with_types(tag_name, text) ⇒ Tag
Parses tag text and creates a new tag with formally declared types and descriptive text
33 34 35 36 37 |
# File 'lib/yard/tags/default_factory.rb', line 33 def parse_tag_with_types(tag_name, text) name, types, text = *extract_types_and_name_from_text(text) raise TagFormatError, "cannot specify a name before type list for '@#{tag_name}'" if name Tag.new(tag_name, text, types) end |
#parse_tag_with_types_and_name(tag_name, text) ⇒ Tag
Parses tag text and creates a new tag with formally declared types, a key name and descriptive text
45 46 47 48 49 |
# File 'lib/yard/tags/default_factory.rb', line 45 def parse_tag_with_types_and_name(tag_name, text) name, types, text = *extract_types_and_name_from_text(text) name, text = *extract_name_from_text(text) unless name Tag.new(tag_name, text, types, name) end |
#parse_tag_with_types_and_title(tag_name, text) ⇒ Tag
Parses tag text and creates a new tag with formally declared types, a title on the first line and descriptive text
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/yard/tags/default_factory.rb', line 57 def parse_tag_with_types_and_title(tag_name, text) name, types, text = *extract_types_and_name_from_text_unstripped(text) if name title = name desc = text else title, desc = *extract_title_and_desc_from_text(text) end Tag.new(tag_name, desc, types, title) rescue TagFormatError Tag.new(tag_name, '', types, nil) end |
#parse_tag_with_types_name_and_default(tag_name, text) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/yard/tags/default_factory.rb', line 75 def parse_tag_with_types_name_and_default(tag_name, text) # Can't allow () in a default tag, otherwise the grammar is too ambiguous when types is omitted. open = TYPELIST_OPENING_CHARS.delete('(') close = TYPELIST_CLOSING_CHARS.delete(')') name, types, text = *extract_types_and_name_from_text(text, open, close) name, text = *extract_name_from_text(text) unless name if text && text.start_with?('(') _, default, text = *extract_types_and_name_from_text(text, '(', ')') DefaultTag.new(tag_name, text, types, name, default) else DefaultTag.new(tag_name, text, types, name, nil) end end |