Configuration options for documentation generation
Source files or directories to process (array or string)
Output directory for generated documentation
Name of the API project
Version of the API
Description of the API project
Title for the generated documentation
Base URL of the API
Sample URL for API requests
Header configuration object
Footer configuration object
Custom template directory
Configuration file path
Include private API endpoints
Enable verbose logging
Enable debug mode
Suppress all output
Dry run mode (don't write files)
Treat warnings as errors and exit with error code
Enable markdown parsing in descriptions
Line ending style (CRLF or LF)
File encoding (default: utf8)
Processing result:
ApiDocParseResult
object with data
and project
properties if successfultrue
if there are no files to processfalse
if an error occurred during processingimport { createDoc } from '@hrefcl/apidoc';
const result = createDoc({
src: ['./src/controllers'],
dest: './docs/api'
});
if (typeof result !== 'boolean') {
console.log('Generated docs for', result.project.name);
}
const result = createDoc({
src: ['./src/api', './src/controllers'],
dest: './public/docs',
name: 'My REST API',
version: '1.2.0',
description: 'A comprehensive REST API for managing resources',
url: 'https://api.example.com/v1',
sampleUrl: 'https://api.example.com/v1',
header: {
title: 'Introduction',
filename: './docs/header.md'
},
footer: {
title: 'Additional Info',
filename: './docs/footer.md'
},
verbose: true,
apiprivate: false
});
try {
const result = createDoc({
src: ['./nonexistent'],
dest: './docs'
});
if (result === false) {
console.error('Documentation generation failed');
} else if (result === true) {
console.log('No API documentation found');
} else {
console.log('Success:', result.data.length, 'endpoints documented');
}
} catch (error) {
console.error('Configuration error:', error.message);
}
Creates API documentation from source code comments
This is the main entry point for generating API documentation. It processes source files containing API documentation comments and generates HTML output.