Sha256: 9145030346ca4b6d320e157be6e1d64ceb3d0e851105f95d1d5b9595760ed86a
Contents?: true
Size: 1.16 KB
Versions: 25
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true module PlatformosCheck module PlatformosLiquid class Documentation class MarkdownTemplate MARKDOWN_RELATIVE_LINK = %r{(\[([^\[]+)\]\((/[^\)]+)\))*} def render(entry) [ title(entry), body(entry) ].reject(&:empty?).join("\n") end private def title(entry) "### [#{entry.name}](#{entry.platformos_documentation_url})" end def body(entry) [entry.deprecation_reason, entry.summary, entry.description] .reject(&:nil?) .reject(&:empty?) .join(horizontal_rule) .tap { |body| break(patch_urls!(body)) } end def horizontal_rule "\n\n---\n\n" end def patch_urls!(body) body.gsub(MARKDOWN_RELATIVE_LINK) do |original_link| match = Regexp.last_match text = match[2] path = match[3] if text && path "[#{text}](https://documentation.platformos.com#{path})" else original_link end end end end end end end
Version data entries
25 entries across 25 versions & 1 rubygems