get_api_reference
Retrieve detailed API documentation for Ember classes, modules, methods, or properties, including parameters, return values, examples, and links to official docs.
Instructions
Get detailed API reference documentation for a specific Ember class, module, or method. Returns full API documentation including parameters, return values, examples, and links to official API docs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name of the API element (e.g., 'Component', '@glimmer/component', 'Service', 'Router') | |
| type | No | Type of API element (optional) |
Implementation Reference
- lib/documentation-service.js:510-559 (helper)Core data-fetching helper in DocumentationService. Looks up API doc by name in the index, falls back to searching and parsing JSON from docs, and returns enriched object with deprecation info and API URL.
async getApiReference(name, type) { const key = name.toLowerCase(); const apiDoc = this.apiIndex.get(key); if (!apiDoc) { // Try to search for it const results = await this.search(name, "api", 1); if (results.length > 0 && results[0].apiLink) { // Try to extract from the content const apiDocs = this.sections["api-docs"] || []; for (const doc of apiDocs) { if (doc.content.toLowerCase().includes(key)) { try { const jsonMatch = doc.content.match(/\{[\s\S]*"data"[\s\S]*\}/); if (jsonMatch) { const parsed = JSON.parse(jsonMatch[0]); if (parsed.data?.attributes) { const attrs = parsed.data.attributes; return { name: attrs.name || attrs.shortname, type: parsed.data.type, module: attrs.module, description: attrs.description, file: attrs.file, line: attrs.line, extends: attrs.extends, methods: attrs.methods || [], properties: attrs.properties || [], apiUrl: results[0].apiLink, }; } } } catch (e) { // Continue searching } } } } return null; } // Check if API is deprecated const deprecationInfo = this.deprecationManager.getDeprecationInfo(apiDoc.name); return { ...apiDoc, apiUrl: generateApiUrl(apiDoc.name, apiDoc.type), deprecationInfo: deprecationInfo, }; } - lib/formatters.js:65-142 (helper)Formatting helper that converts API doc object into a markdown string with name, module, type, description, extends, source, methods (up to 10 with params/returns), properties (up to 10), and a link to full API docs.
export function formatApiReference(apiDoc, deprecationManager) { let output = `# ${apiDoc.name}\n\n`; // Add deprecation warning if applicable if (apiDoc.deprecationInfo) { output += deprecationManager.generateWarning(apiDoc.name, 'banner'); } if (apiDoc.module) { output += `**Module:** \`${apiDoc.module}\`\n\n`; } if (apiDoc.type) { output += `**Type:** ${apiDoc.type}\n\n`; } if (apiDoc.description) { output += `## Description\n\n${apiDoc.description}\n\n`; } if (apiDoc.extends) { output += `**Extends:** ${apiDoc.extends}\n\n`; } if (apiDoc.file) { output += `**Source:** \`${apiDoc.file}\``; if (apiDoc.line) { output += `:${apiDoc.line}`; } output += `\n\n`; } if (apiDoc.methods && apiDoc.methods.length > 0) { output += `## Methods\n\n`; apiDoc.methods.slice(0, 10).forEach((method) => { output += `### ${method.name}\n\n`; if (method.description) { output += `${method.description}\n\n`; } if (method.params && method.params.length > 0) { output += `**Parameters:**\n`; method.params.forEach((param) => { output += `- \`${param.name}\``; if (param.type) output += ` (${param.type})`; if (param.description) output += `: ${param.description}`; output += `\n`; }); output += `\n`; } if (method.return) { output += `**Returns:** ${method.return.type || "void"}`; if (method.return.description) { output += ` - ${method.return.description}`; } output += `\n\n`; } }); } if (apiDoc.properties && apiDoc.properties.length > 0) { output += `## Properties\n\n`; apiDoc.properties.slice(0, 10).forEach((prop) => { output += `### ${prop.name}\n\n`; if (prop.description) { output += `${prop.description}\n\n`; } if (prop.type) { output += `**Type:** ${prop.type}\n\n`; } }); } if (apiDoc.apiUrl) { output += `\n**Full API Documentation:** ${apiDoc.apiUrl}\n`; } return output; }