當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Injector.Injector類代碼示例

本文整理匯總了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;未經允許,請勿轉載。