/starlight-typedoc

Astro integration for Starlight to generate documentation from TypeScript using TypeDoc

Primary LanguageTypeScriptMIT LicenseMIT

starlight-typedoc 📚

Astro integration for Starlight to generate documentation from TypeScript using TypeDoc.

Screenshot of starlight-typedoc

Integration Status License

Features

An Astro integration* for Starlight using TypeDoc and typedoc-plugin-markdown to generate documentation from TypeScript code.

Check out the example for a preview of the generated documentation.

Some TSDoc tags uses a custom Markdown syntax, e.g. the @deprecated, @alpha, @beta and @experimental tags using Starlight asides:

Screenshot of a deprecated tag in Starlight



*: starlight-typedoc is currently not available as an Astro Integration due to current Starlight limitations but the goal is to make it available as one in the future.

Installation

Install the Starlight TypeDoc package and its peer dependencies using your favorite package manager, e.g. with pnpm:

pnpm add starlight-typedoc typedoc typedoc-plugin-markdown@next

Update your Astro configuration to generate documentation from your TypeScript code:

  import starlight from '@astrojs/starlight'
  import { defineConfig } from 'astro/config'
+ import { generateTypeDoc } from 'starlight-typedoc'

+ const typeDocSidebarGroup = await generateTypeDoc({
+   entryPoints: ['../path/to/entry-point.ts'],
+   tsconfig: '../path/to/tsconfig.json',
+ })

  export default defineConfig({
    // …
    integrations: [
      starlight({
        sidebar: [
          {
            label: 'Guides',
            items: [{ label: 'Example Guide', link: '/guides/example/' }],
          },
+         typeDocSidebarGroup,
        ],
        title: 'My Docs',
      }),
    ],
  })

Configuration

The generateTypeDoc function returns a group of SidebarItem containing the generated documentation sidebar navigation items and can be used in the Starlight configuration. It accepts an object with the following properties:

Name Description Required
entryPoints The path(s) to the entry point(s) to document.
tsconfig The path to the tsconfig.json file to use for the documentation generation.
output The output directory containing the generated documentation markdown files relative to the src/content/docs/ directory.
pagination Whether the footer should include previous and next page links for the generated documentation.
sidebar The generated documentation sidebar configuration.
typeDoc Additional TypeDoc or typedoc-plugin-markdown configuration to override the default settings used by this integration.
watch Whether to watch the entry point(s) for changes and regenerate the documentation when needed.

Sidebar configuration

The sidebar configuration is an object with the following properties:

Name Description Required
collapsed Wheter the generated documentation sidebar group should be collapsed by default. Note that nested sidebar groups are always collapsed.
label The generated documentation sidebar group label.

License

Licensed under the MIT License, Copyright © HiDeoo.

See LICENSE for more information.