Class: Chiridion::Engine::DriftChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/chiridion/engine/drift_checker.rb

Overview

Detects when documentation is out of sync with source code.

Compares what would be generated against existing files. Useful in CI pipelines to enforce documentation currency.

Instance Method Summary collapse

Constructor Details

#initialize(output, namespace_strip, include_specs, verbose, logger, root: Dir.pwd, github_repo: nil, github_branch: "main", project_title: "API Documentation", inline_source_threshold: 10) ⇒ DriftChecker

Returns a new instance of DriftChecker.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/chiridion/engine/drift_checker.rb', line 10

def initialize(
  output,
  namespace_strip,
  include_specs,
  verbose,
  logger,
  root: Dir.pwd,
  github_repo: nil,
  github_branch: "main",
  project_title: "API Documentation",
  inline_source_threshold: 10
)
  @output          = output
  @namespace_strip = namespace_strip
  @include_specs   = include_specs
  @verbose         = verbose
  @logger          = logger
  @renderer        = Renderer.new(
    namespace_strip:         namespace_strip,
    include_specs:           include_specs,
    root:                    root,
    github_repo:             github_repo,
    github_branch:           github_branch,
    project_title:           project_title,
    inline_source_threshold: inline_source_threshold
  )
end

Instance Method Details

#check(structure) ⇒ Object

Check for drift between source and existing documentation.

Parameters:

  • structure (Hash)

    Documentation structure from Extractor

Raises:

  • (SystemExit)

    Exits with code 1 if drift is detected



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/chiridion/engine/drift_checker.rb', line 42

def check(structure)
  @renderer.register_classes(structure)

  drifted  = []
  missing  = []
  orphaned = find_orphaned_files(structure)

  check_index(structure, drifted, missing)
  check_objects(structure[:classes] + structure[:modules], drifted, missing)

  report_results(drifted, missing, orphaned)
end