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

api_refs[major]: Remove script, use custom typedoc plugin #3630

Merged
merged 11 commits into from
Dec 12, 2023
Merged
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
3 changes: 2 additions & 1 deletion docs/api_refs/package.json
Original file line number Diff line number Diff line change
@@ -5,8 +5,9 @@
"scripts": {
"dev": "next dev -p 3001",
"typedoc": "npx typedoc --options typedoc.json",
"build:scripts": "node ./scripts/generate-api-refs.js && node ./scripts/update-typedoc-css.js",
"build:scripts": "yarn typedoc && node ./scripts/update-typedoc-css.js",
"build": "yarn run build:deps && yarn build:scripts && next build",
"build:vercel": "yarn run build:deps --force && yarn build:scripts && next build",
"build:deps": "yarn run turbo:command build --filter=@langchain/core --filter=@langchain/anthropic --filter=@langchain/openai --filter=@langchain/community --filter=langchain --concurrency=1",
"start": "yarn build && next start -p 3001",
"lint": "next lint"
104 changes: 0 additions & 104 deletions docs/api_refs/scripts/generate-api-refs.js

This file was deleted.

565 changes: 284 additions & 281 deletions docs/api_refs/typedoc.json

Large diffs are not rendered by default.

70 changes: 70 additions & 0 deletions docs/api_refs/typedoc_plugins/hide_underscore_lc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const {
Application,
Converter,
Context,
ReflectionKind,
DeclarationReflection,
} = require("typedoc");

/**
* @param {Application} application
* @returns {void}
*/
function load(application) {
/**
* @type {Array<DeclarationReflection>}
*/
let reflectionsToHide = [];

application.converter.on(
Converter.EVENT_CREATE_DECLARATION,
resolveReflection
);
application.converter.on(Converter.EVENT_RESOLVE_BEGIN, onBeginResolve);

const reflectionKindsToHide = [
ReflectionKind.Property,
ReflectionKind.Accessor,
ReflectionKind.Variable,
ReflectionKind.Method,
ReflectionKind.Function,
ReflectionKind.Class,
ReflectionKind.Interface,
ReflectionKind.Enum,
ReflectionKind.TypeAlias,
];

/**
* @param {Context} context
* @returns {void}
*/
function onBeginResolve(context) {
reflectionsToHide.forEach((reflection) => {
const { project } = context;
// Remove the property from documentation
project.removeReflection(reflection);
});
}

/**
* @param {Context} _context
* @param {DeclarationReflection} reflection
* @returns {void}
*/
function resolveReflection(
_context,
reflection
) {
const reflectionKind = reflection.kind;
if (reflectionKindsToHide.includes(reflectionKind)) {
if (
reflection.name.startsWith("_") ||
reflection.name.startsWith("lc_")
) {
reflectionsToHide.push(reflection);
}
}
}
}

module.exports = { load };
2 changes: 2 additions & 0 deletions docs/core_docs/package.json
Original file line number Diff line number Diff line change
@@ -6,7 +6,9 @@
"docusaurus": "docusaurus",
"start": "yarn build:typedoc && rimraf ./docs/api && NODE_OPTIONS=--max-old-space-size=7168 docusaurus start",
"build": "yarn build:typedoc && rimraf ./build && NODE_OPTIONS=--max-old-space-size=7168 DOCUSAURUS_SSR_CONCURRENCY=4 docusaurus build",
"build:vercel": "yarn build:typedoc:vercel && rimraf ./build && NODE_OPTIONS=--max-old-space-size=7168 DOCUSAURUS_SSR_CONCURRENCY=4 docusaurus build",
"build:typedoc": "yarn run turbo:command build --filter=api_refs",
"build:typedoc:vercel": "yarn run turbo:command build:vercel --filter=api_refs",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
2 changes: 1 addition & 1 deletion langchain/scripts/create-entrypoints.js
Original file line number Diff line number Diff line change
@@ -578,7 +578,7 @@ const updateConfig = () => {
...json,
entryPoints: [...Object.keys(entrypoints)]
.filter((key) => !deprecatedNodeOnly.includes(key))
.map((key) => `./langchain/src/${entrypoints[key]}.ts`),
.map((key) => `../../langchain/src/${entrypoints[key]}.ts`),
}));

const generatedFiles = generateFiles();
9 changes: 8 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
@@ -22,7 +22,11 @@
"inputs": ["src/**", "scripts/**", "package.json", "tsconfig.json"]
},
"build": {
"dependsOn": ["@langchain/core#build", "@langchain/community#build", "^build"],
"dependsOn": [
"@langchain/core#build",
"@langchain/community#build",
"^build"
],
"outputs": ["dist/**", "dist-cjs/**", "*.js", "*.cjs", "*.d.ts"],
"inputs": ["src/**", "scripts/**", "package.json", "tsconfig.json"]
},
@@ -46,6 +50,9 @@
"precommit": {},
"start": {
"cache": false
},
"build:vercel": {
"dependsOn": ["^build:vercel"]
}
}
}