Class: Ace::Docs::Atoms::ReadmeMetadataInferrer

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/docs/atoms/readme_metadata_inferrer.rb

Overview

Infers metadata for README files managed without frontmatter.

Class Method Summary collapse

Class Method Details

.infer(path:, content:, last_updated: nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ace/docs/atoms/readme_metadata_inferrer.rb', line 8

def self.infer(path:, content:, last_updated: nil)
  return nil unless File.basename(path).casecmp("README.md").zero?

  title = extract_title(content, path)
  parent = parent_label(path)
  doc_type = root_readme?(path) ? "root_readme" : "readme"
  purpose = if doc_type == "root_readme"
    "Monorepo entry point and navigation for ACE"
  else
    "User-facing introduction for #{parent}"
  end

   = {
    "doc-type" => doc_type,
    "purpose" => purpose,
    "update" => {"frequency" => "on-change"}
  }

  if last_updated
    ["ace-docs"] = {"last-updated" => last_updated.strftime("%Y-%m-%d")}
  end

  ["title"] = title
  
end