module YARD::Templates::Helpers::MarkupHelper
def clear_markup_cache
-
(void)
-
def clear_markup_cache self.markup_cache = {} end
def load_markup_provider(type = options.markup)
-
(Boolean)
- whether the markup provider was successfully loaded.
def load_markup_provider(type = options.markup) return true if MarkupHelper.markup_cache[type] MarkupHelper.markup_cache[type] ||= {} providers = MARKUP_PROVIDERS[type.to_sym] return true if providers && providers.empty? if providers && options.markup_provider providers = providers.select {|p| p[:lib] == options.markup_provider } end if providers.nil? || providers.empty? log.error "Invalid markup type '#{type}' or markup provider " \ "(#{options.markup_provider}) is not registered." return false end # Search for provider, return the library class name as const if found providers.each do |provider| begin require provider[:lib].to_s; rescue LoadError; next end if provider[:lib] begin klass = eval("::" + provider[:const]); rescue NameError; next end # rubocop:disable Lint/Eval MarkupHelper.markup_cache[type][:provider] = provider[:lib] # Cache the provider MarkupHelper.markup_cache[type][:class] = klass return true end # Show error message telling user to install first potential provider lib = providers.first[:lib] || type log.error "Missing '#{lib}' gem for #{type.to_s.capitalize} formatting. Install it with `gem install #{lib}`" false end
def markup_class(type = options.markup)
-
(Class)
- the markup class
Parameters:
-
type
(Symbol
) -- the markup type (:rdoc, :markdown, etc.)
def markup_class(type = options.markup) load_markup_provider(type) MarkupHelper.markup_cache[type][:class] end
def markup_file_contents(contents)
- Since: - 0.6.0
Returns:
-
(String)
- the file contents minus any preprocessing tags
Deprecated:
- Use {CodeObjects::ExtraFileObject#contents} instead
def markup_file_contents(contents) contents =~ MARKUP_FILE_SHEBANG ? $' : contents end
def markup_for_file(contents, filename)
- Since: - 0.6.0
Other tags:
- See: MARKUP_EXTENSIONS -
Returns:
-
(Symbol)
- the markup type recognized for the file
Parameters:
-
contents
(String
) -- Unused. Was necessary prior to 0.7.0.
def markup_for_file(contents, filename) return $1.to_sym if contents && contents =~ MARKUP_FILE_SHEBANG # Shebang support ext = (File.extname(filename)[1..-1] || '').downcase MARKUP_EXTENSIONS.each do |type, exts| return type if exts.include?(ext) end options.markup end
def markup_provider(type = options.markup)
-
(Symbol)
- the markup provider name (usually the gem name of the library)
Parameters:
-
type
(Symbol
) -- the markup type (:rdoc, :markdown, etc.)
def markup_provider(type = options.markup) MarkupHelper.markup_cache[type][:provider] end