Class: Chiridion::Engine::Writer

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

Overview

Writes generated documentation files to disk.

Handles smart write detection to avoid unnecessary file updates when only timestamps have changed but content is identical.

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", index_description: nil, inline_source_threshold: 10, rbs_attr_types: {}) ⇒ Writer

Returns a new instance of Writer.



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
37
38
39
40
41
42
# File 'lib/chiridion/engine/writer.rb', line 12

def initialize(
  output,
  namespace_strip,
  include_specs,
  verbose,
  logger,
  root: Dir.pwd,
  github_repo: nil,
  github_branch: "main",
  project_title: "API Documentation",
  index_description: nil,
  inline_source_threshold: 10,
  rbs_attr_types: {}
)
  @output          = output
  @namespace_strip = namespace_strip
  @verbose         = verbose
  @logger          = logger
  @root            = root
  @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,
    index_description:       index_description,
    inline_source_threshold: inline_source_threshold,
    rbs_attr_types:          rbs_attr_types
  )
end

Instance Method Details

#write(structure) ⇒ Object

Write all documentation files.

Parameters:

  • structure (Hash)

    Documentation structure from Extractor



47
48
49
50
51
# File 'lib/chiridion/engine/writer.rb', line 47

def write(structure)
  FileUtils.mkdir_p(@output)
  written, skipped = write_all_files(structure)
  @logger.info "  #{written} files written, #{skipped} unchanged"
end