<commit_before>#!/bin/bash

script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Verify jazzy is installed
if ! command -v jazzy > /dev/null; then
  echo "ERROR: Please install jazzy before running build_documentation.sh:"
  echo "https://github.com/realm/jazzy#installation"
  exit 1
fi

# Verify jazzy is up to date
jazzy_version_remote="$(gem search ^jazzy$ --remote --no-verbose | grep --only-matching --extended-regexp "[0-9\.]+")"
jazzy_version_installed="$(gem search ^jazzy$ --installed --no-verbose --version "${jazzy_version_remote}")"

if [[ "${jazzy_version_installed}" != "true" ]]; then
  echo "ERROR: Please update jazzy before running build_documentation.sh:"
  echo "\`gem update jazzy\`"
  exit 1
fi

# Clean destination `stripe-ios/docs/docs/` directory
echo "Cleaning stripe-ios/docs/docs/ directory..."
rm -rf "${script_dir}/../docs/docs/"

# Execute jazzy
echo "Executing jazzy..."
jazzy \
  --config "${script_dir}/../.jazzy.yaml" \
  --output "${script_dir}/../docs/docs"

# Verify jazzy exit code
jazzy_exit_code="$?"

if [[ "${jazzy_exit_code}" != 0 ]]; then
  echo "ERROR: Executing jazzy failed with status code: ${jazzy_exit_code}"<commit_msg>Use better version source `jazzy --version`<commit_after>#!/bin/bash

script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Verify jazzy is installed
if ! command -v jazzy > /dev/null; then
  echo "ERROR: Please install jazzy before running build_documentation.sh:"
  echo "https://github.com/realm/jazzy#installation"
  exit 1
fi

# Verify jazzy is up to date
jazzy_version_local="$(jazzy --version | grep --only-matching --extended-regexp "[0-9\.]+")"
jazzy_version_remote="$(gem search ^jazzy$ --remote --no-verbose | grep --only-matching --extended-regexp "[0-9\.]+")"

if [[ "${jazzy_version_local}" != "${jazzy_version_remote}" ]]; then
  echo "ERROR: Please update jazzy before running build_documentation.sh:"
  echo "\`gem update jazzy\`"
  exit 1
fi

# Clean destination `stripe-ios/docs/docs/` directory
echo "Cleaning stripe-ios/docs/docs/ directory..."
rm -rf "${script_dir}/../docs/docs/"

# Execute jazzy
echo "Executing jazzy..."
jazzy \
  --config "${script_dir}/../.jazzy.yaml" \
  --output "${script_dir}/../docs/docs"

# Verify jazzy exit code
jazzy_exit_code="$?"

if [[ "${jazzy_exit_code}" != 0 ]]; then
  echo "ERROR: Executing jazzy failed with status code: ${jazzy_exit_code}"
{'fraction_non_alphanumeric': 0.178168130489335, 'fraction_numerical': 0.005855290673358427, 'mean_word_length': 4.222707423580786, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '907500', 'n_tokens_mistral': 879, 'n_tokens_neox': 849, 'n_words': 219}