Class: Docwright::Wizard

Inherits:
Object
  • Object
show all
Defined in:
lib/docwright/wizard.rb

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

FIRST_RUN_MESSAGE =
<<~MSG
  ============================================
  DocWright — Rails Documentation Generator
  ============================================

  This tool will generate a docs/ folder with:

    Auto-generated (safe to regenerate anytime):
      - database.md   — tables, columns, types
      - api.md        — routes and endpoints
      - models.md     — model associations and validations

    Manual templates (written once, never overwritten):
      - overview.md, setup.md, architecture.md,
        deployment.md, security.md, troubleshooting.md,
        business_rules.md, changelog.md, readme.md
      - docs/features/ — feature-specific docs

    Important:
      Never manually edit content inside
      <!-- DOCWRIGHT:AUTO --> blocks — it will be overwritten.
      Write your notes outside those markers.

  ============================================
MSG
DOCWRIGHT_YML_TEMPLATE =
<<~YAML
  # DocWright feature configuration
  # Declare your app's features here and DocWright will generate a doc template for each one.
  ##{" "}
  # Optional narrative docs - set to true to generate
  # DocWright will only generate these if the relevant folders exist in your app
  ##{" "}
  # optional_docs:
  #   controllers: true
  #   background_jobs: true
  #   services: true
  #   auth_and_permissions: true
  #
  # Feature-specific docs
  # Uncomment and edit the example below to add your features:
  #
  # features:
  #   - name: qr_flow
  #     description: QR code generation and scanning flow
  #   - name: subscriptions
  #     description: Billing, plan management, and renewals
YAML

Instance Method Summary collapse

Instance Method Details

#runObject

rubocop:disable Metrics/MethodLength



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/docwright/wizard.rb', line 54

def run # rubocop:disable Metrics/MethodLength
  ## File.exist? also works for both files and directories but Dir.exist? is specific for folder and return nil if that is named as file name
  first_run = !Dir.exist?("docs")
  puts FIRST_RUN_MESSAGE if first_run

  create_config_if_missing

  puts "\nDocWright: scanning your app...\n\n"

  report = detection_pass
  display_report(report)

  return unless confirm

  generate_auto_files
  process_manual_files(report[:new_manual])
  process_manual_files(report[:new_features])

  puts "\nDocWright: done!\n"
rescue Interrupt
  puts "\n\nDocWright: wizard cancelled."
end