Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update links, formatting and code examples #740

Merged
merged 3 commits into from
Dec 22, 2023
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 docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ export default defineConfig({
},
],
editLink: {
pattern: 'https://github.com/kubb-project/kubb/edit/main/docs/src/:path',
pattern: 'https://github.com/kubb-project/kubb/edit/main/docs/:path',
},
sidebar: {
'/config': configSidebar,
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ If you are using an older TypeScript version, please migrate to version 4.7 or l

## Latest <Badge type="tip" :text="version" />

You can install Kubb via [NPM](https://www.npmjs.com/).
You can install Kubb via [bun](https://bun.sh/), [pnpm](https://pnpm.io/), [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/).

::: code-group

Expand Down
12 changes: 6 additions & 6 deletions docs/guide/tutorial/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ outline: deep

# Basic tutorial

This tutorial will describe how you can set up Kubb + use the TypeScript plugin to generate types based on the `petStore.yaml` file.
This tutorial will describe how you can set up Kubb and use the [`@kubb/swagger-ts`](/plugins/swagger-ts/) plugin to generate types based on the `petStore.yaml` file.

The setup will contain from the beginning the following folder structure:

Expand All @@ -21,13 +21,13 @@ The setup will contain from the beginning the following folder structure:

## Step one

Set up your `kubb.config.ts`` file based on the [Quick-start](/guide/quick-start).
Set up your `kubb.config.ts` file based on the [Quick start](/guide/quick-start).

We will add here the [Swagger](/plugins/swagger) and [SwaggerTypescript](/plugins/swagger-ts)(which is dependent on the [Swagger](/plugins/swagger) plugin) plugin, those 2 plugins together will generate the TypeScript types.
We will add the plugins [`@kubb/swagger`](/plugins/swagger) and [`@kubb/swagger-ts`](/plugins/swagger-ts)(which is dependent on the [`@kubb/swagger`](/plugins/swagger) plugin). Together these two plugins will generate the TypeScript types.

Next to that, we will also set `output` to false for the [Swagger](/plugins/swagger) plugin because we don't need the plugin to generate the JSON schemas for us.
Next to that, we will also set `output` to false for the [`@kubb/swagger`](/plugins/swagger) plugin because we do not need the plugin to generate the JSON schemas for us.

- For the [SwaggerTypescript](/plugins/swagger-ts) plugin, we will set the `output` to the models folder.
- For the [`@kubb/swagger-ts`](/plugins/swagger-ts/) plugin, we will set the `output` to the `models` folder.

::: code-group

Expand Down Expand Up @@ -81,7 +81,7 @@ This will result in the following folder structure when Kubb has been executed

## Step two

Update your `package.json` and install `Kubb, see the [installation](/guide/introduction.html#configuration-file).
Update your `package.json` and install `Kubb`, see the [installation](/guide/installation).

Your `package.json` will look like this:

Expand Down
6 changes: 3 additions & 3 deletions docs/plugins/core/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ outline: deep

## Features

Every plugin of `Kubb` has options and with the global `Kubb`, you can access those options with `KubbJSONPlugins`.
Every plugin of `Kubb` has options and with the global `Kubb`, you can access those options with `Kubb.Plugins`.

See [packages/core/src/globals.d.ts](https://github.com/kubb-project/kubb/blob/main/packages/core/global.d.ts)
See [packages/core/src/globals.d.ts](https://github.com/kubb-project/kubb/blob/main/packages/core/globals.d.ts)

::: code-group

Expand Down Expand Up @@ -67,5 +67,5 @@ export type SwaggerPluginOptions = Kubb.OptionsPlugins['@kubb/swagger']['options

This feature could be useful for:

- Types support for 'kubb' options
- Types support for `Kubb` options
- Prototyping
9 changes: 4 additions & 5 deletions docs/plugins/core/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ The core contains the building blocks for all plugins.
- Read and write to the file system(Windows, Mac and Linux support).
- Format code/source with [Prettier](https://prettier.io/).
- Types needed to create a plugin and the types needed for the lifecycle/pluginManager.
- Basic utilities such as `isPromise`, [`isURL`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/utils/isURL.ts), [`createJSDocBlockText`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/utils/createJSDocBlockText.ts), `cache`,...
- Basic utilities such as `isPromise`, [`isURL`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/utils/URLPath.ts), [`createJSDocBlockText`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/transformers/createJSDocBlockText.ts), `cache`,...
- [`createPlugin`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/plugin.ts) functionality to set up a plugin.
- [`defineConfig`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/config.ts) functionality to set up the `kubb.config.js` file.
- Abstract classes for plugins
- [`Generator`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/generators/Generator.ts) which contains the base with a getter for `options` and a `build` function.
- [`SchemaGenerator`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/generators/SchemaGenerator.ts) which is a layer on top of the `Generator`.
- [`Generator`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/Generator.ts) which contains the base with a getter for `options` and a `build` function.
- Managers classes as the base for all logic
- [`FileManager`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/managers/fileManager/FileManager.ts) which is used to store all files before those are saved to the file system.
- [`PluginManager`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/managers/pluginManager/PluginManager.ts) which contains the logic of when which plugin can be triggered, see [pluginManager](/reference/pluginManager/).
- [`FileManager`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/FileManager.ts) which is used to store all files before those are saved to the file system.
- [`PluginManager`](https://github.com/kubb-project/kubb/blob/main/packages/core/src/PluginManager.ts) which contains the logic of when which plugin can be triggered, see [pluginManager](/reference/pluginManager/).

## Installation

Expand Down
10 changes: 3 additions & 7 deletions docs/plugins/swagger-client/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ outline: deep

## Features

- Client that is using 'axios' behind the scenes to do REST calls
- Client that is using [Axios](https://axios-http.com/docs/intro) behind the scenes to do REST calls
- Override with your own implementation

### Default `client`

By default, `@kubb/swagger-client/client` is getting used as the [`client`](http://localhost:3000/plugins/swagger-client/client#default-client).
By default, `@kubb/swagger-client/client` is getting used as the [`client`](/plugins/swagger-client/client#default-client).

::: code-group

Expand Down Expand Up @@ -105,7 +105,7 @@ export function addPet<TData = AddPetMutationResponse, TVariables = AddPetMutati
Create your own implementation of the `client`.
Handy when you want for example to use `fetch` instead of `axios`.

You can start by using a copy-paste of `@kubb`/swagger-client/client`.
You can start by using a copy-paste of `@kubb/swagger-client/client`.

::: code-group

Expand Down Expand Up @@ -275,7 +275,3 @@ export const axiosClient = async <TData, TError = unknown, TVariables = unknown>

export default axiosClient
```

## Links

- [plugins/core/fileManager#getenveource](/plugins/core/fileManager#getenveource)
4 changes: 2 additions & 2 deletions docs/plugins/swagger-client/globals.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ outline: deep
- `AXIOS_BASE` for Axios's `baseURL`
- `AXIOS_HEADERS` for Axios's `headers`

See [reference/fileManager#getenveource](/reference/fileManager#getenveource) for more information about how this works in the background.
See [FileManager#getEnvSource](https://github.com/kubb-project/kubb/blob/main/packages/core/src/FileManager.ts) for more information about how this works in the background.

::: code-group
<<< @/../packages/swagger-client/src/types.ts{12-15}
Expand Down Expand Up @@ -56,4 +56,4 @@ This feature could be useful for:

## Links

- [reference#getenveource](/reference#getenveource)
- [FileManager#getEnvSource](https://github.com/kubb-project/kubb/blob/main/packages/core/src/FileManager.ts)
28 changes: 14 additions & 14 deletions docs/plugins/swagger-client/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Default: `'clients'`
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -83,7 +83,7 @@ Type: `string` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -121,7 +121,7 @@ Type: `string` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -198,7 +198,7 @@ Default: `'{{tag}}Service'`
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -243,7 +243,7 @@ Default: `'@kubb/swagger-client/client'`
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -308,7 +308,7 @@ Default: `'data'`
::: code-group

```typescript ['data']
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand All @@ -333,7 +333,7 @@ export default defineConfig({
```

```typescript ['full']
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -396,7 +396,7 @@ Default: `'data'`
::: code-group

```typescript ['object']
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand All @@ -421,7 +421,7 @@ export default defineConfig({
```

```typescript ['inline']
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -469,7 +469,7 @@ Type: `Array<Include>` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -522,7 +522,7 @@ Type: `Array<Exclude>` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -576,7 +576,7 @@ Type: `Array<Override>` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -625,7 +625,7 @@ Type: `(name: string, type?: "function" | "type" | "file" ) => string` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -684,7 +684,7 @@ Type: `Templates` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerClient from '@kubb/swagger-client'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down
22 changes: 11 additions & 11 deletions docs/plugins/swagger-faker/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Default: `'mocks'`
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerFaker from '@kubb/swagger-faker'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -85,7 +85,7 @@ Type: `string` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerFaker from '@kubb/swagger-faker'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -123,7 +123,7 @@ Type: `string` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerFaker from '@kubb/swagger-faker'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -198,7 +198,7 @@ Default: `'{{tag}}Mocks'`
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerFaker from '@kubb/swagger-faker'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -252,7 +252,7 @@ Type: `Array<Include>` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerFaker from '@kubb/swagger-faker'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -305,7 +305,7 @@ Type: `Array<Exclude>` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerFaker from '@kubb/swagger-faker'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -359,7 +359,7 @@ Type: `Array<Override>` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerFaker from '@kubb/swagger-faker'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -406,7 +406,7 @@ Type: `(name: string, type?: "function" | "type" | "file" ) => string` <br/>
::: code-group

```typescript [kubb.config.js]
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerFaker from '@kubb/swagger-faker'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -466,7 +466,7 @@ Default: `'string'`
::: code-group

```typescript ['string']
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerFaker from '@kubb/swagger-faker'
import createSwaggerTS from '@kubb/swagger-ts'
Expand All @@ -491,7 +491,7 @@ export default defineConfig({
```

```typescript ['date']
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerFaker from '@kubb/swagger-faker'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down Expand Up @@ -529,7 +529,7 @@ Type: `'number' | 'number[]'` <br/>
::: code-group

```typescript
import { defineConfig } from '@kubb/swagger'
import { defineConfig } from '@kubb/core'
import createSwagger from '@kubb/swagger'
import createSwaggerFaker from '@kubb/swagger-faker'
import createSwaggerTS from '@kubb/swagger-ts'
Expand Down
Loading
Loading