Sha256: 143661e117ef9ef74d675aa25c66d6a01b0a1333756bb443e6208938480ebef3

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

require 'puppet-strings/json'

# module for parsing Yard Registries and generating markdown
module PuppetStrings::Markdown
  require_relative 'markdown/puppet_classes'
  require_relative 'markdown/functions'
  require_relative 'markdown/defined_types'
  require_relative 'markdown/resource_types'
  require_relative 'markdown/table_of_contents'

  # generates markdown documentation
  # @return [String] markdown doc
  def self.generate
    final = "# Reference\n\n"
    final << PuppetStrings::Markdown::TableOfContents.render
    final << PuppetStrings::Markdown::PuppetClasses.render
    final << PuppetStrings::Markdown::DefinedTypes.render
    final << PuppetStrings::Markdown::ResourceTypes.render
    final << PuppetStrings::Markdown::Functions.render

    final
  end

  # mimicks the behavior of the json render, although path will never be nil
  # @param [String] path path to destination file
  def self.render(path = nil)
    if path.nil?
      puts generate
      exit
    else
      File.open(path, 'w') { |file| file.write(generate) }
      YARD::Logger.instance.debug "Wrote markdown to #{path}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puppet-strings-1.2.1 lib/puppet-strings/markdown.rb
puppet-strings-1.2.0 lib/puppet-strings/markdown.rb