@ -9,9 +9,10 @@
|
||||
import {createPatch} from 'diff';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import {SerializationOptions, publicApi} from './serializer';
|
||||
|
||||
export {SerializationOptions, publicApi} from './serializer';
|
||||
import {publicApi, SerializationOptions} from './serializer';
|
||||
|
||||
export {publicApi, SerializationOptions} from './serializer';
|
||||
|
||||
export function generateGoldenFile(
|
||||
entrypoint: string, outFile: string, options: SerializationOptions = {}): void {
|
||||
|
@ -60,7 +60,7 @@ export interface SerializationOptions {
|
||||
paramTags?: JsDocTagOptions;
|
||||
}
|
||||
|
||||
export type DiagnosticSeverity = 'warn' | 'error' | 'none';
|
||||
export type DiagnosticSeverity = 'warn'|'error'|'none';
|
||||
|
||||
export function publicApi(fileName: string, options: SerializationOptions = {}): string {
|
||||
return publicApiInternal(ts.createCompilerHost(baseTsOptions), fileName, baseTsOptions, options);
|
||||
@ -324,7 +324,8 @@ class ResolvedDeclarationEmitter {
|
||||
this.diagnostics.push({
|
||||
type: 'error',
|
||||
message: createErrorMessage(
|
||||
node, 'Required jsdoc tags - One of the tags: ' +
|
||||
node,
|
||||
'Required jsdoc tags - One of the tags: ' +
|
||||
requireAtLeastOne.map(tag => `"@${tag}"`).join(', ') +
|
||||
` - must exist on ${getName(node)}.`)
|
||||
});
|
||||
@ -335,7 +336,8 @@ class ResolvedDeclarationEmitter {
|
||||
this.diagnostics.push({
|
||||
type: 'error',
|
||||
message: createErrorMessage(
|
||||
node, 'Banned jsdoc tags - ' + bannedTagsFound.map(tag => `"@${tag}"`).join(', ') +
|
||||
node,
|
||||
'Banned jsdoc tags - ' + bannedTagsFound.map(tag => `"@${tag}"`).join(', ') +
|
||||
` - were found on ${getName(node)}.`)
|
||||
});
|
||||
}
|
||||
@ -437,7 +439,7 @@ function hasModifier(node: ts.Node, modifierKind: ts.SyntaxKind): boolean {
|
||||
return !!node.modifiers && node.modifiers.some(x => x.kind === modifierKind);
|
||||
}
|
||||
|
||||
function applyDefaultTagOptions(tagOptions: JsDocTagOptions | undefined): JsDocTagOptions {
|
||||
function applyDefaultTagOptions(tagOptions: JsDocTagOptions|undefined): JsDocTagOptions {
|
||||
return {requireAtLeastOne: [], banned: [], toCopy: [], ...tagOptions};
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,9 @@ describe('cli: e2e test', () => {
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(() => { unlinkRecursively(outDir); });
|
||||
afterEach(() => {
|
||||
unlinkRecursively(outDir);
|
||||
});
|
||||
|
||||
it('should print usage without any argument', () => {
|
||||
const {stderr} = execute([]);
|
||||
|
@ -26,14 +26,17 @@ describe('integration test: public api', () => {
|
||||
_warn = null;
|
||||
});
|
||||
|
||||
it('should handle empty files',
|
||||
() => { check('test/fixtures/empty.d.ts', 'test/fixtures/empty_expected.d.ts'); });
|
||||
it('should handle empty files', () => {
|
||||
check('test/fixtures/empty.d.ts', 'test/fixtures/empty_expected.d.ts');
|
||||
});
|
||||
|
||||
it('should include symbols',
|
||||
() => { check('test/fixtures/simple.d.ts', 'test/fixtures/simple_expected.d.ts'); });
|
||||
it('should include symbols', () => {
|
||||
check('test/fixtures/simple.d.ts', 'test/fixtures/simple_expected.d.ts');
|
||||
});
|
||||
|
||||
it('should include symbols reexported explicitly',
|
||||
() => { check('test/fixtures/reexported.d.ts', 'test/fixtures/reexported_expected.d.ts'); });
|
||||
it('should include symbols reexported explicitly', () => {
|
||||
check('test/fixtures/reexported.d.ts', 'test/fixtures/reexported_expected.d.ts');
|
||||
});
|
||||
|
||||
it('should include symbols reexported with *', () => {
|
||||
check('test/fixtures/reexported_star.d.ts', 'test/fixtures/reexported_star_expected.d.ts');
|
||||
@ -95,7 +98,9 @@ describe('integration test: generateGoldenFile', () => {
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(() => { unlinkRecursively(outDir); });
|
||||
afterEach(() => {
|
||||
unlinkRecursively(outDir);
|
||||
});
|
||||
|
||||
|
||||
it('should generate a golden file', () => {
|
||||
|
@ -9,7 +9,7 @@
|
||||
import * as chai from 'chai';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {SerializationOptions, publicApiInternal} from '../lib/serializer';
|
||||
import {publicApiInternal, SerializationOptions} from '../lib/serializer';
|
||||
|
||||
const classesAndInterfaces = `
|
||||
export declare class A {
|
||||
@ -639,8 +639,9 @@ function check(
|
||||
|
||||
function checkThrows(
|
||||
files: {[name: string]: string}, error: string, options: SerializationOptions = {}) {
|
||||
chai.assert.throws(
|
||||
() => { publicApiInternal(getMockHost(files), 'file.d.ts', {}, options); }, error);
|
||||
chai.assert.throws(() => {
|
||||
publicApiInternal(getMockHost(files), 'file.d.ts', {}, options);
|
||||
}, error);
|
||||
}
|
||||
|
||||
function stripExtraIndentation(text: string) {
|
||||
@ -648,7 +649,7 @@ function stripExtraIndentation(text: string) {
|
||||
// Ignore first and last new line
|
||||
lines = lines.slice(1, lines.length - 1);
|
||||
const commonIndent = lines.reduce((min, line) => {
|
||||
const indent = /^( *)/.exec(line) ![1].length;
|
||||
const indent = /^( *)/.exec(line)![1].length;
|
||||
// Ignore empty line
|
||||
return line.length ? Math.min(min, indent) : min;
|
||||
}, text.length);
|
||||
|
Reference in New Issue
Block a user