Skip to content

Commit

Permalink
Add support for Astro 5 (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
HiDeoo authored Dec 17, 2024
1 parent 0cac985 commit c4014bc
Show file tree
Hide file tree
Showing 35 changed files with 2,665 additions and 2,342 deletions.
9 changes: 9 additions & 0 deletions .changeset/short-kangaroos-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'starlight-typedoc': minor
---

Adds support for Astro v5, drops support for Astro v4.

⚠️ **BREAKING CHANGE:** The minimum supported version of Starlight is now `0.30.0`.

Please follow the [upgrade guide](https://github.com/withastro/starlight/releases/tag/%40astrojs/starlight%400.30.0) to update your project.
3 changes: 0 additions & 3 deletions .eslintrc.json

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
build
coverage
dist
dist-multiple-entrypoints
dist-ssr
lerna-debug.log*
logs
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.14.1
v18.17.1
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ dist
dist-ssr
out
pnpm-lock.yaml
src/content/docs/api*
example/src/content/docs/api*
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"eslint.useFlatConfig": true,
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"html",
"vue",
"markdown",
"astro"
]
}
13 changes: 0 additions & 13 deletions docs/.prettierignore

This file was deleted.

16 changes: 8 additions & 8 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@
"build": "astro build",
"preview": "astro preview",
"astro": "astro",
"lint": "eslint . --cache --max-warnings=0",
"format": "prettier -w --cache --ignore-unknown ."
"lint": "eslint . --cache --max-warnings=0"
},
"dependencies": {
"@astrojs/starlight": "0.25.0",
"@hideoo/starlight-plugins-docs-components": "^0.2.2",
"astro": "4.16.10",
"sharp": "0.32.6"
"@astrojs/starlight": "^0.30.2",
"@hideoo/starlight-plugins-docs-components": "^0.3.0",
"astro": "^5.0.5",
"sharp": "^0.33.5"
},
"engines": {
"node": ">=18.14.1"
"node": ">=18.17.1"
},
"packageManager": "[email protected]",
"private": true,
Expand All @@ -36,7 +35,8 @@
"homepage": "https://github.com/HiDeoo/starlight-typedoc",
"repository": {
"type": "git",
"url": "https://github.com/HiDeoo/starlight-typedoc.git"
"url": "https://github.com/HiDeoo/starlight-typedoc.git",
"directory": "docs"
},
"bugs": "https://github.com/HiDeoo/starlight-typedoc/issues"
}
7 changes: 7 additions & 0 deletions docs/src/content.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { docsLoader } from '@astrojs/starlight/loaders'
import { docsSchema } from '@astrojs/starlight/schema'
import { defineCollection } from 'astro:content'

export const collections = {
docs: defineCollection({ loader: docsLoader(), schema: docsSchema() }),
}
7 changes: 0 additions & 7 deletions docs/src/content/config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ hero:
- text: Getting Started
link: /getting-started/
icon: rocket
variant: primary
- text: Demo
link: https://starlight-typedoc-example.vercel.app/api/functions/dothingc/
icon: external
variant: minimal
---

import { Card, CardGrid } from '@astrojs/starlight/components'
Expand Down
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import hideoo from '@hideoo/eslint-config'

export default hideoo()
1 change: 0 additions & 1 deletion example/.prettierignore

This file was deleted.

4 changes: 0 additions & 4 deletions example/.vscode/extensions.json

This file was deleted.

11 changes: 0 additions & 11 deletions example/.vscode/launch.json

This file was deleted.

