@mintlify/scraping 4.0.952 → 4.0.954

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintlify/scraping",
3
- "version": "4.0.952",
3
+ "version": "4.0.954",
4
4
  "description": "Scrape documentation frameworks to Mintlify docs",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -43,7 +43,7 @@
43
43
  "format:check": "oxfmt --check"
44
44
  },
45
45
  "dependencies": {
46
- "@mintlify/common": "1.0.1085",
46
+ "@mintlify/common": "1.0.1086",
47
47
  "fast-xml-parser": "5.7.3",
48
48
  "fs-extra": "11.1.1",
49
49
  "graphql": "16.11.0",
@@ -63,9 +63,9 @@
63
63
  "zod": "3.24.0"
64
64
  },
65
65
  "devDependencies": {
66
- "@mintlify/models": "0.0.347",
66
+ "@mintlify/models": "0.0.348",
67
67
  "@mintlify/ts-config": "2.0.2",
68
- "@mintlify/validation": "0.1.825",
68
+ "@mintlify/validation": "0.1.826",
69
69
  "@tsconfig/recommended": "1.0.2",
70
70
  "@types/hast": "3.0.4",
71
71
  "@types/mdast": "4.0.4",
@@ -79,5 +79,5 @@
79
79
  "typescript": "5.5.3",
80
80
  "vitest": "2.1.9"
81
81
  },
82
- "gitHead": "2a68e3ad7ad0237b95413bf78989cfb5031d9d85"
82
+ "gitHead": "779dd0a76dc2128fe36244c7761cf765d3774f27"
83
83
  }
package/src/index.ts CHANGED
@@ -14,5 +14,13 @@ export { checkUrl } from './utils/url.js';
14
14
  export { FINAL_SUCCESS_MESSAGE } from './constants.js';
15
15
  export { parseGraphqlSdl } from './graphql/parseGraphqlSdl.js';
16
16
  export { generateSdkReference } from './sdk/generateSdkReference.js';
17
+ export { findSdkPage, matchesSdkPageTarget, renderSdkTarget } from './sdk/findSdkPage.js';
17
18
  export { htmlToMdx, hastToMdx, markdownToMdx } from './sdk/convert.js';
18
- export type { SdkFormat, SdkPage, SdkNavGroup, SdkReference, SdkConverter } from './sdk/types.js';
19
+ export type {
20
+ SdkFormat,
21
+ SdkPage,
22
+ SdkPageTarget,
23
+ SdkNavGroup,
24
+ SdkReference,
25
+ SdkConverter,
26
+ } from './sdk/types.js';
@@ -1,8 +1,9 @@
1
+ import type { SdkSymbolKind } from '@mintlify/models';
1
2
  import fse from 'fs-extra';
2
3
  import path from 'node:path';
3
4
 
4
5
  import { markdownToMdx } from '../convert.js';
5
- import type { SdkNavGroup, SdkPage, SdkReference } from '../types.js';
6
+ import type { SdkNavGroup, SdkPage, SdkPageTarget, SdkReference } from '../types.js';
6
7
 
