From 1f486846449c5156d196896c091b83743aa0047a Mon Sep 17 00:00:00 2001 From: Dominic Roberts Date: Thu, 30 Sep 2021 17:38:38 +0000 Subject: [PATCH] Removed artifacts related to producing duplicate reference guide --- Gemfile | 6 - Gemfile.lock | 28 ----- Rakefile | 28 ----- lib/cli2docs.rb | 98 ----------------- spec/cli2docs_spec.rb | 249 ------------------------------------------ 5 files changed, 409 deletions(-) delete mode 100644 Gemfile delete mode 100644 Gemfile.lock delete mode 100644 Rakefile delete mode 100644 lib/cli2docs.rb delete mode 100644 spec/cli2docs_spec.rb diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 0360b41..0000000 --- a/Gemfile +++ /dev/null @@ -1,6 +0,0 @@ -source 'https://rubygems.org' - -group :test do - gem 'rspec' - gem 'rake' -end diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index d6e02f8..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,28 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - diff-lcs (1.2.5) - rake (10.4.2) - rspec (3.4.0) - rspec-core (~> 3.4.0) - rspec-expectations (~> 3.4.0) - rspec-mocks (~> 3.4.0) - rspec-core (3.4.2) - rspec-support (~> 3.4.0) - rspec-expectations (3.4.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-mocks (3.4.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-support (3.4.1) - -PLATFORMS - ruby - -DEPENDENCIES - rake - rspec - -BUNDLED WITH - 1.11.2 diff --git a/Rakefile b/Rakefile deleted file mode 100644 index 40460bc..0000000 --- a/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -desc 'Set up cli2docs requirements' -task newb: :download - -namespace :install do - desc 'Install CF CLI on OS X' - task :osx do |t, args| - sh 'brew tap cloudfoundry/tap' - sh 'brew install cf-cli' - end - - desc 'Install CF CLI on Linux' - task :deb, [:version] do |t, args| - version = args[:version] - url = "https://cli.run.pivotal.io/stable?release=debian64&version=#{version}&source=github-rel" - sh "wget -O cf_cli.deb '#{url}'" - sh 'apt-get remove -y cf-cli' - sh 'dpkg -i cf_cli.deb' - end -end - -desc 'Format `cf help` output to STDOUT' -task :format do |t, args| - cli_major_version = Integer(`cf version`.strip.match(/cf version (\d+)\.\d+\.\d+\+\w/).captures.first) - cli_help_text = `CF_COLOR=false cf help -a` - - require_relative 'lib/cli2docs' - puts Cli2Docs.format cli_help_text, cli_major_version -end diff --git a/lib/cli2docs.rb b/lib/cli2docs.rb deleted file mode 100644 index 3893028..0000000 --- a/lib/cli2docs.rb +++ /dev/null @@ -1,98 +0,0 @@ -class Cli2Docs - class << self - HEADER_REGEX = /^([^\s].*?)(:|:)$/ - - TITLE_HEADER = <<-EOS ---- -title: Cloud Foundry CLI Reference Guide ---- - EOS - - TABLE_TEMPLATE= <<-EOS.chomp - - - - - - - - - - - - -%s - -
%sDescription
- EOS - - def format(cf_help, cli_major_version) - sections = [] - - cf_help.each_line do |line| - if line =~ HEADER_REGEX - sections << [$1] - else - sections.last << line.strip if sections.last - end - end - - sections = sections.reject do |section| - body = section[1] - body.empty? - end - - out = [] - - sections.each do |header, *body| - id = header.downcase.gsub(' ', '-').gsub('/', '') - text = header.split(' ').map(&:capitalize).join(' ') - out << "## #{text}\n" - - body.pop if body.last.empty? # Remove empty line at the end of each section - out.last << case header - when /NAME|USAGE|VERSION/ - "

#{body.join("\n")}

" - when "GLOBAL OPTIONS" - self.tablify_body(body, cli_major_version, separator: /\s{2,}/, column_name: 'Option', no_link: true) - when "ENVIRONMENT VARIABLES" - self.tablify_body(body, cli_major_version, column_name: 'Variable', no_link: true) - else - self.tablify_body(body, cli_major_version) - end - end - - "#{TITLE_HEADER}\n#{out.join("\n\n")}" - end - - def tablify_body(body, cli_major_version, **options) - separator = options.fetch(:separator, /\s+/) - column_name = options.fetch(:column_name, 'Command') - no_link = options.fetch(:no_link, false) - - rows = body.inject('') do |rows, line| - rows << if line.empty? - <<-EOS - - - - - EOS - else - command, description = line.split(separator, 2) - description ||= ' ' - unless no_link - command = "#{command}" - end - <<-EOS - - #{command} - #{description} - - EOS - end - end - TABLE_TEMPLATE % [column_name, rows.chomp] - end - end -end diff --git a/spec/cli2docs_spec.rb b/spec/cli2docs_spec.rb deleted file mode 100644 index d0adb62..0000000 --- a/spec/cli2docs_spec.rb +++ /dev/null @@ -1,249 +0,0 @@ -require_relative '../lib/cli2docs' - -describe Cli2Docs do - describe '.format' do - let(:cf_help) do - <<-eos -NAME: - cf - A command line tool to interact with Cloud Foundry - -USAGE: - [environment variables] cf [global options] command [arguments...] [command options] - -GETTING STARTED: - target Set or view the targeted org or space - - api Set or view target api url - -ADD/REMOVE PLUGIN: - plugins List all available plugin commands - -INSTALLED PLUGIN COMMANDS: - -ENVIRONMENT VARIABLES: - CF_COLOR=false Do not colorize output - CF_HOME=path/to/dir/ Override path to default config directory - -GLOBAL OPTIONS: - --version, -v Print the version - eos - end - - context 'when cli major version is 6' do - it 'formats `cf help` output' do - expect(Cli2Docs.format(cf_help, '6')).to eq(<<-eos.chomp) ---- -title: Cloud Foundry CLI Reference Guide ---- - -## Name -

cf - A command line tool to interact with Cloud Foundry

- -## Usage -

[environment variables] cf [global options] command [arguments...] [command options]

- -## Getting Started - - - - - - - - - - - - - - - - - - - - - - - - - -
CommandDescription
targetSet or view the targeted org or space
apiSet or view target api url
- -## Add/remove Plugin - - - - - - - - - - - - - - - - - -
CommandDescription
pluginsList all available plugin commands
- -## Environment Variables - - - - - - - - - - - - - - - - - - - - - -
VariableDescription
CF_COLOR=falseDo not colorize output
CF_HOME=path/to/dir/Override path to default config directory
- -## Global Options - - - - - - - - - - - - - - - - - -
OptionDescription
--version, -vPrint the version
-eos - end - end - - context 'when cli major version is 7' do - it 'formats `cf help` output' do - expect(Cli2Docs.format(cf_help, '7')).to eq(<<-eos.chomp) ---- -title: Cloud Foundry CLI Reference Guide ---- - -## Name -

cf - A command line tool to interact with Cloud Foundry

- -## Usage -

[environment variables] cf [global options] command [arguments...] [command options]

- -## Getting Started - - - - - - - - - - - - - - - - - - - - - - - - - -
CommandDescription
targetSet or view the targeted org or space
apiSet or view target api url
- -## Add/remove Plugin - - - - - - - - - - - - - - - - - -
CommandDescription
pluginsList all available plugin commands
- -## Environment Variables - - - - - - - - - - - - - - - - - - - - - -
VariableDescription
CF_COLOR=falseDo not colorize output
CF_HOME=path/to/dir/Override path to default config directory
- -## Global Options - - - - - - - - - - - - - - - - - -
OptionDescription
--version, -vPrint the version
-eos - end - end - end -end -