UNPKG

dgeni

Version:

Flexible JavaScript documentation generator used by both AngularJS and Angular

77 lines (76 loc) 2.9 kB
import { Package, PackageRef } from './Package'; import { Injector } from './Injector'; import { Processor } from './Processor'; /** * Create an instance of the Dgeni documentation generator, loading any packages passed in as a * parameter. * @param {Package[]} [packages] A collection of packages to load */ export declare class Dgeni { static Package: typeof Package; injector: Injector; packages: Record<string, Package> | Package[]; processors: Processor[]; stopOnProcessingError: boolean; handlerMap: { [key: string]: Function[]; }; constructor(packages?: Package[]); /** * Load a package into dgeni * @param package The package to load or the name of a new package to create. * @param dependencies A collection of dependencies for this package * @return The package that was loaded, to allow chaining */ package(pkg: PackageRef, dependencies?: PackageRef[]): Package; /** * Configure the injector using the loaded packages. * * The injector is assigned to the `injector` property on `this`, which is used by the * `generate()` method. Subsequent calls to this method will just return the same injector. * * This method is useful in unit testing services and processors as it gives an easy way to * get hold of an instance of a ready instantiated component without having to load in all * the potential dependencies manually: * * ``` * const Dgeni = require('dgeni'); * * function getInjector() { * const dgeni = new Dgeni(); * dgeni.package('testPackage', [require('dgeni-packages/base')]) * .factory('templateEngine', function dummyTemplateEngine() {}); * return dgeni.configureInjector(); * }; * * describe('someService', function() { * const someService; * beforeEach(function() { * const injector = getInjector(); * someService = injector.get('someService'); * }); * * it("should do something", function() { * someService.doSomething(); * ... * }); * }); * ``` */ configureInjector(): Injector; /** * Generate the documentation using the loaded packages * @return {Promise} A promise to the generated documents */ generate(): Promise<any[]>; runProcessor(processor: any, docs: any): Promise<any>; /** * Trigger a dgeni event and run all the registered handlers * All the arguments to this call are passed through to each handler * @param {string} eventName The event being triggered * @return {Promise} A promise to an array of the results from each of the handlers */ triggerEvent(eventName: string, ...extras: any[]): Promise<any[]>; triggerProcessorEvent(eventName: string, processor: any, docs: any): Promise<any>; info(): void; }