dgeni
- Version 0.4.14
- Published
- 151 kB
- 9 dependencies
- MIT license
Install
npm i dgeni
yarn add dgeni
pnpm add dgeni
Overview
Flexible JavaScript documentation generator used by both AngularJS and Angular
Index
Classes
Interfaces
Type Aliases
Classes
class Dgeni
class Dgeni {}
Create an instance of the Dgeni documentation generator, loading any packages passed in as a parameter.
Parameter packages
A collection of packages to load
constructor
constructor(packages?: Package[]);
property handlerMap
handlerMap: { [key: string]: Function[] };
property injector
injector: Injector;
property Package
static Package: typeof Package;
property packages
packages: Package[] | Record<string, Package>;
property processors
processors: Processor[];
property stopOnProcessingError
stopOnProcessingError: boolean;
method configureInjector
configureInjector: () => Injector;
Configure the injector using the loaded packages.
The injector is assigned to the
injector
property onthis
, which is used by thegenerate()
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();...});});
method generate
generate: () => Promise<any[]>;
Generate the documentation using the loaded packages {Promise} A promise to the generated documents
method info
info: () => void;
method package
package: (pkg: PackageRef, dependencies?: PackageRef[]) => Package;
Load a package into dgeni
Parameter package
The package to load or the name of a new package to create.
Parameter dependencies
A collection of dependencies for this package The package that was loaded, to allow chaining
method runProcessor
runProcessor: (processor: any, docs: any) => Promise<any>;
method triggerEvent
triggerEvent: (eventName: string, ...extras: 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
Parameter eventName
The event being triggered {Promise} A promise to an array of the results from each of the handlers
method triggerProcessorEvent
triggerProcessorEvent: ( eventName: string, processor: any, docs: any) => Promise<any>;
class Package
class Package {}
A Dgeni Package containing processors, services and config blocks.
Parameter name
The name of the package
Parameter dependencies
The names of packages (or the actual packages) that this package depends upon
constructor
constructor(name: string, dependencies?: PackageRef[]);
property configFns
configFns: any[];
property dependencies
dependencies: PackageRef[];
property handlers
handlers: { [key: string]: string[] };
property module
module: Module;
property name
name: string;
property namedDependencies
namedDependencies: string[];
property processors
processors: any[];
method config
config: (configFn: Function) => this;
Add a new config block to the package. Config blocks are run at the beginning of the doc generation before the processors are run. They can be injected with services and processors to allow you access to their properties so that you can configure them.
Parameter configFn
The config block function to run
{Package} "This" package, to allow methods to be chained.
method eventHandler
eventHandler: (eventName: string, handlerFactory: FactoryDef) => this;
Add an event handler to this package
Parameter eventName
The name of the event to handle
Parameter handlerFactory
An injectable factory function that will return the handler {Package} This package for chaining
method factory
factory: ( serviceFactoryOrName: string | FactoryDef, serviceFactory?: FactoryDef) => this;
Add a new service, defined by a factory function, to the package
Parameter serviceFactoryOrName
If a string then this is the name of the service, otherwise it is assumed to be the
serviceFactory
.Parameter serviceFactory
The factory function that will be used by the injector to create the service. The function must not be anonymous - it must have a name, e.g.
function myService() { ... }
- since the name of the service is taken from the name of the factory function.{Package} "This" package, to allow methods to be chained.
method isPackage
static isPackage: (pkg: any) => pkg is Package;
method processor
processor: ( processorDefOrName: string | ProcessorDef, processorDef?: ProcessorDef) => this;
Add a new processor to the package. The processor can be defined by a processor definition object or a factory function, which can be injected with services and will return the processor definition object. The following properties of a processor definition object have special meaning to Dgeni:
*
name : {string}
: The name of the processor - if the processor is defined by a factory function or a name is explicitly provided as the first parameter, then this is ignored *$process(docs : {string}) : {Array|Promise|undefined}
: The method that will be called to process the documents. If it is async then it should return a Promise. *$runAfter : {string[]}
: Dgeni will ensure that this processor runs after those named here. *$runBefore : {string[]}
: Dgeni will ensure that this processor runs before those named here. *$validate: {Object}
: Dgeni will check that the properties of the processor, which match the keys of this object, pass the validation rules provided as the values of this object. See http://validatejs.orgParameter processorDefOrName
If this parameter is a string then it will be used as the processor's name, otherwise it is assumed that it used as the
processorDef
Parameter processorDef
The factory function or object that will be used by the injector to create the processor. * If a function then it is a factory and it must not be anonymous - it must have a name, e.g.
function myProcessor(dep1, dep2) { ... }
- since the name of the processor is taken from the name of the factory function. * If an object, then it is the actual processor and must have aname
property. In this case, you cannot inject services into this processor.{Package}
this
package, to allow methods to be chained.
method type
type: (ServiceTypeOrName: string | TypeDef, ServiceType?: TypeDef) => this;
Add a new service, defined as a Type to instantiated, to the package
Parameter ServiceTypeOrName
If a string then this is the name of the service, otherwise it is assumed to be the
ServiceType
.Parameter ServiceType
The constructor function that will be used by the injector to create the processor. The function must not be anonymous - it must have a name, e.g.
function MyType() { ... }
- since the name of the service is taken from the name of the constructor function.{Package} "This" package, to allow methods to be chained.
Interfaces
interface Module
interface Module {}
index signature
[token: string]: [InjectionType, any];
interface Processor
interface Processor {}
property $enabled
$enabled?: boolean;
property $package
$package?: string;
property $runAfter
$runAfter?: string[];
property $runBefore
$runBefore?: string[];
property description
description?: string;
property name
name?: string;
method $process
$process: ( docs: DocCollection) => DocCollection | PromiseLike<DocCollection> | void;
Type Aliases
type DocCollection
type DocCollection = Document[];
type Document
type Document = any;
Package Files (7)
Dependencies (9)
Dev Dependencies (11)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/dgeni
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/dgeni)
- HTML<a href="https://www.jsdocs.io/package/dgeni"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4684 ms. - Missing or incorrect documentation? Open an issue for this package.