Sha256: e96bc0135d200ae826a66bc51f8c032fb0daaf7d219a0659f4c53b960f9dabbd

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 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/data_types'
  require_relative 'markdown/resource_types'
  require_relative 'markdown/puppet_tasks'
  require_relative 'markdown/puppet_plans'
  require_relative 'markdown/table_of_contents'

  # generates markdown documentation
  # @return [String] markdown doc
  def self.generate
    final = "# Reference\n\n"
    final << "<!-- DO NOT EDIT: This document was generated by Puppet Strings -->\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 << PuppetStrings::Markdown::DataTypes.render
    final << PuppetStrings::Markdown::PuppetTasks.render
    final << PuppetStrings::Markdown::PuppetPlans.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

1 entries across 1 versions & 1 rubygems

Version Path
puppet-strings-2.5.0 lib/puppet-strings/markdown.rb