codoc 0.1.0

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

# A class demonstrating various Yardoc documentation tags.
#
# This class shows how different documentation tags are parsed.
#
# @author John Doe
# @since 1.0.0
# @see https://example.com Documentation
# @note This is an important note about the class.
# @todo Add more features
class YardocExamples
  # A method with comprehensive documentation.
  #
  # This method demonstrates most Yardoc tags.
  #
  # @param name [String] the name parameter with a longer description
  #   that spans multiple lines for testing purposes
  # @param options [Hash] the options hash
  # @option options [Integer] :timeout the timeout in seconds
  # @option options [Boolean] :retry whether to retry on failure
  # @option options [String] :format the output format
  #
  # @return [Hash] the result containing:
  #   - `:status` - the status code
  #   - `:data` - the response data
  #
  # @raise [ArgumentError] if name is empty
  # @raise [RuntimeError] if operation fails
  #
  # @example Basic usage
  #   result = obj.comprehensive("test")
  #   result[:status] #=> 200
  #
  # @example With options
  #   result = obj.comprehensive("test", timeout: 60, retry: true)
  #
  # @see #simple_method
  # @note This method may be slow for large inputs.
  # @deprecated Use {#new_method} instead.
  def comprehensive(name, options = {})
    { status: 200, data: name }
  end

  # A method that yields to a block.
  #
  # @param items [Array<String>] the items to iterate
  # @yield [item, index] Yields each item with its index
  # @yieldparam item [String] the current item
  # @yieldparam index [Integer] the current index
  # @yieldreturn [Boolean] whether to continue
  # @return [Integer] the number of items processed
  def with_yield(items)
    items.each_with_index do |item, index|
      break unless yield(item, index)
    end.length
  end

  # A simple method for reference.
  #
  # @return [String]
  def simple_method
    "simple"
  end

  # The new recommended method.
  #
  # @param name [String] the name
  # @return [Hash]
  def new_method(name)
    comprehensive(name)
  end

  # A method with union types.
  #
  # @param value [String, Integer, nil] the value (can be multiple types)
  # @return [String, nil] the result or nil
  def union_types(value)
    value&.to_s
  end

  # A method with array types.
  #
  # @param items [Array<Hash{Symbol => String}>] array of hashes
  # @return [Array<String>] array of strings
  def array_types(items)
    items.map { |h| h.values.join }
  end
end