1 change: 1 addition & 0 deletions example/astro.multiple-entrypoints.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default defineConfig({
title: 'Starlight TypeDoc Multiple Entry Points Example',
}),
],
outDir: './dist-multiple-entrypoints',
server: {
port: 4322,
},
Expand Down
31 changes: 19 additions & 12 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,31 @@
"dev:multiple-entrypoints": "astro dev --config astro.multiple-entrypoints.config.ts",
"dev:packages-entrypoints": "pnpm -C ../fixtures/packages run build && astro dev --config astro.packages-entrypoints.config.ts",
"dev:multiple-plugins": "astro dev --config astro.multiple-plugins.config.ts",
"start": "astro dev",
"build": "astro build",
"build:single-entrypoints": "astro build --config astro.config.ts",
"build:multiple-entrypoints": "astro build --config astro.multiple-entrypoints.config.ts",
"build:packages-entrypoints": "pnpm -C ../fixtures/packages run build && astro build --config astro.packages-entrypoints.config.ts",
"build:multiple-plugins": "astro build --config astro.multiple-plugins.config.ts",
"preview": "astro preview",
"preview:single-entrypoints": "astro preview --config astro.config.ts",
"preview:multiple-entrypoints": "astro preview --config astro.multiple-entrypoints.config.ts",
"preview:packages-entrypoints": "astro preview --config astro.packages-entrypoints.config.ts",
"preview:multiple-plugins": "astro preview --config astro.multiple-plugins.config.ts",
"astro": "astro",
"lint": "eslint . --cache --max-warnings=0",
"format": "prettier -w --cache --ignore-unknown ."
"lint": "eslint . --cache --max-warnings=0"
},
"dependencies": {
"@astrojs/starlight": "0.25.0",
"astro": "4.16.10",
"sharp": "0.32.6",
"@astrojs/starlight": "^0.30.2",
"astro": "^5.0.5",
"sharp": "^0.33.5",
"starlight-typedoc": "workspace:*",
"typedoc": "0.26.5",
"typedoc-plugin-frontmatter": "1.0.0",
"typedoc-plugin-markdown": "4.1.1",
"typedoc-plugin-mdn-links": "3.0.3"
"typedoc": "^0.26.5",
"typedoc-plugin-frontmatter": "^1.0.0",
"typedoc-plugin-markdown": "^4.1.1",
"typedoc-plugin-mdn-links": "^3.0.3"
},
"engines": {
"node": ">=18.14.1"
"node": ">=18.17.1"
},
"packageManager": "[email protected]",
"private": true,
Expand All @@ -45,7 +51,8 @@
"homepage": "https://github.com/HiDeoo/starlight-typedoc",
"repository": {
"type": "git",
"url": "https://github.com/HiDeoo/starlight-typedoc.git"
"url": "https://github.com/HiDeoo/starlight-typedoc.git",
"directory": "example"
},
"bugs": "https://github.com/HiDeoo/starlight-typedoc/issues"
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { docsSchema, i18nSchema } from '@astrojs/starlight/schema'
import { docsLoader } from '@astrojs/starlight/loaders'
import { docsSchema } from '@astrojs/starlight/schema'
import { defineCollection, z } from 'astro:content'

