diff --git a/src/formatting.ts b/src/formatting.ts index 8618e67..a5de7d5 100644 --- a/src/formatting.ts +++ b/src/formatting.ts @@ -95,17 +95,17 @@ function linkToken(data: DocsData, token: string) { ); }); if (i) { - return `${token}`; + return `[${token}](#${i.slug})`; } const ta = data.typeAliases.find((ta) => ta.name === t); if (ta) { - return `${token}`; + return `[${token}](#${ta.slug})`; } const e = data.enums.find((e) => e.name === t || e.members.some((m) => e.name + '.' + m.name === t)); if (e) { - return `${token}`; + return `[${token}](#${e.slug})`; } return null; diff --git a/src/test/formatting.spec.ts b/src/test/formatting.spec.ts index eccc5f6..5ac2998 100644 --- a/src/test/formatting.spec.ts +++ b/src/test/formatting.spec.ts @@ -41,13 +41,13 @@ describe('formatting', () => { it('formatDescription w/ backticks', () => { const r = formatDescription(d, 'Hey `SomeInterface`!'); - expect(r).toEqual('Hey `SomeInterface`!'); + expect(r).toEqual('Hey [`SomeInterface`](#someinterface)!'); }); it('formatDescription', () => { const r = formatDescription(d, `Hey SomeInterface and SomeInterface.prop and SomeEnum and SomeEnum.Value!`); expect(r).toEqual( - `Hey SomeInterface and SomeInterface.prop and SomeEnum and SomeEnum.Value!` + `Hey [SomeInterface](#someinterface) and [SomeInterface.prop](#someinterface) and [SomeEnum](#someenum) and [SomeEnum.Value](#someenum)!` ); }); @@ -55,20 +55,20 @@ describe('formatting', () => { const r = formatType(d, `Promise>`); expect(r.type).toEqual(`Promise>`); expect(r.formatted).toEqual( - `Promise<SomeInterface | SomeEnum | Promise<void>>` + `Promise<[SomeInterface](#someinterface) | [SomeEnum](#someenum) | Promise<void>>` ); }); it('formatType interface promise', () => { const r = formatType(d, `Promise`); expect(r.type).toEqual(`Promise`); - expect(r.formatted).toEqual(`Promise<SomeInterface>`); + expect(r.formatted).toEqual(`Promise<[SomeInterface](#someinterface)>`); }); it('formatType interface', () => { const r = formatType(d, `SomeInterface`); expect(r.type).toEqual(`SomeInterface`); - expect(r.formatted).toEqual(`SomeInterface`); + expect(r.formatted).toEqual(`[SomeInterface](#someinterface)`); }); it('formatType remove undefined', () => {