7
8
  const KIND = {
8
9
  project: 1,
@@ -69,13 +70,37 @@ type TypedocNode = {
69
70
  inheritedFrom?: { name: string };
70
71
  };
71
72
 
72
- const SECTIONS: { kind: number; group: string; dir: string; tag: string }[] = [
73
- { kind: KIND.class, group: 'Classes', dir: 'classes', tag: 'CLASS' },
74
- { kind: KIND.interface, group: 'Interfaces', dir: 'interfaces', tag: 'INTERFACE' },
75
- { kind: KIND.enum, group: 'Enumerations', dir: 'enums', tag: 'ENUM' },
76
- { kind: KIND.function, group: 'Functions', dir: 'functions', tag: 'FUNCTION' },
77
- { kind: KIND.typeAlias, group: 'Type Aliases', dir: 'types', tag: 'TYPE' },
78
- { kind: KIND.variable, group: 'Variables', dir: 'variables', tag: 'VARIABLE' },
73
+ const SECTIONS: {
74
+ kind: number;
75
+ group: string;
76
+ dir: string;
77
+ tag: string;
78
+ symbolKind: SdkSymbolKind;
79
+ }[] = [
80
+ { kind: KIND.class, group: 'Classes', dir: 'classes', tag: 'CLASS', symbolKind: 'class' },
81
+ {
82
+ kind: KIND.interface,
83
+ group: 'Interfaces',
84
+ dir: 'interfaces',
85
+ tag: 'INTERFACE',
86
+ symbolKind: 'interface',
87
+ },
88
+ { kind: KIND.enum, group: 'Enumerations', dir: 'enums', tag: 'ENUM', symbolKind: 'enum' },
89
+ {
90
+ kind: KIND.function,
91
+ group: 'Functions',
92
+ dir: 'functions',
93
+ tag: 'FUNCTION',
94
+ symbolKind: 'function',
95
+ },
96
+ { kind: KIND.typeAlias, group: 'Type Aliases', dir: 'types', tag: 'TYPE', symbolKind: 'type' },
97
+ {
98
+ kind: KIND.variable,
99
+ group: 'Variables',
100
+ dir: 'variables',
101
+ tag: 'VARIABLE',
102
+ symbolKind: 'variable',
103
+ },
79
104
  ];
80
105
 
81
106
  export async function convertTypedoc(sourcePath: string): Promise<SdkReference> {
@@ -115,6 +140,18 @@ export async function convertTypedoc(sourcePath: string): Promise<SdkReference>
115
140
  renderer.renderPage(entry.node, section, qualifiedName(entry))
116
141
  );
117
142
  pages.push(...sectionPages);
143
+ for (const entry of entries) {
144
+ if (entry.node.kind !== KIND.class && entry.node.kind !== KIND.interface) continue;
145
+ const parentSlug =
146
+ slugById.get(entry.node.id) ??
147
+ path.posix.join(
148
+ multiModule ? slugify(module.name) : '',
149
+ ...entry.namespacePath.map(slugify),
150
+ section.dir,
151
+ slugify(entry.node.name)
152
+ );
153
+ pages.push(...renderer.renderMemberPages(entry.node, parentSlug, qualifiedName(entry)));
154
+ }
118
155
  groups.push({ group: `${prefix}${section.group}`, pages: sectionPages.map((p) => p.slug) });
119
156
  }
120
157
  }
