Class: DocsKit::Generators::SyncReport

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/docs_kit/install/sync_report.rb

Overview

Detects manual drift in an existing docs site that the install generator can't safely automate away — things docs-kit now provides, so the site's own copy is dead weight. String-level and CONSERVATIVE by design: it reads a few known files, reports what it finds, and never touches a byte. The generator prints these as a checklist during a --sync upgrade; the site owner deletes the flagged code by hand.

Drift items, from the consumer audits:

- ApplicationController hand-defines `render_page` — DocsKit::Controller
(included by the generator for months) already provides it.
- a dead IconHelper copy — the gem renders icons via rails_icons.
- a Dockerfile stamped by an OLDER docs-kit than the gem now ships — the
site should diff against the current template and adopt the improvements.

Constant Summary collapse

APPLICATION_CONTROLLER =
"app/controllers/application_controller.rb"
ICON_HELPER =
"app/helpers/icon_helper.rb"
DOCKERFILE =
"Dockerfile"
DOCKERFILE_MARKER =

Matches the version stamp the Dockerfile template writes, e.g. # docs-kit Dockerfile v1.0.2. Absent on a hand-written Dockerfile a site brought itself — which we deliberately leave alone (no marker → no warning).

/docs-kit Dockerfile v(\d+\.\d+\.\d+)/

Instance Method Summary collapse

Constructor Details

#initialize(destination_root) ⇒ SyncReport

Returns a new instance of SyncReport.



30
31
32
# File 'lib/generators/docs_kit/install/sync_report.rb', line 30

def initialize(destination_root)
  @root = destination_root
end

Instance Method Details

#clean?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/generators/docs_kit/install/sync_report.rb', line 40

def clean?
  items.empty?
end

#itemsObject

The drift messages, in the order a site should act on them. Empty when the site is clean.



36
37
38
# File 'lib/generators/docs_kit/install/sync_report.rb', line 36

def items
  [render_page_drift, icon_helper_drift, dockerfile_drift].compact
end