diff --git a/scripts/apidoc/markdown.ts b/scripts/apidoc/markdown.ts index 88df01507b6..870b4201136 100644 --- a/scripts/apidoc/markdown.ts +++ b/scripts/apidoc/markdown.ts @@ -39,10 +39,15 @@ const htmlSanitizeOptions: sanitizeHtml.IOptions = { function comparableSanitizedHtml(html: string): string { return html + .replace(/[0-9A-F]{2};/g, (x) => + String.fromCodePoint(Number.parseInt(x.slice(3, -1), 16)) + ) .replace(/>/g, '>') - .replace(/ /g, '') + .replace(/</g, '<') + .replace(/&/g, '&') .replace(/"/g, '"') - .replace(/'/g, "'"); + .replace(/=""/g, '') + .replace(/ /g, ''); } /** diff --git a/test/scripts/apidoc/__snapshots__/module.spec.ts.snap b/test/scripts/apidoc/__snapshots__/module.spec.ts.snap index dcd88cd0cf3..2f2d15ddbee 100644 --- a/test/scripts/apidoc/__snapshots__/module.spec.ts.snap +++ b/test/scripts/apidoc/__snapshots__/module.spec.ts.snap @@ -12,7 +12,7 @@ exports[`module > analyzeModule() > ModuleExampleTest 1`] = ` { "comment": "This is a description for a module with a code example.", "deprecated": undefined, - "examples": "
new ModuleExampleTest()
new ModuleExampleTest()
+ "examples": "new ModuleExampleTest()
Complex array parameter.
", - "examples": "complexArrayParameter<T>(array: readonly Array<{
- value: T,
- weight: number
-}>): T
complexArrayParameter<T>(array: readonly Array<{
- value: T,
- weight: number
-}>): T
+ "examples": "complexArrayParameter<T>(array: readonly Array<{
+ value: T,
+ weight: number
+}>): T
Test with a default parameter.
", - "examples": "defaultBooleanParamMethod(c: boolean = true): number
defaultBooleanParamMethod(c: boolean = true): number
+ "examples": "defaultBooleanParamMethod(c: boolean = true): number
Test with a function parameters.
", - "examples": "functionParamMethod(fn: (a: string) => number): number
functionParamMethod(fn: (a: string) => number): number
+ "examples": "functionParamMethod(fn: (a: string) => number): number
Test with LiteralUnion.
", - "examples": "literalUnionParamMethod(value: 'a' | 'b' | string, namedValue: 'a' | 'b' | string, array: readonly Array<'a' | 'b' | string>, namedArray: readonly Array<'a' | 'b' | string>, mixed: 'a' | 'b' | string | readonly Array<'a' | 'b' | string>, namedMixed: 'a' | 'b' | string | readonly Array<'a' | 'b' | string>): string
literalUnionParamMethod(value: 'a' | 'b' | string, namedValue: 'a' | 'b' | string, array: readonly Array<'a' | 'b' | string>, namedArray: readonly Array<'a' | 'b' | string>, mixed: 'a' | 'b' | string | readonly Array<'a' | 'b' | string>, namedMixed: 'a' | 'b' | string | readonly Array<'a' | 'b' | string>): string
+ "examples": "literalUnionParamMethod(value: 'a' | 'b' | string, namedValue: 'a' | 'b' | string, array: readonly Array<'a' | 'b' | string>, namedArray: readonly Array<'a' | 'b' | string>, mixed: 'a' | 'b' | string | readonly Array<'a' | 'b' | string>, namedMixed: 'a' | 'b' | string | readonly Array<'a' | 'b' | string>): string
Test with deprecated and see marker.
", - "examples": "methodWithDeprecated(): number
methodWithDeprecated(): number
+ "examples": "methodWithDeprecated(): number
Test with deprecated option.
", - "examples": "methodWithDeprecatedOption(option: {
- a: string,
- b: () => number,
- c: number
-}): number
methodWithDeprecatedOption(option: {
- a: string,
- b: () => number,
- c: number
-}): number
+ "examples": "methodWithDeprecatedOption(option: {
+ a: string,
+ b: () => number,
+ c: number
+}): number
Test with example marker.
", - "examples": "methodWithExample(): number
-test.apidoc.methodWithExample() // 0
methodWithExample(): number
-test.apidoc.methodWithExample() // 0
+ "examples": "methodWithExample(): number
+test.apidoc.methodWithExample() // 0
Test with multiple see markers.
", - "examples": "methodWithMultipleSeeMarkers(): number
methodWithMultipleSeeMarkers(): number
+ "examples": "methodWithMultipleSeeMarkers(): number
Test with multiple see markers and backticks.
", - "examples": "methodWithMultipleSeeMarkersAndBackticks(): number
methodWithMultipleSeeMarkersAndBackticks(): number
+ "examples": "methodWithMultipleSeeMarkersAndBackticks(): number
Test with multiple throws.
", - "examples": "methodWithMultipleThrows(): number
methodWithMultipleThrows(): number
+ "examples": "methodWithMultipleThrows(): number
Test with since marker.
", - "examples": "methodWithSinceMarker(): number
methodWithSinceMarker(): number
+ "examples": "methodWithSinceMarker(): number
Test with throws.
", - "examples": "methodWithThrows(): number
methodWithThrows(): number
+ "examples": "methodWithThrows(): number
Test with multiple parameters.
", - "examples": "multiParamMethod(a: number, b?: string, c: boolean = true): number
multiParamMethod(a: number, b?: string, c: boolean = true): number
+ "examples": "multiParamMethod(a: number, b?: string, c: boolean = true): number
Test with no parameters.
", - "examples": "noParamMethod(): number
noParamMethod(): number
+ "examples": "noParamMethod(): number
Test with an optional parameter.
", - "examples": "optionalStringParamMethod(b?: string): number
optionalStringParamMethod(b?: string): number
+ "examples": "optionalStringParamMethod(b?: string): number
Test with a function parameters (inline types) with defaults.
", - "examples": "optionsInlineParamMethodWithDefaults(a: {
- value: number
-} = { value: 1 }, b: {
- value: number
-} = { value: 1 }, c: {
- value: number
-}): number
optionsInlineParamMethodWithDefaults(a: {
- value: number
-} = { value: 1 }, b: {
- value: number
-} = { value: 1 }, c: {
- value: number
-}): number
+ "examples": "optionsInlineParamMethodWithDefaults(a: {
+ value: number
+} = { value: 1 }, b: {
+ value: number
+} = { value: 1 }, c: {
+ value: number
+}): number
Test with a function parameters with defaults.
", - "examples": "optionsInterfaceParamMethodWithDefaults(a: ParameterOptionsInterfaceA = { value: 1 }, b: ParameterOptionsInterfaceB = { value: 1 }, c: ParameterOptionsInterfaceC): number
optionsInterfaceParamMethodWithDefaults(a: ParameterOptionsInterfaceA = { value: 1 }, b: ParameterOptionsInterfaceB = { value: 1 }, c: ParameterOptionsInterfaceC): number
+ "examples": "optionsInterfaceParamMethodWithDefaults(a: ParameterOptionsInterfaceA = { value: 1 }, b: ParameterOptionsInterfaceB = { value: 1 }, c: ParameterOptionsInterfaceC): number
Test with an options parameter.
", - "examples": "optionsParamMethod(options: {
- a: number,
- b: string,
- c: boolean,
- d: () => string,
- e: 'a' | 'b' | string
-}): number
optionsParamMethod(options: {
- a: number,
- b: string,
- c: boolean,
- d: () => string,
- e: 'a' | 'b' | string
-}): number
+ "examples": "optionsParamMethod(options: {
+ a: number,
+ b: string,
+ c: boolean,
+ d: () => string,
+ e: 'a' | 'b' | string
+}): number
Test with a function parameters with defaults.
", - "examples": "optionsTypeParamMethodWithDefaults(a: ParameterOptionsTypeA = { value: 1 }, b: ParameterOptionsTypeB = { value: 1 }, c: ParameterOptionsTypeC): number
optionsTypeParamMethodWithDefaults(a: ParameterOptionsTypeA = { value: 1 }, b: ParameterOptionsTypeB = { value: 1 }, c: ParameterOptionsTypeC): number
+ "examples": "optionsTypeParamMethodWithDefaults(a: ParameterOptionsTypeA = { value: 1 }, b: ParameterOptionsTypeB = { value: 1 }, c: ParameterOptionsTypeC): number
Test with a Record parameter.
", - "examples": "recordParamMethod(object: Record<string, number>): number
recordParamMethod(object: Record<string, number>): number
+ "examples": "recordParamMethod(object: Record<string, number>): number
Test with a required parameter.
", - "examples": "requiredNumberParamMethod(a: number): number
requiredNumberParamMethod(a: number): number
+ "examples": "requiredNumberParamMethod(a: number): number
Test with string union.
", - "examples": "stringUnionParamMethod(value: 'a' | 'b', options?: {
- casing: 'lower' | 'mixed' | 'upper',
- excludes: readonly AlphaNumericChar[],
- format: 'binary' | 'css' | 'decimal' | 'hex'
-}): string
stringUnionParamMethod(value: 'a' | 'b', options?: {
- casing: 'lower' | 'mixed' | 'upper',
- excludes: readonly AlphaNumericChar[],
- format: 'binary' | 'css' | 'decimal' | 'hex'
-}): string
+ "examples": "stringUnionParamMethod(value: 'a' | 'b', options?: {
+ casing: 'lower' | 'mixed' | 'upper',
+ excludes: readonly AlphaNumericChar[],
+ format: 'binary' | 'css' | 'decimal' | 'hex'
+}): string