Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"updateInternalDependencies": "patch",
"fixed": [],
"linked": [],
"ignore": []
"ignore": ["@tanstack/integration-*"]
}
5 changes: 5 additions & 0 deletions .changeset/long-apples-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/typedoc-config': minor
---

feat: release @tanstack/typedoc-config
2 changes: 1 addition & 1 deletion integrations/react/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "react-integration",
"name": "@tanstack/integration-react",
"version": "1.0.0",
"private": true,
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion integrations/vanilla/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vanilla-integration",
"name": "@tanstack/integration-vanilla",
"version": "1.0.0",
"private": true,
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion integrations/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "vue-integration",
"name": "@tanstack/integration-vue",
"version": "1.0.0",
"private": true,
"type": "module",
Expand Down
4 changes: 1 addition & 3 deletions packages/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"@commitlint/parse": "catalog:",
"@eslint/js": "catalog:",
"@stylistic/eslint-plugin-js": "catalog:",
"@tanstack/typedoc-config": "workspace:",
"commander": "catalog:",
"esbuild-register": "catalog:",
"eslint-plugin-import-x": "catalog:",
Expand All @@ -74,9 +75,6 @@
"rollup-plugin-preserve-directives": "catalog:",
"semver": "catalog:",
"simple-git": "catalog:",
"typedoc": "catalog:",
"typedoc-plugin-frontmatter": "catalog:",
"typedoc-plugin-markdown": "catalog:",
"typescript-eslint": "catalog:",
"v8flags": "catalog:",
"vite-plugin-dts": "catalog:",
Expand Down
23 changes: 5 additions & 18 deletions packages/config/src/typedoc/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
import type { UserConfig } from 'vite'

export type Package = {
name: string
entryPoints: Array<string>
tsconfig: string
outputDir: string
exclude?: Array<string>
}

export type Options = {
/** Config for packages that need reference docs */
packages: Array<Package>
/** Override branch for GitHub links */
gitBranch?: string
}

export function generateReferenceDocs(config: Options): Promise<void>
export type {
Package,
Options,
generateReferenceDocs,
} from '@tanstack/typedoc-config'
59 changes: 1 addition & 58 deletions packages/config/src/typedoc/index.js
Original file line number Diff line number Diff line change
@@ -1,58 +1 @@
import { resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { mkdir, rm } from 'node:fs/promises'
import * as TypeDoc from 'typedoc'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

/**
* @type {Partial<import("typedoc").TypeDocOptions & import("typedoc-plugin-markdown").PluginOptions>}
*/
const settings = {
plugin: [
'typedoc-plugin-markdown',
'typedoc-plugin-frontmatter',
resolve(__dirname, './typedoc-custom-settings.js'),
],
hideGenerator: true,
readme: 'none',
entryFileName: 'index',
hideBreadcrumbs: true,
hidePageHeader: true,
useCodeBlocks: true,
excludePrivate: true,
}

/**
* @param {import('./index.js').Options} options
* @returns {Promise<void>}
*/
export const generateReferenceDocs = async (options) => {
for (const pkg of options.packages) {
// Clean and recreate the output directories
try {
await rm(pkg.outputDir, { recursive: true })
} catch (error) {
// @ts-expect-error
if (error.code !== 'ENOENT') {
throw error
}
}
await mkdir(pkg.outputDir, { recursive: true })

const app = await TypeDoc.Application.bootstrapWithPlugins({
...settings,
gitRevision: options.gitBranch ?? 'main',
entryPoints: pkg.entryPoints,
tsconfig: pkg.tsconfig,
exclude: pkg.exclude,
out: pkg.outputDir,
})

const project = await app.convert()

if (project) {
await app.generateOutputs(project)
}
}
}
export { generateReferenceDocs } from '@tanstack/typedoc-config'
5 changes: 5 additions & 0 deletions packages/typedoc-config/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import { tanstackConfig } from '../config/src/eslint/index.js'

export default [...tanstackConfig]
49 changes: 49 additions & 0 deletions packages/typedoc-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "@tanstack/typedoc-config",
"version": "0.0.0",
"description": "Configuration and tools for publishing and maintaining TanStack projects.",
"author": "tannerlinsley",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/TanStack/config.git",
"directory": "packages/typedoc-config"
},
"homepage": "https://tanstack.com/config",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/tannerlinsley"
},
"scripts": {
"test:types": "tsc",
"test:eslint": "eslint ./src",
"test:build": "publint --strict"
},
"type": "module",
"exports": {
".": {
"import": {
"types": "./src/index.d.ts",
"default": "./src/index.js"
}
},
"./package.json": "./package.json"
},
"preferGlobal": false,
"sideEffects": false,
"files": [
"src"
],
"engines": {
"node": ">=18"
},
"dependencies": {
"typedoc": "catalog:",
"typedoc-plugin-frontmatter": "catalog:",
"typedoc-plugin-markdown": "catalog:"
},
"devDependencies": {
"@types/eslint": "catalog:",
"eslint": "catalog:"
}
}
18 changes: 18 additions & 0 deletions packages/typedoc-config/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { UserConfig } from 'vite'

export type Package = {
name: string
entryPoints: Array<string>
tsconfig: string
outputDir: string
exclude?: Array<string>
}

export type Options = {
/** Config for packages that need reference docs */
packages: Array<Package>
/** Override branch for GitHub links */
gitBranch?: string
}

export function generateReferenceDocs(config: Options): Promise<void>
58 changes: 58 additions & 0 deletions packages/typedoc-config/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { mkdir, rm } from 'node:fs/promises'
import * as TypeDoc from 'typedoc'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

/**
* @type {Partial<import("typedoc").TypeDocOptions & import("typedoc-plugin-markdown").PluginOptions>}
*/
const settings = {
plugin: [
'typedoc-plugin-markdown',
'typedoc-plugin-frontmatter',
resolve(__dirname, './typedoc-custom-settings.js'),
],
hideGenerator: true,
readme: 'none',
entryFileName: 'index',
hideBreadcrumbs: true,
hidePageHeader: true,
useCodeBlocks: true,
excludePrivate: true,
}

/**
* @param {import('./index.js').Options} options
* @returns {Promise<void>}
*/
export const generateReferenceDocs = async (options) => {
for (const pkg of options.packages) {
// Clean and recreate the output directories
try {
await rm(pkg.outputDir, { recursive: true })
} catch (error) {
// @ts-expect-error
if (error.code !== 'ENOENT') {
throw error
}
}
await mkdir(pkg.outputDir, { recursive: true })

const app = await TypeDoc.Application.bootstrapWithPlugins({
...settings,
gitRevision: options.gitBranch ?? 'main',
entryPoints: pkg.entryPoints,
tsconfig: pkg.tsconfig,
exclude: pkg.exclude,
out: pkg.outputDir,
})

const project = await app.convert()

if (project) {
await app.generateOutputs(project)
}
}
}
4 changes: 4 additions & 0 deletions packages/typedoc-config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["bin", "src", "eslint.config.js"]
}
31 changes: 22 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading