Skip to content

Commit

Permalink
Merge pull request #36 from HiDeoo/hd-docs-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
HiDeoo authored Jun 24, 2024
2 parents ae6de0d + 1724158 commit 939fbcf
Show file tree
Hide file tree
Showing 17 changed files with 1,251 additions and 951 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

## Docs

Run the docs locally using your favorite package manager, e.g. with [pnpm](https://pnpm.io):
Run the docs locally using [pnpm](https://pnpm.io):

```shell
pnpm run dev
Expand Down
7 changes: 7 additions & 0 deletions docs/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ export default defineConfig({
{ label: 'Configuration', link: '/configuration/' },
],
},
{
label: 'Resources',
items: [
{ label: 'Showcase', link: '/resources/showcase/' },
{ label: 'Plugins and Tools', link: '/resources/starlight/' },
],
},
{
label: 'Demo',
items: openAPISidebarGroups,
Expand Down
10 changes: 5 additions & 5 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"lint": "prettier -c --cache . && eslint . --cache --max-warnings=0"
},
"dependencies": {
"@astrojs/starlight": "0.19.0",
"astro": "4.4.0",
"sharp": "0.33.2",
"starlight-openapi": "workspace:*",
"starlight-package-managers": "0.3.0"
"@astrojs/starlight": "0.24.4",
"@hideoo/starlight-plugins-docs-components": "^0.2.2",
"astro": "4.11.1",
"sharp": "0.32.6",
"starlight-openapi": "workspace:*"
},
"engines": {
"node": ">=18.14.1"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/assets/showcase/docs.garajonai.com.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/assets/showcase/docs.taiko.xyz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/assets/showcase/fxhu.kripod.dev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/assets/showcase/openpayments.dev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/assets/showcase/openpodcastapi.org.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions docs/src/components/PackageManagers.astro

This file was deleted.

96 changes: 51 additions & 45 deletions docs/src/content/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ title: Getting Started
description: Learn how to generate documentation from OpenAPI/Swagger specifications using the Starlight OpenAPI plugin.
---

import PackageManagers from '../../components/PackageManagers.astro'

A [Starlight](https://starlight.astro.build) plugin to generate documentation from OpenAPI/Swagger specifications.

- Support for [Swagger 2.0](https://swagger.io/specification/v2/), [OpenAPI 3.0](https://swagger.io/specification/v3/) and [OpenAPI 3.1](https://swagger.io/specification/) specifications.
Expand All @@ -16,48 +14,56 @@ A [Starlight](https://starlight.astro.build) plugin to generate documentation fr
You will need to have a Starlight website set up.
If you don't have one yet, you can follow the ["Getting Started"](https://starlight.astro.build/getting-started) guide in the Starlight docs to create one.

## Install the plugin

Starlight OpenAPI is a Starlight [plugin](https://starlight.astro.build/reference/plugins/).
Install it using your favorite package manager:

<PackageManagers pkg="starlight-openapi" />

## Configure the plugin

The Starlight OpenAPI plugin can be configured in your Starlight [configuration](https://starlight.astro.build/reference/configuration/#plugins) in the `astro.config.mjs` file.

```diff lang="js"
// astro.config.mjs
import starlight from '@astrojs/starlight'
import { defineConfig } from 'astro/config'
+import starlightOpenAPI, { openAPISidebarGroups } from 'starlight-openapi'

export default defineConfig({
integrations: [
starlight({
+ plugins: [
+ // Generate the OpenAPI documentation pages.
+ starlightOpenAPI([
+ {
+ base: 'api',
+ label: 'My API',
+ schema: '../schemas/api-schema.yaml',
+ },
+ ]),
+ ],
sidebar: [
{
label: 'Guides',
items: [{ label: 'Example Guide', link: '/guides/example/' }],
},
+ // Add the generated sidebar group to the sidebar.
+ ...openAPISidebarGroups,
],
title: 'My Docs',
}),
],
})
```
## Installation

import { Steps } from '@astrojs/starlight/components'
import { PackageManagers } from '@hideoo/starlight-plugins-docs-components'

<Steps>

1. Starlight OpenAPI is a Starlight [plugin](https://starlight.astro.build/reference/plugins/). Install it using your favorite package manager:

<PackageManagers pkg="starlight-openapi" />

2. Configure the plugin in your Starlight [configuration](https://starlight.astro.build/reference/configuration/#plugins) in the `astro.config.mjs` file.

The following example shows how to specify a schema file and add the generated sidebar group to the sidebar:

```diff lang="js"
// astro.config.mjs
import starlight from '@astrojs/starlight'
import { defineConfig } from 'astro/config'
+import starlightOpenAPI, { openAPISidebarGroups } from 'starlight-openapi'

export default defineConfig({
integrations: [
starlight({
+ plugins: [
+ // Generate the OpenAPI documentation pages.
+ starlightOpenAPI([
+ {
+ base: 'api',
+ label: 'My API',
+ schema: '../schemas/api-schema.yaml',
+ },
+ ]),
+ ],
sidebar: [
{
label: 'Guides',
items: [{ label: 'Example Guide', link: '/guides/example/' }],
},
+ // Add the generated sidebar group to the sidebar.
+ ...openAPISidebarGroups,
],
title: 'My Docs',
}),
],
})
```

3. [Start the development server](https://starlight.astro.build/getting-started/#start-the-development-server) to preview the generated documentation.

</Steps>

The Starlight OpenAPI plugin behavior can be tweaked using various [configuration options](/configuration).
52 changes: 52 additions & 0 deletions docs/src/content/docs/resources/showcase.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
title: Showcase
description: Discover Starlight project using the Starlight OpenAPI plugin.
---

import { ShowcaseIntro, Showcase } from '@hideoo/starlight-plugins-docs-components'

<ShowcaseIntro
cta="Have you built a documentation using Starlight OpenAPI?"
href="https://github.com/HiDeoo/starlight-openapi/edit/main/docs/src/content/docs/resources/showcase.mdx"
/>

## Sites

Starlight OpenAPI is already being used in production. These are some of the sites around the web:

<Showcase
entries={[
{
thumbnail: import('../../../assets/showcase/openpayments.dev.png'),
href: 'https://openpayments.dev/',
title: 'Open Payments',
},
{
thumbnail: import('../../../assets/showcase/classchartsapi.github.io.png'),
href: 'https://classchartsapi.github.io/api-docs/',
title: 'ClassCharts API',
},
{
thumbnail: import('../../../assets/showcase/openpodcastapi.org.png'),
href: 'https://openpodcastapi.org/',
title: 'Open Podcast API',
},
{
thumbnail: import('../../../assets/showcase/docs.garajonai.com.png'),
href: 'https://docs.garajonai.com/',
title: 'GarajonAI',
},
{
thumbnail: import('../../../assets/showcase/fxhu.kripod.dev.png'),
href: 'https://fxhu.kripod.dev/',
title: 'FXHU',
},
{
thumbnail: import('../../../assets/showcase/docs.taiko.xyz.png'),
href: 'https://docs.taiko.xyz/start-here/getting-started',
title: 'Taiko',
},
]}
/>

See all the [public project repos using Starlight on GitHub](https://github.com/hideoo/starlight-openapi/network/dependents).
20 changes: 20 additions & 0 deletions docs/src/content/docs/resources/starlight.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: Starlight Plugins and Tools
description: Discover other Starlight plugins, components and tools developed by HiDeoo.
---

import { ResourcesIntro, Resources } from '@hideoo/starlight-plugins-docs-components'

<ResourcesIntro />

## Plugins

<Resources type="plugins" />

## Components

<Resources type="components" />

## Tools

<Resources type="tools" />
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@hideoo/eslint-config": "3.0.0",
"@hideoo/prettier-config": "2.0.0",
"@hideoo/tsconfig": "2.0.1",
"astro": "4.4.0",
"astro": "4.11.1",
"eslint": "8.56.0",
"husky": "8.0.3",
"lint-staged": "14.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/starlight-openapi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

## Getting Started

Want to get started immediately? Check out the [getting started guide](https://starlight-openapi.vercel.app/guides/getting-started/) or a [live demo](https://starlight-openapi.vercel.app/api/petstore/operations/addpet/).
Want to get started immediately? Check out the [getting started guide](https://starlight-openapi.vercel.app/guides/getting-started/) or check out the [demo](https://starlight-openapi.vercel.app/api/petstore/operations/addpet/) to see the plugin in action.

## Features

Expand Down
4 changes: 2 additions & 2 deletions packages/starlight-openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"github-slugger": "2.0.0"
},
"devDependencies": {
"@astrojs/starlight": "0.19.0",
"@astrojs/starlight": "0.24.4",
"@playwright/test": "1.36.2",
"@types/node": "18.17.3",
"astro": "4.4.0",
"astro": "4.11.1",
"openapi-types": "12.1.3"
},
"peerDependencies": {
Expand Down
Loading

0 comments on commit 939fbcf

Please sign in to comment.