Class: Woods::Unblocked::DocumentBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/woods/unblocked/document_builder.rb

Overview

Converts extracted unit JSON into condensed Markdown documents optimized for Unblocked’s code review and Q&A context.

Each unit type has a specialized formatting strategy that emphasizes what matters for code review: associations, blast radius, entry points, side effects, and structural complexity.

Examples:

builder = DocumentBuilder.new(repo_url: "https://github.com/acme/myapp")
doc = builder.build(unit_data)
# => { title: "Order (model)", body: "# Order (model)\n...", uri: "https://..." }

Instance Method Summary collapse

Constructor Details

#initialize(repo_url:) ⇒ DocumentBuilder

Returns a new instance of DocumentBuilder.

Parameters:

  • repo_url (String)

    GitHub repo base URL for citation URIs



19
20
21
# File 'lib/woods/unblocked/document_builder.rb', line 19

def initialize(repo_url:)
  @repo_url = repo_url.chomp('/')
end

Instance Method Details

#build(unit_data) ⇒ Hash

Build a document hash from a unit’s extracted data.

Parameters:

  • unit_data (Hash)

    Parsed unit JSON (from IndexReader)

Returns:

  • (Hash)

    { title:, body:, uri: }



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/woods/unblocked/document_builder.rb', line 27

def build(unit_data)
  type = unit_data['type']
  identifier = unit_data['identifier']
  file_path = unit_data['file_path']

  {
    title: "#{identifier} (#{type})",
    body: build_body(unit_data),
    uri: build_uri(file_path)
  }
end