Reference Source Test
public class | source

Plugin

You can directly use an instance of this class. plugin

Plugin system for your plugin.

Constructor Summary

Public Constructor
public

create instance.

Member Summary

Private Members
private

Method Summary

Public Methods
public

init(plugins: Array<{name: string, option: object}>)

initialize with plugin property.

public

handle complete

public

onHandleAST(ast: AST, filePath: string, code: string): AST

handle AST.

public

onHandleCode(code: string, filePath: string): string

handle code.

public

onHandleCodeParser(parser: function(code: string), parserOption: object, filePath: string, code: string): function(code: string): Object}

handle code parser.

public

handle config.

public

onHandleContent(content: string, fileName: string): string

handle content.

public

onHandleDocs(docs: Object[]): Object[]

handle docs.

public

onHandlePlugins(plugins: *)

public

onPublish(writeFile: function(filePath: string, content: string), copyDir: function(srcPath: string, destPath: string), readFile: function(filePath: string): string)

handle publish

public

handle start.

Private Methods
private

_execHandler(handlerName: string, ev: PluginEvent)

exec plugin handler.

Public Constructors

public constructor() source

create instance.

Private Members

private _plugins: * source

Public Methods

public init(plugins: Array<{name: string, option: object}>) source

initialize with plugin property.

Params:

NameTypeAttributeDescription
plugins Array<{name: string, option: object}>

expect config.plugins property.

public onComplete() source

handle complete

public onHandleAST(ast: AST, filePath: string, code: string): AST source

handle AST.

Params:

NameTypeAttributeDescription
ast AST

original ast.

filePath string

source code file path.

code string

original code.

Return:

AST

handled AST.

public onHandleCode(code: string, filePath: string): string source

handle code.

Params:

NameTypeAttributeDescription
code string

original code.

filePath string

source code file path.

Return:

string

handled code.

public onHandleCodeParser(parser: function(code: string), parserOption: object, filePath: string, code: string): function(code: string): Object} source

handle code parser.

Params:

NameTypeAttributeDescription
parser function(code: string)

original js parser.

parserOption object

default babylon options.

filePath string

source code file path.

code string

original code.

Return:

function(code: string): Object}

handled parser.

public onHandleConfig(config: ESDocConfig): ESDocConfig source

handle config.

Params:

NameTypeAttributeDescription
config ESDocConfig

original esdoc2 config.

Return:

ESDocConfig

handled config.

public onHandleContent(content: string, fileName: string): string source

handle content.

Params:

NameTypeAttributeDescription
content string

original content.

fileName string

the fileName of the HTML file.

Return:

string

handled HTML.

public onHandleDocs(docs: Object[]): Object[] source

handle docs.

Params:

NameTypeAttributeDescription
docs Object[]

docs.

Return:

Object[]

handled docs.

public onHandlePlugins(plugins: *) source

Params:

NameTypeAttributeDescription
plugins *

public onPublish(writeFile: function(filePath: string, content: string), copyDir: function(srcPath: string, destPath: string), readFile: function(filePath: string): string) source

handle publish

Params:

NameTypeAttributeDescription
writeFile function(filePath: string, content: string)

write content.

copyDir function(srcPath: string, destPath: string)

copy directory.

readFile function(filePath: string): string

read content.

public onStart() source

handle start.

Private Methods

private _execHandler(handlerName: string, ev: PluginEvent) source

exec plugin handler.

Params:

NameTypeAttributeDescription
handlerName string

handler name(e.g. onHandleCode)

ev PluginEvent

plugin event object.