Module: YardSchemas

Defined in:
lib/yardmcp.rb

Constant Summary collapse

RESOURCE_URIS_SCHEMA =
{
  type: 'object',
  properties: {
    object: { type: 'string' },
    source: { type: 'string' }
  },
  required: %w[object source]
}.freeze
LIST_GEMS_SCHEMA =
array_schema(:gems)
LIST_CLASSES_SCHEMA =
{
  type: 'object',
  properties: {
    gem_name: { type: 'string' },
    classes: { type: 'array', items: { type: 'string' } }
  },
  required: %w[gem_name classes]
}.freeze
DOC_OBJECT_SCHEMA =
{
  type: 'object',
  properties: {
    path: { type: 'string' },
    gem_name: { type: %w[string null] },
    resource_uris: RESOURCE_URIS_SCHEMA,
    document: {
      type: 'object',
      properties: {
        type: { type: 'string' },
        name: { type: 'string' },
        namespace: { type: %w[string null] },
        visibility: { type: %w[string null] },
        docstring: { type: 'string' },
        parameters: { type: %w[array null] },
        return: { type: %w[object null] },
        source: { type: %w[string null] },
        tags: { type: 'array' }
      },
      required: %w[type name docstring tags]
    }
  },
  required: %w[resource_uris document]
}.freeze
CHILDREN_SCHEMA =
path_array_schema(:children)
METHODS_SCHEMA =
path_array_schema(:methods)
SOURCE_LOCATION_SCHEMA =
{
  type: 'object',
  properties: {
    path: { type: 'string' },
    gem_name: { type: %w[string null] },
    resource_uris: RESOURCE_URIS_SCHEMA,
    source_location: {
      type: 'object',
      properties: {
        file: { type: %w[string null] },
        line: { type: %w[integer null] }
      },
      required: %w[file line]
    }
  },
  required: %w[path resource_uris source_location]
}.freeze
HIERARCHY_SCHEMA =
{
  type: 'object',
  properties: {
    path: { type: 'string' },
    gem_name: { type: %w[string null] },
    resource_uris: RESOURCE_URIS_SCHEMA,
    hierarchy: {
      type: 'object',
      properties: {
        superclass: { type: %w[string null] },
        included_modules: { type: 'array', items: { type: 'string' } },
        mixins: { type: 'array', items: { type: 'string' } }
      },
      required: %w[superclass included_modules mixins]
    }
  },
  required: %w[path resource_uris hierarchy]
}.freeze
SEARCH_SCHEMA =
{
  type: 'object',
  properties: {
    query: { type: 'string' },
    gem_name: { type: %w[string null] },
    limit: { type: 'integer' },
    offset: { type: 'integer' },
    results: {
      type: 'array',
      items: {
        type: 'object',
        properties: {
          path: { type: 'string' },
          score: { type: 'integer' }
        },
        required: %w[path score]
      }
    }
  },
  required: %w[query limit offset results]
}.freeze
CODE_SNIPPET_SCHEMA =
{
  type: 'object',
  properties: {
    path: { type: 'string' },
    gem_name: { type: %w[string null] },
    resource_uris: RESOURCE_URIS_SCHEMA,
    snippet: { type: 'string' }
  },
  required: %w[path resource_uris snippet]
}.freeze
ANCESTORS_SCHEMA =
path_array_schema(:ancestors)
{
  type: 'object',
  properties: {
    path: { type: 'string' },
    gem_name: { type: %w[string null] },
    resource_uris: RESOURCE_URIS_SCHEMA,
    related_objects: {
      type: 'object',
      properties: {
        included_modules: { type: 'array', items: { type: 'string' } },
        mixins: { type: 'array', items: { type: 'string' } },
        subclasses: { type: 'array', items: { type: 'string' } }
      },
      required: %w[included_modules mixins subclasses]
    }
  },
  required: %w[path resource_uris related_objects]
}.freeze
BUILD_GEM_DOCS_SCHEMA =
{
  type: 'object',
  properties: {
    gem_name: { type: 'string' },
    indexed: { type: 'boolean' }
  },
  required: %w[gem_name indexed]
}.freeze

Class Method Summary collapse

Class Method Details

.array_schema(name) ⇒ Object



373
374
375
376
377
378
379
380
381
# File 'lib/yardmcp.rb', line 373

def self.array_schema(name)
  {
    type: 'object',
    properties: {
      name => { type: 'array', items: { type: 'string' } }
    },
    required: [name.to_s]
  }.freeze
end

.path_array_schema(name) ⇒ Object



383
384
385
386
387
388
389
390
391
392
393
394
# File 'lib/yardmcp.rb', line 383

def self.path_array_schema(name)
  {
    type: 'object',
    properties: {
      path: { type: 'string' },
      gem_name: { type: %w[string null] },
      resource_uris: RESOURCE_URIS_SCHEMA,
      name => { type: 'array', items: { type: 'string' } }
    },
    required: %w[path resource_uris] + [name.to_s]
  }.freeze
end