Class: Chiridion::SemanticEngine

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

Overview

Semantic documentation engine - outputs structured JSON data.

This is an alternative to the regular Engine that focuses on semantic extraction and outputs machine-readable JSON alongside markdown. It’s useful for:

  • Verifying what data is being captured

  • Debugging the extraction pipeline

  • Generating LLM-friendly documentation

  • Separating extraction from presentation

Usage:

engine = Chiridion::SemanticEngine.new(
  paths: ['lib/myproject'],
  output: 'docs/sys',
  namespace_filter: 'MyProject::'
)
engine.refresh

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths:, output:, namespace_filter: nil, namespace_strip: nil, include_specs: false, verbose: false, logger: nil, root: Dir.pwd, rbs_path: "sig", spec_path: "test", project_title: "API Documentation", project_description: nil) ⇒ SemanticEngine

Returns a new instance of SemanticEngine.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/chiridion/semantic_engine.rb', line 29

def initialize(
  paths:,
  output:,
  namespace_filter: nil,
  namespace_strip: nil,
  include_specs: false,
  verbose: false,
  logger: nil,
  root: Dir.pwd,
  rbs_path: "sig",
  spec_path: "test",
  project_title: "API Documentation",
  project_description: nil
)
  @paths               = Array(paths)
  @output              = output
  @namespace_filter    = namespace_filter
  @namespace_strip     = namespace_strip || namespace_filter
  @include_specs       = include_specs
  @verbose             = verbose
  @logger              = logger || DefaultLogger.new
  @root                = root
  @rbs_path            = rbs_path
  @spec_path           = spec_path
  @project_title       = project_title
  @project_description = project_description
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



27
28
29
# File 'lib/chiridion/semantic_engine.rb', line 27

def output
  @output
end

#pathsObject (readonly)

Returns the value of attribute paths.



27
28
29
# File 'lib/chiridion/semantic_engine.rb', line 27

def paths
  @paths
end

Instance Method Details

#refreshObject



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/chiridion/semantic_engine.rb', line 57

def refresh
  require "yard"
  register_rbs_tag

  @logger.info "Semantic extraction from #{paths_description}..."

  # Load sources
  load_sources

  # Extract using SemanticExtractor
  project_doc = extract_documentation

  # Render to JSON+markdown
  files = render_documentation(project_doc)

  # Write files
  write_files(files)

  @logger.info "Semantic docs written to #{@output}/ (#{files.size} files)"
end