本文整理汇总了TypeScript中dgeni/lib/Injector.Injector类的典型用法代码示例。如果您正苦于以下问题:TypeScript Injector类的具体用法?TypeScript Injector怎么用?TypeScript Injector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Injector类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(() => {
dgeni = new Dgeni([mockPackage()]);
injector = dgeni.configureInjector();
tsProcessor = injector.get('readTypeScriptModules');
parseTagsProcessor = injector.get('parseTagsProcessor');
extractTagsProcessor = injector.get('extractTagsProcessor');
mergeParameterInfoProcessor = injector.get('mergeParameterInfo');
tsProcessor.basePath = path.resolve(__dirname, '../mocks/readTypeScriptModules');
tsProcessor.sourceFiles = ['methodParameters.ts'];
});
开发者ID:angular,项目名称:dgeni-packages,代码行数:11,代码来源:mergeParameterInfo.spec.ts
示例2: describe
describe('mergeParameterInfo', () => {
let dgeni: Dgeni;
let injector: Injector;
let tsProcessor: ReadTypeScriptModules;
let mergeParameterInfoProcessor: MergeParameterInfoProcessor;
let parseTagsProcessor: Processor;
let extractTagsProcessor: Processor;
beforeEach(() => {
dgeni = new Dgeni([mockPackage()]);
injector = dgeni.configureInjector();
tsProcessor = injector.get('readTypeScriptModules');
parseTagsProcessor = injector.get('parseTagsProcessor');
extractTagsProcessor = injector.get('extractTagsProcessor');
mergeParameterInfoProcessor = injector.get('mergeParameterInfo');
tsProcessor.basePath = path.resolve(__dirname, '../mocks/readTypeScriptModules');
tsProcessor.sourceFiles = ['methodParameters.ts'];
});
it('should merge the param tags into the parameter docs', () => {
const docsArray: DocCollection = [];
tsProcessor.$process(docsArray);
parseTagsProcessor.$process(docsArray);
extractTagsProcessor.$process(docsArray);
mergeParameterInfoProcessor.$process(docsArray);
const param5: ParameterDoc = docsArray.find(doc => doc.name === 'param5' && doc.container.name === 'method2');
expect(param5.id).toEqual('methodParameters/TestClass.method2()~param5');
expect(param5.description).toEqual('description of param5');
expect(param5.type).toEqual('string');
const param6: ParameterDoc = docsArray.find(doc => doc.name === 'param6' && doc.container.name === 'method2');
expect(param6.id).toEqual('methodParameters/TestClass.method2()~param6');
expect(param6.description).toEqual('description of param6');
expect(param6.type).toEqual('number');
const param7: ParameterDoc = docsArray.find(doc => doc.name === 'param7' && doc.container.name === 'method2');
expect(param7.id).toEqual('methodParameters/TestClass.method2()~param7');
expect(param7.description).toEqual('description of param7');
expect(param7.type).toEqual('number');
expect(param7.defaultValue).toEqual('42');
});
});
开发者ID:angular,项目名称:dgeni-packages,代码行数:46,代码来源:mergeParameterInfo.spec.ts
示例3: beforeEach
beforeEach(() => {
dgeni = new Dgeni([mockPackage()]);
injector = dgeni.configureInjector();
processor = injector.get('readTypeScriptModules');
processor.basePath = path.resolve(__dirname, '../../mocks/readTypeScriptModules');
});
开发者ID:angular,项目名称:dgeni-packages,代码行数:6,代码来源:index.spec.ts
示例4: describe
describe('readTypeScriptModules', () => {
let dgeni: Dgeni;
let injector: Injector;
let processor: ReadTypeScriptModules;
beforeEach(() => {
dgeni = new Dgeni([mockPackage()]);
injector = dgeni.configureInjector();
processor = injector.get('readTypeScriptModules');
processor.basePath = path.resolve(__dirname, '../../mocks/readTypeScriptModules');
});
describe('exportDocs', () => {
it('should extract all content from the comments', () => {
processor.sourceFiles = [ 'commentContent.ts' ];
const docs: DocCollection = [];
processor.$process(docs);
const someClassDoc = docs.find(doc => doc.name === 'SomeClass');
expect(someClassDoc.content).toEqual('@empty');
const fooDoc = docs.find(doc => doc.name === 'foo');
expect(fooDoc.content).toEqual('The description\n@tag1\ntag info');
const barDoc = docs.find(doc => doc.name === 'bar');
expect(barDoc.content).toEqual('@name bar\n@description\ndescription of bar {@inline-tag} more content');
});
it('should extract the starting and ending lines from the comments', () => {
processor.sourceFiles = [ 'commentContent.ts' ];
const docs: DocCollection = [];
processor.$process(docs);
const someClassDoc = docs.find(doc => doc.name === 'SomeClass') as ClassExportDoc;
expect(someClassDoc.startingLine).toEqual(0);
expect(someClassDoc.endingLine).toEqual(17);
const fooDoc = docs.find(doc => doc.name === 'foo');
expect(fooDoc.startingLine).toEqual(4);
expect(fooDoc.endingLine).toEqual(9);
const barDoc = docs.find(doc => doc.name === 'bar');
expect(barDoc.startingLine).toEqual(10);
expect(barDoc.endingLine).toEqual(16);
});
it('should provide the original module if the export is re-exported', () => {
processor.sourceFiles = [ 'publicModule.ts' ];
const docs: DocCollection = [];
processor.$process(docs);
const exportedDoc = docs[1];
expect(exportedDoc.originalModule).toEqual('privateModule');
});
it('should include exported abstract classes', () => {
processor.sourceFiles = [ 'publicModule.ts' ];
const docs: DocCollection = [];
processor.$process(docs);
const exportedDoc = docs[2];
expect(exportedDoc.name).toEqual('AbstractClass');
});
it('should hide members marked as private in TypeScript', () => {
processor.sourceFiles = [ 'privateMembers.ts' ];
const docs: DocCollection = [];
processor.$process(docs);
expect(docs.every(doc => doc.name !== 'privateProperty')).toBe(true);
});
it('should put static members into the `.statics` property of the export doc', () => {
processor.sourceFiles = [ 'staticMembers.ts' ];
const docs: DocCollection = [];
processor.$process(docs);
const classDoc: ClassExportDoc = docs.find(doc => doc.docType === 'class');
expect(classDoc.statics.length).toEqual(2);
expect(classDoc.statics.map(staticMember => staticMember.name)).toEqual(['staticA', 'num']);
expect(classDoc.members.length).toEqual(0);
});
it('should add additional declarations of a symbol onto the exportDoc', () => {
processor.sourceFiles = [ 'multipleDeclarations.ts' ];
const docs: DocCollection = [];
processor.$process(docs);
const someThingDoc = docs.find(doc => doc.name === 'SomeThing');
expect(someThingDoc.docType).toEqual('interface');
expect(someThingDoc.content).toEqual('the constant doc');
expect(someThingDoc.additionalDeclarations).toEqual([
someThingDoc.symbol.getDeclarations()[0],
]);
});
it('should remove `index` from the end of module ids and names', () => {
processor.sourceFiles = [ 'test/folder/index.ts' ];
const docs: DocCollection = [];
processor.$process(docs);
//.........这里部分代码省略.........
开发者ID:angular,项目名称:dgeni-packages,代码行数:101,代码来源:index.spec.ts
示例5: it
it('should add each exportDoc to the exportSymbolsToDocsMap', () => {
processor.sourceFiles = [ 'returnTypes.ts' ];
const docs: DocCollection = [];
processor.$process(docs);
const map = injector.get('exportSymbolsToDocsMap') as Map<Symbol, ExportDoc>;
expect(map.size).toEqual(2);
map.forEach((doc, symbol) => {
expect(doc.symbol).toBe(symbol);
});
});
开发者ID:angular,项目名称:dgeni-packages,代码行数:11,代码来源:index.spec.ts
注:本文中的dgeni/lib/Injector.Injector类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论