Class: RailsAiContext::Serializers::MarkdownSerializer

Inherits:
Object
  • Object
show all
Includes:
StackOverviewHelper, TestCommandDetection
Defined in:
lib/rails_ai_context/serializers/markdown_serializer.rb

Overview

Generates AI-friendly markdown context files from introspection data. Outputs: CLAUDE.md (for Claude Code), copilot-instructions.md, etc.

Constant Summary collapse

MARKDOWN_SPECIAL_CHARS =
/([\\`*_{\}\[\]()+\-#.!~|])/

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StackOverviewHelper

#arch_labels_hash, #detect_before_actions, #detect_job_files, #detect_service_files, #full_preset_stack_lines, #model_extras_line, #notable_gems_list, #pattern_labels_hash, #project_root, #render_compact_controllers_list, #scope_names, #write_rule_files

Constructor Details

#initialize(context) ⇒ MarkdownSerializer

Returns a new instance of MarkdownSerializer.



15
16
17
# File 'lib/rails_ai_context/serializers/markdown_serializer.rb', line 15

def initialize(context)
  @context = context
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



13
14
15
# File 'lib/rails_ai_context/serializers/markdown_serializer.rb', line 13

def context
  @context
end

Instance Method Details

#callString

Returns full markdown document.

Returns:

  • (String)

    full markdown document



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/rails_ai_context/serializers/markdown_serializer.rb', line 20

def call
  sections = []
  sections << header
  sections << app_overview
  sections << schema_section if context[:schema]
  sections << models_section if context[:models]
  sections << routes_section if context[:routes]
  sections << jobs_section if context[:jobs]
  sections << gems_section if context[:gems]
  sections << conventions_section if context[:conventions]
  sections << controllers_section if context[:controllers]
  sections << views_section if context[:views]
  sections << turbo_section if context[:turbo]
  sections << active_storage_section if context[:active_storage]
  sections << action_text_section if context[:action_text]
  sections << i18n_section if context[:i18n]
  sections << config_section if context[:config]
  sections << assets_section if context[:assets]
  sections << auth_section if context[:auth]
  sections << api_section if context[:api]
  sections << tests_section if context[:tests]
  sections << rake_tasks_section if context[:rake_tasks]
  sections << devops_section if context[:devops]
  sections << action_mailbox_section if context[:action_mailbox]
  sections << migrations_section if context[:migrations]
  sections << seeds_section if context[:seeds]
  sections << middleware_section if context[:middleware]
  sections << engines_section if context[:engines]
  sections << multi_database_section if context[:multi_database]
  sections << warnings_section if context[:_warnings]&.any?
  sections << footer
  sections.compact.join("\n\n")
end