codoc 0.1.0

Unified documentation parser for Ruby and TypeScript codebases
Documentation
# frozen_string_literal: true

# A module that can be included for logging functionality.
#
# @example Including the module
#   class MyClass
#     include Loggable
#   end
module Loggable
  # Logs a message at info level.
  #
  # @param message [String] the message to log
  # @return [void]
  def log_info(message)
    puts "[INFO] #{message}"
  end

  # Logs a message at error level.
  #
  # @param message [String] the message to log
  # @param exception [Exception, nil] optional exception
  # @return [void]
  def log_error(message, exception = nil)
    puts "[ERROR] #{message}"
    puts exception.backtrace.first(5).join("\n") if exception
  end
end

# A module providing class methods when extended.
module ClassMethods
  # Finds all records matching criteria.
  #
  # @param criteria [Hash] the search criteria
  # @return [Array] matching records
  def find_all(criteria = {})
    []
  end
end

# A class demonstrating mixin usage.
#
# @see Loggable
# @see ClassMethods
class MixedClass
  include Loggable
  extend ClassMethods
  prepend SomeOverrides if defined?(SomeOverrides)

  # The identifier.
  #
  # @return [String]
  attr_reader :id

  # Creates a new mixed class.
  #
  # @param id [String] the identifier
  def initialize(id)
    @id = id
    log_info("Created #{id}")
  end
end