(pkg: PackageReferenceDocsConfig)
| 137 | } |
| 138 | |
| 139 | async function generatePackageReferenceDocs(pkg: PackageReferenceDocsConfig) { |
| 140 | const outputDir = pkg.outputDir |
| 141 | await rm(outputDir, { recursive: true, force: true }) |
| 142 | await mkdir(outputDir, { recursive: true }) |
| 143 | |
| 144 | const app = await TypeDoc.Application.bootstrapWithPlugins({ |
| 145 | plugin: [ |
| 146 | 'typedoc-plugin-markdown', |
| 147 | 'typedoc-plugin-frontmatter', |
| 148 | '@tanstack/typedoc-config/typedoc-custom-settings', |
| 149 | ], |
| 150 | hideGenerator: true, |
| 151 | readme: 'none', |
| 152 | entryFileName: 'index', |
| 153 | hideBreadcrumbs: true, |
| 154 | hidePageHeader: true, |
| 155 | hidePageTitle: true, |
| 156 | useCodeBlocks: true, |
| 157 | // `parametersFormat` and `typeDeclarationFormat` are deliberately left as lists: the first |
| 158 | // puts the huge conditional types of `useQueries` into a single cell and drops `@default` |
| 159 | // blocks, and the second collapses `@example` code blocks onto one line, which swallows the |
| 160 | // following statement into a `//` comment. |
| 161 | interfacePropertiesFormat: 'table', |
| 162 | typeAliasPropertiesFormat: 'table', |
| 163 | tableColumnSettings: { |
| 164 | hideInherited: true, |
| 165 | hideSources: true, |
| 166 | }, |
| 167 | // Without this, a function property renders as `(data) => TData` — the table and list formats |
| 168 | // both omit the parameter types otherwise. |
| 169 | expandParameters: true, |
| 170 | excludePrivate: true, |
| 171 | excludeProtected: true, |
| 172 | excludeInternal: true, |
| 173 | excludeExternals: true, |
| 174 | sourceLinkTemplate: |
| 175 | 'https://github.com/TanStack/query/blob/{gitRevision}/{path}#L{line}', |
| 176 | gitRevision: 'main', |
| 177 | displayBasePath: resolve(__dirname, '..'), |
| 178 | entryPoints: pkg.entryPoints, |
| 179 | tsconfig: pkg.tsconfig, |
| 180 | ...(pkg.exclude && { exclude: pkg.exclude }), |
| 181 | out: outputDir, |
| 182 | }) |
| 183 | |
| 184 | // TypeScript flattens an alias out of an intersection, so `Options<T> & QueryKeyWithDataTag<T>` |
| 185 | // would render as the members of `Options` followed by the tag. Convert declared intersections from |
| 186 | // the source instead, so signatures keep the alias names they were written with. |
| 187 | app.converter.on( |
| 188 | TypeDoc.Converter.EVENT_CREATE_SIGNATURE, |
| 189 | ( |
| 190 | context: InstanceType<typeof TypeDoc.Context>, |
| 191 | signature: InstanceType<typeof TypeDoc.SignatureReflection>, |
| 192 | declaration?: ts.Node, |
| 193 | ) => { |
| 194 | if (!declaration || !ts.isFunctionLike(declaration)) { |
| 195 | return |
| 196 | } |
no test coverage detected