|
| 1 | +diff --git a/dist/lib/converter/converter.js b/dist/lib/converter/converter.js |
| 2 | +index 2438a37c1ce94b8b2b2537965c374a6471a7e729..3855e44031a41c27b52ed00566dc735605fc5a60 100644 |
| 3 | +--- a/dist/lib/converter/converter.js |
| 4 | ++++ b/dist/lib/converter/converter.js |
| 5 | +@@ -442,7 +442,8 @@ let Converter = (() => { |
| 6 | + // Clone context in case deferred conversion uses different programs |
| 7 | + const entryContext = context.withScope(context.scope); |
| 8 | + entryContext.setActiveProgram(entry.program); |
| 9 | +- this.convertExports(entryContext, entry, createModuleReflections); |
| 10 | ++ // Hack 3, make sure that we flatten `index` into the root module |
| 11 | ++ this.convertExports(entryContext, entry, entry.displayName === "index" ? false : createModuleReflections); |
| 12 | + } |
| 13 | + this.finalizeDeferredConversion(); |
| 14 | + } |
| 15 | +diff --git a/dist/lib/converter/plugins/GroupPlugin.js b/dist/lib/converter/plugins/GroupPlugin.js |
| 16 | +index 1f5ab57d619ff2a20f4b59e26d8d234f6553d9af..e879fe67665906ff2b7c901737bc4da9b3076b62 100644 |
| 17 | +--- a/dist/lib/converter/plugins/GroupPlugin.js |
| 18 | ++++ b/dist/lib/converter/plugins/GroupPlugin.js |
| 19 | +@@ -193,6 +193,10 @@ let GroupPlugin = (() => { |
| 20 | + groups.add(String(reflection.frontmatter["group"])); |
| 21 | + } |
| 22 | + groups.delete(""); |
| 23 | ++ // Hack: we want to group deprecated items in a separate group |
| 24 | ++ if (reflection.isDeprecated()) { |
| 25 | ++ groups.add("Deprecated"); |
| 26 | ++ } |
| 27 | + if (groups.size === 0) { |
| 28 | + if (reflection instanceof ReferenceReflection && |
| 29 | + groupReferencesByType) { |
| 30 | +diff --git a/dist/lib/output/router.js b/dist/lib/output/router.js |
| 31 | +index 2dadd8df70cefca52fb2d1cc104c8bf5783d1195..50c5f263740b52639681baa16abce8ccec629c6b 100644 |
| 32 | +--- a/dist/lib/output/router.js |
| 33 | ++++ b/dist/lib/output/router.js |
| 34 | +@@ -359,6 +359,8 @@ export class KindRouter extends BaseRouter { |
| 35 | + reflection = reflection.parent; |
| 36 | + parts.unshift(createNormalizedUrl(reflection.name)); |
| 37 | + } |
| 38 | ++ const prefix = createNormalizedUrl("@langchain/"); |
| 39 | ++ if (parts[0].startsWith(prefix)) parts[0] = parts[0].slice(prefix.length); |
| 40 | + const baseName = parts.join("."); |
| 41 | + return `${dir}/${baseName}`; |
| 42 | + } |
| 43 | +@@ -396,6 +398,8 @@ export class StructureRouter extends BaseRouter { |
| 44 | + reflection = reflection.parent; |
| 45 | + parts.unshift(...reflection.name.split("/").map(createNormalizedUrl)); |
| 46 | + } |
| 47 | ++ // Hack: Make sure that we're not creating a dummy _langchain folder |
| 48 | ++ if (parts[0] === createNormalizedUrl("@langchain")) parts.shift() |
| 49 | + // This should only happen if someone tries to break things with @module |
| 50 | + // I don't think it will ever occur in normal usage. |
| 51 | + if (parts.includes("..")) { |
| 52 | +diff --git a/dist/lib/output/themes/default/DefaultTheme.js b/dist/lib/output/themes/default/DefaultTheme.js |
| 53 | +index b6c97e6cd7c832256ed861f2da1c414c1485f8a8..7202ab3f44ca5db6353cbae64e3a4f2a1bd6923a 100644 |
| 54 | +--- a/dist/lib/output/themes/default/DefaultTheme.js |
| 55 | ++++ b/dist/lib/output/themes/default/DefaultTheme.js |
| 56 | +@@ -234,7 +234,11 @@ let DefaultTheme = (() => { |
| 57 | + return filterMapWithNoneCollection(parent.categories); |
| 58 | + } |
| 59 | + if (parent.groups && shouldShowGroups(parent, opts)) { |
| 60 | +- return filterMapWithNoneCollection(parent.groups); |
| 61 | ++ // Hack: We want to group only certain groups, not all |
| 62 | ++ const includeGroups = ["Interfaces", "Type Aliases", "Deprecated", "Errors", "Graphs", "Functional API", "Pregel", "Constants", "Storage"]; |
| 63 | ++ const grouped = parent.groups.filter(g => includeGroups.includes(g.title)) |
| 64 | ++ const notGrouped = parent.groups.filter(g => !includeGroups.includes(g.title)) |
| 65 | ++ return [...filterMap(notGrouped.flatMap(g => g.children), toNavigation), ...filterMapWithNoneCollection(grouped)]; |
| 66 | + } |
| 67 | + if (opts.includeFolders && parent.childrenIncludingDocuments?.some((child) => child.name.includes("/"))) { |
| 68 | + return deriveModuleFolders(parent.childrenIncludingDocuments); |
| 69 | +diff --git a/dist/lib/utils/entry-point.js b/dist/lib/utils/entry-point.js |
| 70 | +index 0ba34b1f0d960ae1aef109c7b5bd7e2522fce418..c4d324bda6abc540f0a78647bc50f66ed2dae0a0 100644 |
| 71 | +--- a/dist/lib/utils/entry-point.js |
| 72 | ++++ b/dist/lib/utils/entry-point.js |
| 73 | +@@ -6,6 +6,7 @@ import { deriveRootDir, getCommonDirectory, MinimatchSet, nicePath, normalizePat |
| 74 | + import { discoverPackageJson, glob, inferPackageEntryPointPaths, isDir } from "./fs.js"; |
| 75 | + import { assertNever, i18n } from "#utils"; |
| 76 | + import { addInferredDeclarationMapPaths, resolveDeclarationMaps } from "./declaration-maps.js"; |
| 77 | ++import { createRequire } from "node:module"; |
| 78 | + /** |
| 79 | + * Defines how entry points are interpreted. |
| 80 | + * @enum |
| 81 | +@@ -37,8 +38,25 @@ export function inferEntryPoints(logger, options, programs) { |
| 82 | + logger.warn(i18n.no_entry_points_provided()); |
| 83 | + return []; |
| 84 | + } |
| 85 | +- const pathEntries = inferPackageEntryPointPaths(packageJson.file); |
| 86 | ++ let pathEntries = inferPackageEntryPointPaths(packageJson.file); |
| 87 | + const entryPoints = []; |
| 88 | ++ // Hack 1: see if we can rewrite to source files |
| 89 | ++ try { |
| 90 | ++ const lcRootDir = getCommonDirectory(pathEntries.map((p) => p[1])); |
| 91 | ++ const lcConfig = createRequire(import.meta.url)(join(lcRootDir, "langchain.config.js")); |
| 92 | ++ |
| 93 | ++ pathEntries = pathEntries.map(([origName, origPath]) => { |
| 94 | ++ let lcName = origName; |
| 95 | ++ if (lcName.startsWith("./")) lcName = lcName.slice(2); |
| 96 | ++ if (lcName.startsWith(".")) lcName = "index"; |
| 97 | ++ |
| 98 | ++ const lcEntryPoint = lcConfig.config.entrypoints[lcName]; |
| 99 | ++ if (lcEntryPoint) return [origName, resolve(lcRootDir, "src", lcEntryPoint + ".ts")]; |
| 100 | ++ return [origName, origPath]; |
| 101 | ++ }); |
| 102 | ++ } catch { |
| 103 | ++ // pass |
| 104 | ++ } |
| 105 | + programs ||= getEntryPrograms(pathEntries.map((p) => p[1]), logger, options); |
| 106 | + // See also: addInferredDeclarationMapPaths in symbol-id factory |
| 107 | + const jsToTsSource = new Map(); |
| 108 | +@@ -53,7 +71,10 @@ export function inferEntryPoints(logger, options, programs) { |
| 109 | + } |
| 110 | + for (const [name, path] of pathEntries) { |
| 111 | + // Strip leading ./ from the display name |
| 112 | +- const displayName = name.replace(/^\.\/?/, ""); |
| 113 | ++ let displayName = name.replace(/^\.\/?/, ""); |
| 114 | ++ // Hack 2: make sure we resolve displayName to "." for "index" |
| 115 | ++ // That will allow us to collapse the URL |
| 116 | ++ displayName ||= "index" |
| 117 | + const targetPath = jsToTsSource.get(path) || resolveDeclarationMaps(path) || path; |
| 118 | + const program = programs.find((p) => p.getSourceFile(targetPath)); |
| 119 | + if (program) { |
0 commit comments