diff --git a/api.md b/api.md index 0ba92e3..8b46431 100644 --- a/api.md +++ b/api.md @@ -6,15 +6,14 @@ - [annotate](#annotate) - [compile](#compile) - [format](#format) -- [TypeAlias](#typealias) +- [Interface](#interface) - [AnnotateOptions](#annotateoptions) + - [CompileOptions](#compileoptions) - [FormatOptions](#formatoptions) + - [SFCParseError](#sfcparseerror) - [Enum](#enum) - [AnnotateWarningCodes](#annotatewarningcodes) - [CompileErrorCodes](#compileerrorcodes) -- [Interface](#interface) - - [CompileOptions](#compileoptions) - - [SFCParseError](#sfcparseerror) - [Variable](#variable) - [DEFAULT_PRETTIER_OPTIONS](#default_prettier_options) - [Class](#class) @@ -95,7 +94,7 @@ declare function format(source: string, filepath: string, options?: FormatOption Currently, only i18n custom blocks supporting -## TypeAlias +## Interface ### AnnotateOptions @@ -103,73 +102,66 @@ Annotate options of [annotate](#annotate) function **Signature:** ```typescript -declare type AnnotateOptions = { - type?: string; - force?: boolean; - attrs?: Record; - onWarn?: (code: number, args: Record, block: SFCBlock) => void; -}; +interface AnnotateOptions ``` -### FormatOptions -Format options of [format](#format) function +#### Properties + +##### attrs + +The Attributes to be annotated on the block tag **Signature:** ```typescript -declare type FormatOptions = { - prettier?: Options; -}; +attrs?: Record; ``` +#### Remarks -## Enum +default as `{}` -### AnnotateWarningCodes +##### force -Annotate Warning Codes +Whether to force annotations **Signature:** ```typescript -declare const enum AnnotateWarningCodes +force?: boolean; ``` -#### Members - -| Member | Value| Description | -| --- | --- | --- | -| LANG_MISMATCH_IN_ATTR_AND_CONTENT | 4 | Lang mismatch `lang` and block content | -| LANG_MISMATCH_IN_OPTION_AND_CONTENT | 3 | Lang mismatch option and block content | -| LANG_MISMATCH_IN_SRC_AND_CONTENT | 2 | Lang mismatch block `src` and block content | -| NOT_SUPPORTED_TYPE | 1 | Not supported type | - #### Remarks -The warning codes of [annotate](#annotate) function +Force annotation of the attribute values of `attrs` option to the block tag. Even if the actual `lang` of the block content in the `lang` attribute is different, it will be enforced if this flag is turned on. default as `false` -### CompileErrorCodes +##### onWarn -Compile Error Codes +The warning handler **Signature:** ```typescript -declare const enum CompileErrorCodes +onWarn?: (code: number, args: Record, block: SFCBlock) => void; ``` -#### Members +#### Remarks -| Member | Value| Description | -| --- | --- | --- | -| INTERNAL_COMPILE_ERROR | 3 | Internal compile error | -| INTERNAL_COMPILE_WARNING | 2 | Internal compile warning | -| NOT_SUPPORTED_FORMAT | 1 | Not supported format | +Notify warnings generated by the annotate process + +##### type + +The type of the block + +**Signature:** +```typescript +type?: string; +``` #### Remarks -The error codes of [compile](#compile) function +Only `i18n` type is supported, if you don't specify it. If any other type is specified, the function will raise the [SFCAnnotateError](#sfcannotateerror). +default as `i18n` -## Interface ### CompileOptions @@ -219,6 +211,32 @@ onError?: (code: number, source: string, output: string, msg?: string) => void; ``` +### FormatOptions + +Format options of [format](#format) function + +**Signature:** +```typescript +interface FormatOptions +``` + + +#### Properties + +##### prettier + +The prettier options + +**Signature:** +```typescript +prettier?: Options; +``` + +#### Remarks + +The options for formatting the content of `i18n` custom blocks with prettier default as [DEFAULT_PRETTIER_OPTIONS](#default_prettier_options) + + ### SFCParseError Vue SFC compiler error @@ -255,6 +273,52 @@ filepath: string; +## Enum + +### AnnotateWarningCodes + +Annotate Warning Codes + +**Signature:** +```typescript +declare const enum AnnotateWarningCodes +``` + +#### Members + +| Member | Value| Description | +| --- | --- | --- | +| LANG_MISMATCH_IN_ATTR_AND_CONTENT | 4 | Lang mismatch `lang` and block content | +| LANG_MISMATCH_IN_OPTION_AND_CONTENT | 3 | Lang mismatch option and block content | +| LANG_MISMATCH_IN_SRC_AND_CONTENT | 2 | Lang mismatch block `src` and block content | +| NOT_SUPPORTED_TYPE | 1 | Not supported type | + +#### Remarks + +The warning codes of [annotate](#annotate) function + +### CompileErrorCodes + +Compile Error Codes + +**Signature:** +```typescript +declare const enum CompileErrorCodes +``` + +#### Members + +| Member | Value| Description | +| --- | --- | --- | +| INTERNAL_COMPILE_ERROR | 3 | Internal compile error | +| INTERNAL_COMPILE_WARNING | 2 | Internal compile warning | +| NOT_SUPPORTED_FORMAT | 1 | Not supported format | + +#### Remarks + +The error codes of [compile](#compile) function + + ## Variable ### DEFAULT_PRETTIER_OPTIONS diff --git a/src/api/annotate.ts b/src/api/annotate.ts index 6a29ee4..4f8894c 100644 --- a/src/api/annotate.ts +++ b/src/api/annotate.ts @@ -45,7 +45,7 @@ export const enum AnnotateWarningCodes { * * @public */ -export type AnnotateOptions = { +export interface AnnotateOptions { /** * The type of the block * diff --git a/src/api/format.ts b/src/api/format.ts index b271bbc..c8b9527 100644 --- a/src/api/format.ts +++ b/src/api/format.ts @@ -14,7 +14,7 @@ const debug = createDebug('@intlify/cli:api:format') * * @public */ -export type FormatOptions = { +export interface FormatOptions { /** * The prettier options *