@mintlify/scraping 4.0.1210 → 4.0.1212

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.1210",
3
+ "version": "4.0.1212",
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.1332",
46
+ "@mintlify/common": "1.0.1333",
47
47
  "fast-xml-parser": "5.7.3",
48
48
  "fs-extra": "11.1.1",
49
49
  "graphql": "16.11.0",
@@ -87,5 +87,5 @@
87
87
  "optional": true
88
88
  }
89
89
  },
90
- "gitHead": "2e18df750c2324fbc1990296abfcf95e1027f114"
90
+ "gitHead": "0548f1389b0d4f0894e917a8bd2eed682a8a26b0"
91
91
  }
@@ -18,6 +18,7 @@ export function buildSphinxNavigation(docs: SphinxNavigationDoc[]): SdkNavGroup[
18
18
  const children = new Map<string, string[]>();
19
19
  const parents = new Map<string, string[]>();
20
20
  const guideContent = new Set<string>();
21
+ const generated = new Set<string>();
21
22
 
22
23
  function addChild(parent: string, child: string): void {
23
24
  if (parent === child) return;
@@ -31,7 +32,8 @@ export function buildSphinxNavigation(docs: SphinxNavigationDoc[]): SdkNavGroup[
31
32
 
32
33
  for (const doc of docs) {
33
34
  const body = htmlToHast(doc.body);
34
- if (hasGuideContent(body)) guideContent.add(doc.slug);
35
+ if (isGeneratedReference(body)) generated.add(doc.slug);
36
+ else if (hasGuideContent(body)) guideContent.add(doc.slug);
35
37
  const wrappers = toctreeWrappers(body);
36
38
  const sources: (Root | Element)[] = wrappers;
37
39
  if (!sources.length && doc.toc) sources.push(htmlToHast(doc.toc));
@@ -87,7 +89,9 @@ export function buildSphinxNavigation(docs: SphinxNavigationDoc[]): SdkNavGroup[
87
89
  if (ancestor) addChild(ancestor, doc.slug);
88
90
  }
89
91
 
90
- const reference = new Set(docs.filter((doc) => doc.tag).map((doc) => doc.slug));
92
+ const reference = new Set(
93
+ docs.filter((doc) => doc.tag || generated.has(doc.slug)).map((doc) => doc.slug)
94
+ );
91
95
  let changed = true;
92
96
  while (changed) {
93
97
  changed = false;
@@ -143,13 +147,21 @@ export function buildSphinxNavigation(docs: SphinxNavigationDoc[]): SdkNavGroup[
143
147
  );
144
148
  for (const doc of [...roots, ...categoryDocs])
145
149
  pages.push(...entries(doc.slug, category, emitted));
146
- if (pages.length) {
147
- groups.push({ group: category ? 'API Reference' : 'Getting Started', pages });
148
- }
150
+ const group = category ? 'API Reference' : 'Getting Started';
151
+ const flattened = flattenGroup(pages, group);
152
+ if (flattened.length) groups.push({ group, pages: flattened });
149
153
  }
150
154
  return groups;
151
155
  }
152
156
 
157
+ function flattenGroup(pages: (string | SdkNavGroup)[], title: string): (string | SdkNavGroup)[] {
158
+ return pages.flatMap((page) => {
159
+ if (typeof page === 'string') return [page];
160
+ const nested = flattenGroup(page.pages, title);
161
+ return page.group === title ? nested : [{ ...page, pages: nested }];
162
+ });
163
+ }
164
+
153
165
  function ancestorPrefixes(slug: string): string[] {
154
166
  return [...slug.matchAll(/[/.]/g)].map((match) => slug.slice(0, match.index));
155
167
  }
@@ -212,6 +224,17 @@ function resolvePageHref(
212
224
  return;
213
225
  }
214
226
 
227
+ function isGeneratedReference(node: Root | Element): boolean {
228
+ if (node.type === 'element') {
229
+ const { id, href } = node.properties;
230
+ if (typeof id === 'string' && id.startsWith('module-')) return true;
231
+ if (typeof href === 'string' && /github\.com\/readthedocs\/sphinx-autoapi/.test(href)) {
232
+ return true;
233
+ }
234
+ }
235
+ return node.children.some((child) => child.type === 'element' && isGeneratedReference(child));
236
+ }
237
+
215
238
  function hasGuideContent(node: Root | Element): boolean {
216
239
  if (node.type === 'element') {
217
240
  if (classes(node).includes('toctree-wrapper')) return false;