Skip to content

Commit

Permalink
fix!: bump minimum required typedoc-plugin-markdown version to `4.0…
Browse files Browse the repository at this point in the history
….0-next.59`
  • Loading branch information
HiDeoo committed Apr 29, 2024
1 parent 5ce0374 commit 47a1f70
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/src/content/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ni starlight-typedoc typedoc typedoc-plugin-markdown@next
</Tabs>

:::note
The Starlight TypeDoc package requires at least the version `4.0.0-next.54` of `typedoc-plugin-markdown`, hence the `@next` tag in the installation command.
The Starlight TypeDoc package requires at least the version `4.0.0-next.59` of `typedoc-plugin-markdown`, hence the `@next` tag in the installation command.
:::

## Add the plugin
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"sharp": "0.32.6",
"starlight-typedoc": "workspace:*",
"typedoc": "0.25",
"typedoc-plugin-markdown": "4.0.0-next.54",
"typedoc-plugin-markdown": "4.0.0-next.59",
"typedoc-plugin-mdn-links": "3.0.3"
},
"engines": {
Expand Down
26 changes: 11 additions & 15 deletions packages/starlight-typedoc/libs/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
type PageEvent,
type CommentDisplayPart,
} from 'typedoc'
import { MarkdownTheme, MarkdownThemeRenderContext } from 'typedoc-plugin-markdown'
import { MarkdownTheme, MarkdownThemeContext } from 'typedoc-plugin-markdown'

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

Expand All @@ -21,27 +21,23 @@ export class StarlightTypeDocTheme extends MarkdownTheme {
}
}

class StarlightTypeDocThemeRenderContext extends MarkdownThemeRenderContext {
#markdownThemeRenderContext: MarkdownThemeRenderContext
class StarlightTypeDocThemeRenderContext extends MarkdownThemeContext {
#markdownThemeContext: MarkdownThemeContext

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

this.#markdownThemeRenderContext = new MarkdownThemeRenderContext(theme, event, options)
this.#markdownThemeContext = new MarkdownThemeContext(theme, event, options)
}

override helpers: MarkdownThemeRenderContext['helpers'] = {
// @ts-expect-error https://github.com/tgreyuk/typedoc-plugin-markdown/blob/2bc4136a364c1d1ab44789d6148cd19c425ce63c/docs/pages/docs/customizing-output.mdx#custom-theme
...this.helpers,
getRelativeUrl: (url: string) => {
const outputDirectory = this.options.getValue('starlight-typedoc-output')
const baseUrl = typeof outputDirectory === 'string' ? outputDirectory : ''
override getRelativeUrl(url: string): string {
const outputDirectory = this.options.getValue('starlight-typedoc-output')
const baseUrl = typeof outputDirectory === 'string' ? outputDirectory : ''

return getRelativeURL(url, baseUrl, this.page.url)
},
return getRelativeURL(url, baseUrl, this.page.url)
}

override partials: MarkdownThemeRenderContext['partials'] = {
override partials: MarkdownThemeContext['partials'] = {
// @ts-expect-error https://github.com/tgreyuk/typedoc-plugin-markdown/blob/2bc4136a364c1d1ab44789d6148cd19c425ce63c/docs/pages/docs/customizing-output.mdx#custom-theme
...this.partials,
comment: (comment, options) => {
Expand Down Expand Up @@ -70,7 +66,7 @@ class StarlightTypeDocThemeRenderContext extends MarkdownThemeRenderContext {

filteredComment.summary = comment.summary.map((part) => this.#parseCommentDisplayPart(part))

let markdown = this.#markdownThemeRenderContext.partials.comment(filteredComment, options)
let markdown = this.#markdownThemeContext.partials.comment(filteredComment, options)

if (options?.showSummary === false) {
return markdown
Expand Down Expand Up @@ -110,7 +106,7 @@ class StarlightTypeDocThemeRenderContext extends MarkdownThemeRenderContext {
) {
return {
...part,
target: this.helpers.getRelativeUrl(
target: this.getRelativeUrl(
path.posix.join(this.options.getValue('entryPointStrategy') === 'packages' ? '../..' : '..', part.target.url),
),
}
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight-typedoc/libs/typedoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const defaultTypeDocConfig: TypeDocConfig = {

const markdownPluginConfig: TypeDocConfig = {
hideBreadcrumbs: true,
hideInPageTOC: true,
hidePageHeader: true,
hidePageTitle: true,
}
Expand Down Expand Up @@ -88,6 +87,7 @@ async function bootstrapApp(
})
app.logger = new StarlightTypeDocLogger(logger)
app.options.addReader(new TSConfigReader())
// @ts-expect-error - Invalid theme typing
app.renderer.defineTheme('starlight-typedoc', StarlightTypeDocTheme)
app.renderer.on(PageEvent.END, (event: PageEvent<DeclarationReflection>) => {
onRendererPageEnd(event, pagination)
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight-typedoc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@astrojs/starlight": ">=0.15.0",
"astro": ">=4.0.0",
"typedoc": ">=0.25.0",
"typedoc-plugin-markdown": ">=4.0.0-next.54"
"typedoc-plugin-markdown": ">=4.0.0-next.59"
},
"engines": {
"node": ">=18.14.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test('should disable edit links', async ({ docPage }) => {
test('should support TypeDoc plugins', async ({ docPage }) => {
await docPage.goto('classes/foo')

const mdnLink = docPage.page.getByRole('link', { exact: true, name: 'HTMLElement' })
const mdnLink = docPage.page.getByRole('link', { exact: true, name: 'HTMLElement ↗️' })

await expect(mdnLink).toBeVisible()

Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

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

0 comments on commit 47a1f70

Please sign in to comment.