Sha256: 6bb5ad168aca97b40656e8385023d7e0c50da63b222e3240d00a7e95c77b8398

Contents?: true

Size: 1.23 KB

Versions: 10

Compression:

Stored size: 1.23 KB

Contents

#!/usr/bin/env ruby

require 'sfn'

print 'Generating command and configuration page...'

klasses = Sfn::Config.constants.sort.map do |const|
  klass = Sfn::Config.const_get(const)
  klass if klass.is_a?(Class) && klass.respond_to?(:attributes)
end.compact

file = File.open(File.join(File.dirname(__FILE__), '..', 'docs', 'command-config.md'), 'w')

file.puts <<-EOS
---
title: "Commands and configuration"
weight: 6
anchors:
EOS

klasses.each do |klass|
  file.puts "  - title: \"#{klass.name.split('::').last} Command\""
  file.puts "    url: \"##{klass.name.split('::').last.downcase}-command\""
end
file.puts '---'

klasses.each do |klass|
  file.puts "## #{klass.name.split('::').last} Command"
  file.puts
  file.puts '~~~'
  file.puts "$ sfn #{klass.name.split('::').last.downcase}"
  file.puts '~~~'
  file.puts "\n"
  file.puts "| Option | Attribute | Value"
  file.puts "|--------|-----------|------"
  klass.attributes.sort_by(&:first).map do |name, value|
    file.puts "| `--#{name.to_s.tr('_', '-')}` | Description | #{value[:description]} |"
    file.puts "| | Valid | `#{[value[:type]].flatten.compact.join('`, `')}` |"
    file.puts "| | Default | #{value[:default].inspect unless value[:default].nil?}|\n"
  end
  file.puts
end

puts 'done'

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sfn-3.0.32 bin/command-config-generator
sfn-3.0.30 bin/command-config-generator
sfn-3.0.28 bin/command-config-generator
sfn-3.0.26 bin/command-config-generator
sfn-3.0.24 bin/command-config-generator
sfn-3.0.22 bin/command-config-generator
sfn-3.0.20 bin/command-config-generator
sfn-3.0.18 bin/command-config-generator
sfn-3.0.16 bin/command-config-generator
sfn-3.0.14 bin/command-config-generator