@@ -147,7 +184,11 @@ function slugify(name: string): string {
147
184
  class TypedocRenderer {
148
185
  constructor(private slugById: Map<number, string>) {}
149
186
 
150
- renderPage(node: TypedocNode, section: { dir: string; tag: string }, title?: string): SdkPage {
187
+ renderPage(
188
+ node: TypedocNode,
189
+ section: { dir: string; tag: string; symbolKind: SdkSymbolKind },
190
+ title?: string
191
+ ): SdkPage {
151
192
  const slug = this.slugById.get(node.id) ?? path.posix.join(section.dir, slugify(node.name));
152
193
  const lines: string[] = [];
153
194
  const summary = this.comment(node.comment);
@@ -174,15 +215,55 @@ class TypedocRenderer {
174
215
  break;
175
216
  }
176
217
 
218
+ const target: SdkPageTarget = {
219
+ kind: section.symbolKind,
220
+ name: node.name,
221
+ };
222
+
177
223
  return {
178
224
  slug,
179
225
  title: title ?? node.name,
180
226
  description: this.firstSentence(node.comment),
181
227
  tag: section.tag,
182
228
  content: lines.filter(Boolean).join('\n\n'),
229
+ target,
183
230
  };
184
231
  }
185
232
 
233
+ renderMemberPages(parent: TypedocNode, parentSlug: string, parentTitle: string): SdkPage[] {
234
+ const members = (parent.children ?? []).filter((child) => !child.flags?.isPrivate);
235
+ const pages: SdkPage[] = [];
236
+
237
+ for (const property of members.filter(
238
+ (child) => child.kind === KIND.property || child.kind === KIND.accessor
239
+ )) {
240
+ const type = property.kind === KIND.accessor ? property.getSignature?.type : property.type;
241
+ const optional = property.flags?.isOptional === true;
242
+ const summary = this.comment(property.comment ?? property.getSignature?.comment);
243
+ pages.push({
244
+ slug: path.posix.join(parentSlug, slugify(property.name)),
245
+ title: `${parentTitle}.${property.name}`,
246
+ description: this.firstSentence(property.comment ?? property.getSignature?.comment),
247
+ tag: 'PROPERTY',
248
+ content: this.responseField(property.name, this.type(type), optional, summary),
249
+ target: { kind: 'property', name: property.name, parent: parent.name },
250
+ });
251
+ }
252
+
253
+ for (const method of members.filter((child) => child.kind === KIND.method)) {
254
+ pages.push({
255
+ slug: path.posix.join(parentSlug, slugify(method.name)),
256
+ title: `${parentTitle}.${method.name}`,
257
+ description: this.firstSentence(method.comment ?? method.signatures?.[0]?.comment),
258
+ tag: 'METHOD',
259
+ content: this.renderSignatures(method, 2).filter(Boolean).join('\n\n'),
260
+ target: { kind: 'method', name: method.name, parent: parent.name },
261
+ });
262
+ }
263
+
264
+ return pages;
265
+ }
266
+
186
267
  private renderClassLike(node: TypedocNode): string[] {
187
268
  const lines: string[] = [];
188
269
  const heritage = [
@@ -0,0 +1,69 @@
1
+ import type { ResolvedSdkTarget, SdkSymbolKind } from '@mintlify/models';
2
+
3
+ import type { SdkPage, SdkPageTarget, SdkReference } from './types.js';
4
+
5
+ const KIND_DIRS: Record<SdkSymbolKind, string> = {
6
+ class: 'classes',
7
+ interface: 'interfaces',
8
+ enum: 'enums',
9
+ function: 'functions',
10
+ type: 'types',
11
+ variable: 'variables',
12
+ method: 'methods',
13
+ property: 'properties',
14
+ };
15
+
16
+ export function matchesSdkPageTarget(
17
+ pageTarget: SdkPageTarget | undefined,
18
+ target: Pick<ResolvedSdkTarget, 'kind' | 'name' | 'parent'>
19
+ ): boolean {
20
+ if (!pageTarget) return false;
21
+ if (pageTarget.kind !== target.kind || pageTarget.name !== target.name) return false;
22
+ if (target.parent) return pageTarget.parent === target.parent;
23
+ return pageTarget.parent === undefined;
24
+ }
25
+
26
+ function matchesSdkPageHeuristic(
27
+ page: SdkPage,
28
+ target: Pick<ResolvedSdkTarget, 'kind' | 'name' | 'parent'>
29
+ ): boolean {
30
+ if (target.parent) {
31
+ return (
32
+ page.title === `${target.parent}.${target.name}` ||
33
+ page.slug.endsWith(`/${slugify(target.parent)}/${slugify(target.name)}`)
34
+ );
35
+ }
36
+ // Only slug matches encode the symbol kind; a bare title match could return
37
+ // a same-named symbol of a different kind.
38
+ const dir = KIND_DIRS[target.kind];
39
+ return (
40
+ page.slug === `${dir}/${slugify(target.name)}` ||
41
+ page.slug.endsWith(`/${dir}/${slugify(target.name)}`)
42
+ );
43
+ }
44
+
45
+ function slugify(name: string): string {
46
+ return name.replace(/[^a-zA-Z0-9-_.]+/g, '-').replace(/^-+|-+$/g, '') || 'item';
47
+ }
48
+
49
+ export function findSdkPage(
50
+ reference: SdkReference,
51
+ target: Pick<ResolvedSdkTarget, 'kind' | 'name' | 'parent'>
52
+ ): SdkPage | undefined {
53
+ return (
54
+ reference.pages.find((page) => matchesSdkPageTarget(page.target, target)) ??
55
+ reference.pages.find((page) => matchesSdkPageHeuristic(page, target))
56
+ );
57
+ }
58
+
59
+ export function renderSdkTarget(
60
+ reference: SdkReference,
61
+ target: Pick<ResolvedSdkTarget, 'kind' | 'name' | 'parent'>
62
+ ): SdkPage {
63
+ const page = findSdkPage(reference, target);
64
+ if (!page) {
65
+ const qualified = target.parent ? `${target.parent}.${target.name}` : target.name;
66
+ throw new Error(`SDK symbol not found: ${target.kind} ${qualified}`);
67
+ }
68
+ return page;
69
+ }
package/src/sdk/types.ts CHANGED
@@ -1,7 +1,14 @@
1
+ import type { SdkSymbolKind } from '@mintlify/models';
1
2
  import type { SdkFormat } from '@mintlify/validation';
2
3
 
3
4
  export type { SdkFormat };
4
5
 
6
+ export type SdkPageTarget = {
7
+ kind: SdkSymbolKind;
8
+ name: string;
9
+ parent?: string;
10
+ };
11
+
5
12
  export type SdkPage = {
6
13
  slug: string;
7
14
  title: string;
@@ -9,6 +16,7 @@ export type SdkPage = {
9
16
  tag?: string;
10
17
  icon?: string;
11
18
  content: string;
19
+ target?: SdkPageTarget;
12
20
  };
13
21
 
14
22
  export type SdkNavGroup = {