Skip to main content
Version: Next

API Method Documentation Template

Use this template when documenting API methods that supplement the auto-generated TypeDoc documentation.


[Method Name]

Brief description of what this method does and when to use it.

Syntax

methodName<T extends GenericType>(
parameter1: Type1,
parameter2: Type2,
options?: OptionsType
): Promise<ReturnType<T>>

Parameters

ParameterTypeRequiredDescription
parameter1Type1YesDescription of the first parameter
parameter2Type2YesDescription of the second parameter
optionsOptionsTypeNoOptional configuration object

Options Object

If the method accepts an options object, document its properties:

PropertyTypeDefaultDescription
timeoutnumber5000Request timeout in milliseconds
retriesnumber3Number of retry attempts
validatebooleantrueWhether to validate input data

Returns

Type: Promise<ReturnType<T>>

Description of what the method returns, including:

  • The structure of the returned data
  • When the promise resolves/rejects
  • Any special properties or methods on the returned object

Throws

List the exceptions this method can throw:

  • ValidationError: When input data doesn't match the schema
  • ConnectionError: When database connection fails
  • TimeoutError: When the operation times out

Examples

Basic Usage

import { MethodClass } from 'age-schema-client';

// Setup (if needed)
const instance = new MethodClass(configuration);

// Basic method call
const result = await instance.methodName(
'parameter1Value',
{ property: 'value' }
);

console.log('Result:', result);

Advanced Usage

// Advanced example with options
const result = await instance.methodName(
'parameter1Value',
{ property: 'value' },
{
timeout: 10000,
retries: 5,
validate: false
}
);

// Handle the result
if (result.success) {
console.log('Operation completed:', result.data);
} else {
console.error('Operation failed:', result.error);
}

Error Handling

try {
const result = await instance.methodName(
'parameter1Value',
{ property: 'value' }
);

// Process successful result
console.log('Success:', result);

} catch (error) {
if (error instanceof ValidationError) {
console.error('Validation failed:', error.message);
console.error('Invalid fields:', error.fields);
} else if (error instanceof ConnectionError) {
console.error('Database connection failed:', error.message);
} else {
console.error('Unexpected error:', error);
}
}

Usage Notes

When to Use

  • Describe the primary use cases for this method
  • Explain when this method is preferred over alternatives
  • Mention any prerequisites or setup requirements

Performance Considerations

  • Note any performance implications
  • Suggest optimization strategies if applicable
  • Mention batch alternatives for bulk operations

Best Practices

  • Recommended patterns for using this method
  • Common mistakes to avoid
  • Integration tips with other library features

See Also


Template Usage Instructions

When to Use This Template

Use this template for:

  • Complex methods that need more explanation than TypeDoc provides
  • Methods with multiple usage patterns
  • Methods that require detailed error handling documentation
  • Methods that have important performance or security considerations

Customization Guidelines

  1. Replace placeholders: Update all [Method Name], Type1, etc. with actual values
  2. Adjust sections: Remove sections that don't apply to your method
  3. Add sections: Include additional sections if needed (e.g., Security, Migration)
  4. Update examples: Provide realistic, working examples
  5. Test examples: Ensure all code examples actually work

Integration with TypeDoc

This manual documentation should:

  • Complement the auto-generated TypeDoc documentation
  • Not duplicate basic information already in TypeDoc
  • Focus on usage patterns, examples, and complex scenarios
  • Link to the TypeDoc page for complete API reference

Maintenance

  • Update when the method signature changes
  • Review examples when dependencies are updated
  • Check links when documentation is reorganized
  • Validate that examples still work with each release