UNPKG

2.9 kBTypeScriptView Raw
1import { Package, PackageRef } from './Package';
2import { Injector } from './Injector';
3import { Processor } from './Processor';
4/**
5 * Create an instance of the Dgeni documentation generator, loading any packages passed in as a
6 * parameter.
7 * @param {Package[]} [packages] A collection of packages to load
8 */
9export declare class Dgeni {
10 static Package: typeof Package;
11 injector: Injector;
12 packages: Record<string, Package> | Package[];
13 processors: Processor[];
14 stopOnProcessingError: boolean;
15 handlerMap: {
16 [key: string]: Function[];
17 };
18 constructor(packages?: Package[]);
19 /**
20 * Load a package into dgeni
21 * @param package The package to load or the name of a new package to create.
22 * @param dependencies A collection of dependencies for this package
23 * @return The package that was loaded, to allow chaining
24 */
25 package(pkg: PackageRef, dependencies?: PackageRef[]): Package;
26 /**
27 * Configure the injector using the loaded packages.
28 *
29 * The injector is assigned to the `injector` property on `this`, which is used by the
30 * `generate()` method. Subsequent calls to this method will just return the same injector.
31 *
32 * This method is useful in unit testing services and processors as it gives an easy way to
33 * get hold of an instance of a ready instantiated component without having to load in all
34 * the potential dependencies manually:
35 *
36 * ```
37 * const Dgeni = require('dgeni');
38 *
39 * function getInjector() {
40 * const dgeni = new Dgeni();
41 * dgeni.package('testPackage', [require('dgeni-packages/base')])
42 * .factory('templateEngine', function dummyTemplateEngine() {});
43 * return dgeni.configureInjector();
44 * };
45 *
46 * describe('someService', function() {
47 * const someService;
48 * beforeEach(function() {
49 * const injector = getInjector();
50 * someService = injector.get('someService');
51 * });
52 *
53 * it("should do something", function() {
54 * someService.doSomething();
55 * ...
56 * });
57 * });
58 * ```
59 */
60 configureInjector(): Injector;
61 /**
62 * Generate the documentation using the loaded packages
63 * @return {Promise} A promise to the generated documents
64 */
65 generate(): Promise<any[]>;
66 runProcessor(processor: any, docs: any): Promise<any>;
67 /**
68 * Trigger a dgeni event and run all the registered handlers
69 * All the arguments to this call are passed through to each handler
70 * @param {string} eventName The event being triggered
71 * @return {Promise} A promise to an array of the results from each of the handlers
72 */
73 triggerEvent(eventName: string, ...extras: any[]): Promise<any[]>;
74 triggerProcessorEvent(eventName: string, processor: any, docs: any): Promise<any>;
75 info(): void;
76}
77
\No newline at end of file