@hrefcl/apidoc - v4.0.5
    Preparing search index...

    Function createDoc

    • 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.

      Parameters

      • options: ApiDocOptions

        Configuration options for documentation generation

        • src

          Source files or directories to process (array or string)

        • dest

          Output directory for generated documentation

        • name

          Name of the API project

        • version

          Version of the API

        • description

          Description of the API project

        • title

          Title for the generated documentation

        • url

          Base URL of the API

        • sampleUrl

          Sample URL for API requests

        • header

          Header configuration object

        • footer

          Footer configuration object

        • template

          Custom template directory

        • config

          Configuration file path

        • apiprivate

          Include private API endpoints

        • verbose

          Enable verbose logging

        • debug

          Enable debug mode

        • silent

          Suppress all output

        • simulate

          Dry run mode (don't write files)

        • warnError

          Treat warnings as errors and exit with error code

        • markdown

          Enable markdown parsing in descriptions

        • lineEnding

          Line ending style (CRLF or LF)

        • encoding

          File encoding (default: utf8)

      Returns boolean | ApiDocParseResult

      Processing result:

      • ApiDocParseResult object with data and project properties if successful
      • true if there are no files to process
      • false if an error occurred during processing

      Throws error if options are invalid or processing fails

      import { 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);
      }

      4.0.0