Skip to content

Commit

Permalink
docs: rewrite api-docs generation using ts-morph (#2628)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Apr 1, 2024
1 parent 7dae52b commit 6191a5d
Show file tree
Hide file tree
Showing 58 changed files with 4,012 additions and 2,927 deletions.
7 changes: 1 addition & 6 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@
},
{
"groupName": "doc-dependencies",
"matchPackageNames": [
"@algolia/client-search",
"typedoc",
"typedoc-plugin-missing-exports",
"vitepress"
]
"matchPackageNames": ["@algolia/client-search", "ts-morph", "vitepress"]
}
],
"vulnerabilityAlerts": {
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.pnpm-store/
coverage/
dist/
test/scripts/apidoc/temp/
test/scripts/apidocs/temp/
CHANGELOG.md
CHANGELOG_old.md
pnpm-lock.yaml
4 changes: 2 additions & 2 deletions docs/.vitepress/components/api-docs/method-parameters.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { MethodParameter } from './method';
import type { ApiDocsMethodParameter } from './method';
const props = defineProps<{ parameters: MethodParameter[] }>();
const props = defineProps<{ parameters: ApiDocsMethodParameter[] }>();
</script>

<template>
Expand Down
18 changes: 9 additions & 9 deletions docs/.vitepress/components/api-docs/method.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
export interface Method {
export interface ApiDocsMethod {
readonly name: string;
readonly deprecated: string | undefined; // HTML
readonly description: string; // HTML
readonly parameters: MethodParameter[];
readonly since: string;
readonly parameters: ApiDocsMethodParameter[];
readonly returns: string;
readonly throws: string | undefined; // HTML
readonly examples: string; // HTML
readonly deprecated?: string; // HTML
readonly since: string;
readonly sourcePath: string; // URL-Suffix
readonly seeAlsos: string[];
readonly throws?: string; // HTML
readonly sourcePath: string; // URL-Suffix
}

export interface MethodParameter {
export interface ApiDocsMethodParameter {
readonly name: string;
readonly type?: string;
readonly default?: string;
readonly type: string | undefined;
readonly default: string | undefined;
readonly description: string; // HTML
}
4 changes: 2 additions & 2 deletions docs/.vitepress/components/api-docs/method.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script setup lang="ts">
import type { Method } from './method';
import type { ApiDocsMethod } from './method';
import MethodParameters from './method-parameters.vue';
import { slugify } from '../../shared/utils/slugify';
import { sourceBaseUrl } from '../../../api/source-base-url';
const props = defineProps<{ method: Method }>();
const props = defineProps<{ method: ApiDocsMethod }>();
function seeAlsoToUrl(see: string): string {
const [, module, method] = see.replace(/\(.*/, '').split('\.');
Expand Down
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@
"build:types": "tsc --project tsconfig.build.json",
"build": "run-s build:clean build:code build:types",
"generate": "run-s generate:locales generate:api-docs",
"generate:api-docs": "tsx ./scripts/apidoc.ts",
"generate:api-docs": "tsx ./scripts/apidocs.ts",
"generate:locales": "tsx ./scripts/generate-locales.ts",
"docs:build": "run-s docs:prepare docs:build:run",
"docs:build": "run-s generate:api-docs docs:build:run",
"docs:build:run": "vitepress build docs",
"docs:build:ci": "run-s build docs:build",
"docs:prepare": "run-s generate:api-docs",
"docs:dev": "run-s docs:prepare docs:dev:run",
"docs:dev": "run-s generate:api-docs docs:dev:run",
"docs:dev:run": "vitepress dev docs",
"docs:serve": "vitepress serve docs --port 5173",
"docs:diff": "tsx ./scripts/diff.ts",
Expand Down Expand Up @@ -126,9 +125,9 @@
"sanitize-html": "2.13.0",
"semver": "7.6.0",
"standard-version": "9.5.0",
"ts-morph": "22.0.0",
"tsup": "8.0.2",
"tsx": "4.7.1",
"typedoc": "0.25.12",
"typescript": "5.4.3",
"validator": "13.11.0",
"vite": "5.2.6",
Expand Down
81 changes: 33 additions & 48 deletions pnpm-lock.yaml

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

7 changes: 0 additions & 7 deletions scripts/apidoc.ts

This file was deleted.

86 changes: 0 additions & 86 deletions scripts/apidoc/faker-class.ts

This file was deleted.

Loading

0 comments on commit 6191a5d

Please sign in to comment.