export const collections = {
docs: defineCollection({
loader: docsLoader(),
schema: docsSchema({
extend: z.object({
banner: z
Expand All @@ -16,5 +18,4 @@ export const collections = {
}),
}),
}),
i18n: defineCollection({ type: 'data', schema: i18nSchema() }),
}
4 changes: 2 additions & 2 deletions example/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ hero:
actions:
- text: Check Example
link: /api/functions/dothingc/
icon: right-arrow
variant: primary
icon: rocket
- text: Documentation
link: https://starlight-typedoc.vercel.app/
icon: external
variant: minimal
---

import { Card, CardGrid } from '@astrojs/starlight/components'
Expand Down
7 changes: 4 additions & 3 deletions fixtures/basics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"author": "HiDeoo <[email protected]> (https://hideoo.dev)",
"type": "module",
"dependencies": {
"typescript": "5.1.6"
"typescript": "^5.7.2"
},
"engines": {
"node": ">=18.14.1"
"node": ">=18.17.1"
},
"packageManager": "[email protected]",
"private": true,
Expand All @@ -25,7 +25,8 @@
"homepage": "https://github.com/HiDeoo/starlight-typedoc",
"repository": {
"type": "git",
"url": "https://github.com/HiDeoo/starlight-typedoc.git"
"url": "https://github.com/HiDeoo/starlight-typedoc.git",
"directory": "fixtures/basics"
},
"bugs": "https://github.com/HiDeoo/starlight-typedoc/issues"
}
2 changes: 1 addition & 1 deletion fixtures/basics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "../../tsconfig.json"
"extends": "@hideoo/tsconfig"
}
7 changes: 4 additions & 3 deletions fixtures/packages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"build": "tsc --build"
},
"dependencies": {
"typescript": "5.1.6"
"typescript": "^5.7.2"
},
"engines": {
"node": ">=18.14.1"
"node": ">=18.17.1"
},
"packageManager": "[email protected]",
"private": true,
Expand All @@ -28,7 +28,8 @@
"homepage": "https://github.com/HiDeoo/starlight-typedoc",
"repository": {
"type": "git",
"url": "https://github.com/HiDeoo/starlight-typedoc.git"
"url": "https://github.com/HiDeoo/starlight-typedoc.git",
"directory": "fixtures/packages"
},
"bugs": "https://github.com/HiDeoo/starlight-typedoc/issues"
}
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,30 @@
"type": "module",
"scripts": {
"test": "pnpm --stream -r test",
"lint": "pnpm -r lint",
"format": "pnpm -r format",
"lint": "astro check --noSync && pnpm -r lint",
"format": "prettier -w --cache --ignore-unknown .",
"version": "pnpm changeset version && pnpm i --no-frozen-lockfile"
},
"devDependencies": {
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.10",
"@hideoo/eslint-config": "2.0.1",
"@hideoo/prettier-config": "2.0.0",
"@hideoo/tsconfig": "2.0.1",
"eslint": "8.48.0",
"prettier": "3.0.3",
"typescript": "5.1.6"
"@astrojs/check": "^0.9.4",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.10",
"@hideoo/eslint-config": "^4.0.0",
"@hideoo/prettier-config": "^2.0.0",
"@hideoo/tsconfig": "^2.0.1",
"astro": "^5.0.5",
"eslint": "^9.17.0",
"prettier": "^3.4.2",
"typescript": "^5.7.2"
},
"engines": {
"node": ">=18.14.1"
"node": ">=18.17.1"
},
"packageManager": "[email protected]",
"pnpm": {
"peerDependencyRules": {
"allowedVersions": {
"typescript": "5.1.6"
"typescript": "5.7.2"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight-typedoc/.npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.eslintcache
eslint.config.mjs
playwright.config.ts
tests
tsconfig.json
vitest.config.ts
1 change: 0 additions & 1 deletion packages/starlight-typedoc/.prettierignore

This file was deleted.

10 changes: 10 additions & 0 deletions packages/starlight-typedoc/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import hideoo from '@hideoo/eslint-config'

export default hideoo({
ignores: ['eslint.config.mjs'],
languageOptions: {
parserOptions: {
project: ['../../tsconfig.json'],
},
},
})
4 changes: 3 additions & 1 deletion packages/starlight-typedoc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ function makeStarlightTypeDocPlugin(sidebarGroup: SidebarGroup): (options: Starl
return {
name: 'starlight-typedoc-plugin',
hooks: {
async setup({ astroConfig, config, logger, updateConfig }) {
async setup({ astroConfig, command, config, logger, updateConfig }) {
if (command === 'preview') return

const { outputDirectory, reflections } = await generateTypeDoc(options, astroConfig, logger)
const sidebar = getSidebarFromReflections(
config.sidebar,
Expand Down
15 changes: 4 additions & 11 deletions packages/starlight-typedoc/libs/theme.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
import path from 'node:path'

import {
Reflection,
type Comment,
type CommentTag,
type Options,
type PageEvent,
type CommentDisplayPart,
} from 'typedoc'
import { MarkdownTheme, MarkdownThemeContext } from 'typedoc-plugin-markdown'
import { Reflection, type Comment, type CommentTag, type Options, type CommentDisplayPart } from 'typedoc'
import { MarkdownTheme, MarkdownThemeContext, type MarkdownPageEvent } from 'typedoc-plugin-markdown'

import { getAsideMarkdown, getRelativeURL } from './starlight'

const customBlockTagTypes = ['@deprecated'] as const
const customModifiersTagTypes = ['@alpha', '@beta', '@experimental'] as const

export class StarlightTypeDocTheme extends MarkdownTheme {
override getRenderContext(event: PageEvent<Reflection>): StarlightTypeDocThemeRenderContext {
override getRenderContext(event: MarkdownPageEvent): StarlightTypeDocThemeRenderContext {
return new StarlightTypeDocThemeRenderContext(this, event, this.application.options)
}
}

class StarlightTypeDocThemeRenderContext extends MarkdownThemeContext {
#markdownThemeContext: MarkdownThemeContext

constructor(theme: MarkdownTheme, event: PageEvent<Reflection>, options: Options) {
constructor(theme: MarkdownTheme, event: MarkdownPageEvent, options: Options) {
super(theme, event, options)

this.#markdownThemeContext = new MarkdownThemeContext(theme, event, options)
Expand Down
Loading

0 comments on commit c4014bc

Please sign in to comment.