@openpkg-ts/sdk 0.48.1 → 0.50.0
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/dist/browser.d.ts +2 -1
- package/dist/index.d.ts +20 -3
- package/dist/index.js +147 -42
- package/package.json +2 -2
package/dist/browser.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ interface HTMLOptions {
|
|
|
60
60
|
/** Exports to render (multi-mode) - overridden by `export` if both provided */
|
|
61
61
|
exports?: string[];
|
|
62
62
|
}
|
|
63
|
-
import { SpecExportKind } from "@openpkg-ts/spec";
|
|
63
|
+
import { SpecExportKind, SpecInlineTag } from "@openpkg-ts/spec";
|
|
64
64
|
interface JSONOptions {
|
|
65
65
|
/** Include raw spec data alongside simplified data */
|
|
66
66
|
includeRaw?: boolean;
|
|
@@ -115,6 +115,7 @@ interface SimplifiedExport {
|
|
|
115
115
|
tags: Array<{
|
|
116
116
|
name: string;
|
|
117
117
|
text: string;
|
|
118
|
+
inlineTags?: SpecInlineTag[];
|
|
118
119
|
}>;
|
|
119
120
|
parameters?: SimplifiedParameter[];
|
|
120
121
|
returns?: SimplifiedReturn;
|
package/dist/index.d.ts
CHANGED
|
@@ -276,7 +276,7 @@ interface HTMLOptions {
|
|
|
276
276
|
* ```
|
|
277
277
|
*/
|
|
278
278
|
declare function toHTML2(spec: OpenPkg3, options?: HTMLOptions): string;
|
|
279
|
-
import { OpenPkg as OpenPkg4, SpecExportKind } from "@openpkg-ts/spec";
|
|
279
|
+
import { OpenPkg as OpenPkg4, SpecExportKind, SpecInlineTag } from "@openpkg-ts/spec";
|
|
280
280
|
interface JSONOptions {
|
|
281
281
|
/** Include raw spec data alongside simplified data */
|
|
282
282
|
includeRaw?: boolean;
|
|
@@ -331,6 +331,7 @@ interface SimplifiedExport {
|
|
|
331
331
|
tags: Array<{
|
|
332
332
|
name: string;
|
|
333
333
|
text: string;
|
|
334
|
+
inlineTags?: SpecInlineTag[];
|
|
334
335
|
}>;
|
|
335
336
|
parameters?: SimplifiedParameter[];
|
|
336
337
|
returns?: SimplifiedReturn;
|
|
@@ -1271,12 +1272,13 @@ declare function resolveExportTarget(symbol: ts3.Symbol, checker: ts3.TypeChecke
|
|
|
1271
1272
|
targetSymbol: ts3.Symbol;
|
|
1272
1273
|
isTypeOnly: boolean;
|
|
1273
1274
|
};
|
|
1274
|
-
import { SpecExample, SpecExportKind as SpecExportKind8, SpecSource, SpecTag, SpecTypeParameter as SpecTypeParameter2 } from "@openpkg-ts/spec";
|
|
1275
|
+
import { SpecExample, SpecExportKind as SpecExportKind8, SpecInlineTag as SpecInlineTag2, SpecSource, SpecTag, SpecTypeParameter as SpecTypeParameter2 } from "@openpkg-ts/spec";
|
|
1275
1276
|
import ts4 from "typescript";
|
|
1276
1277
|
declare function getJSDocComment(node: ts4.Node, symbol?: ts4.Symbol, checker?: ts4.TypeChecker): {
|
|
1277
1278
|
description?: string;
|
|
1278
1279
|
tags: SpecTag[];
|
|
1279
1280
|
examples: SpecExample[];
|
|
1281
|
+
inlineTags?: SpecInlineTag2[];
|
|
1280
1282
|
};
|
|
1281
1283
|
declare function getSourceLocation(node: ts4.Node, sourceFile: ts4.SourceFile): SpecSource;
|
|
1282
1284
|
/**
|
|
@@ -1839,6 +1841,21 @@ declare function scrubImportQualifiers(text: string): string;
|
|
|
1839
1841
|
*/
|
|
1840
1842
|
declare function renderTypeText(type: ts15.Type, checker: ts15.TypeChecker, enclosing?: ts15.Node, extraFlags?: ts15.TypeFormatFlags): string;
|
|
1841
1843
|
/**
|
|
1844
|
+
* The type exactly as the author WROTE it — the annotation node's source text.
|
|
1845
|
+
* `x-ts-type` carries the resolved truth (`Omit<T, K>` expanded to its mapped
|
|
1846
|
+
* type, `InitiatorType` expanded to its union); this recovers the declared form
|
|
1847
|
+
* a docs reader recognizes.
|
|
1848
|
+
*
|
|
1849
|
+
* Restricted to NAMED references and unions — the shapes where the author wrote
|
|
1850
|
+
* a name that resolves to something else. Object literals, mapped, and
|
|
1851
|
+
* conditional bodies are excluded: they differ from their resolved text only by
|
|
1852
|
+
* formatting (a trailing `;`, `readonly T[]` vs `ReadonlyArray<T>`) or would
|
|
1853
|
+
* drag source comments into the spec, both of which are noise, not signal.
|
|
1854
|
+
*/
|
|
1855
|
+
declare function writtenTypeText(typeNode: ts15.TypeNode | undefined): string | undefined;
|
|
1856
|
+
/** The annotation TypeNode on a declaration (property, alias, parameter), if any. */
|
|
1857
|
+
declare function declaredTypeNode(decl: ts15.Declaration | undefined): ts15.TypeNode | undefined;
|
|
1858
|
+
/**
|
|
1842
1859
|
* Strip `undefined` from a union type when optionality is already expressed
|
|
1843
1860
|
* elsewhere (`required: false`, `flags.optional`). Used for both schema shape
|
|
1844
1861
|
* and x-ts-type text so neither re-encodes optionality as `| undefined`.
|
|
@@ -1948,4 +1965,4 @@ declare function findDiscriminatorProperty(unionTypes: ts15.Type[], checker: ts1
|
|
|
1948
1965
|
import ts16 from "typescript";
|
|
1949
1966
|
declare function isExported(node: ts16.Node): boolean;
|
|
1950
1967
|
declare function getNodeName(node: ts16.Node): string | undefined;
|
|
1951
|
-
export { zodAdapter, withDescription2 as withDescription, withDeprecated, validateSpec, valibotAdapter, typeboxAdapter, toToolSchema, toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toNavigation2 as toNavigation, toMarkdown2 as toMarkdown, toJsonSchema, toJSONString, toJSON2 as toJSON, toHTML2 as toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords2 as toAlgoliaRecords, stripUndefinedFromType, stripTsExtensions, sortByName, shouldEmitAliasTypeText, serializeVariable, serializeTypeAlias, serializeInterface, serializeFunctionExport, serializeEnum, serializeClass, scrubImportQualifiers, schemasAreEqual, schemaIsAny, resolveTypeRef, resolveExportTarget, resolveCompiledPath, renderTypeText, registerReferencedTypes, registerAdapter, recommendSemverBump, query, normalizeType, normalizeSchema, normalizeMembers, normalizeExport, mergeConfig, loadSpec, loadConfig, listExports, isTypeReference, isTypeOnlyExport, isSymbolDeprecated, isStandardJSONSchema, isSchemaType, isReadonlyPropertySymbol, isPureRefSchema, isProperty, isPrimitiveName, isMethod, isExported, isBuiltinSymbol, isBuiltinGeneric, isAnonymous, hasDeprecatedTag, groupByVisibility, getValidationErrors, getTypeOrigin, getSourceLocation, getProperties, getParamDescription, getNonNullableType, getNodeName, getMethods, getMemberBadges, getJSDocComment, getExportKind, getExport2 as getExport, getDeprecationMessage, getAvailableVersions, toMarkdown2 as generateDocs, formatTypeParameters, formatSchema, formatReturnType, formatParameters, formatMappedType, formatConditionalType, formatBadges, findMissingParamDocs, findDiscriminatorProperty, findAdapter, filterSpec, extractTypeParameters, extractStandardSchemasFromTs, extractStandardSchemasFromProject, extractStandardSchemas, extractSpec, extractSchemaType, extractParameters, extract, exportToMarkdown, exportToJsonSchema, ensureNonEmptySchema, diffSpec2 as diffSpecs, diffSpec, detectTsRuntime, deduplicateSchemas, decoratePropertySchema, createProgram, createDocs, categorizeBreakingChanges, calculateNextVersion, bundleRefs, buildSignatureString, buildSchema, buildObjectSchema, buildFunctionSchema, assertSpec, asStandardSchema, arktypeAdapter, analyzeSpec, TypeRegistry, TypeReference2 as TypeReference, TsRuntime, ToolSchemaResult, ToolSchemaProvider, ToToolSchemaOptions, ToJsonSchemaOptions, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, StandardJSONSchemaTarget, StandardJSONSchemaOptions, SpecMappedType, SpecError, SpecDiff, SpecDiagnostics, SpecConditionalType, SkippedExportDetail, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SerializerContext, SemverRecommendation, SemverBump, SearchRecord, SearchOptions, SearchIndex, SchemaVersion, SchemaExtractionResult, SchemaAdapter, STRING_PROTOTYPE_METHODS, QueryBuilder, ProjectExtractionOutput, ProjectExtractionInfo, ProgramResult, ProgramOptions, PagefindRecord, PRIMITIVES, OpenpkgConfig, NormalizeOptions, NavOptions, NavItem, NavGroup, NavFormat, NUMBER_PROTOTYPE_METHODS, MemberChangeInfo, MarkdownOptions, LoadOptions, ListExportsResult, ListExportsOptions, LATEST_VERSION, JsonSchemaDocument, JSONSchema, JSONOptions, HTMLOptions, GroupBy, GetExportResult, GetExportOptions, GenericNav, FumadocsMetaItem, FumadocsMeta, FormatSchemaOptions, ForgottenExport, FilterResult, FilterCriteria, ExtractionWarningCode, ExtractionWarning, ExtractStandardSchemasOptions, ExtractResult, ExtractOptions, ExtractFromProjectOptions, ExternalsConfig, ExportVerification, ExportTracker, ExportMarkdownOptions, ExportItem, DocusaurusSidebarItem, DocusaurusSidebar, DocsInstance, DiagnosticItem, Diagnostic, CategorizedBreaking, CacheManagerOptions, CacheManager, CONFIG_FILENAME, BundleResult, BundleOptions, BuiltinSchema, BreakingSeverity, BUILTIN_TYPE_SCHEMAS, AsStandardSchemaOptions, AlgoliaRecord, ARRAY_PROTOTYPE_METHODS };
|
|
1968
|
+
export { zodAdapter, writtenTypeText, withDescription2 as withDescription, withDeprecated, validateSpec, valibotAdapter, typeboxAdapter, toToolSchema, toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toNavigation2 as toNavigation, toMarkdown2 as toMarkdown, toJsonSchema, toJSONString, toJSON2 as toJSON, toHTML2 as toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords2 as toAlgoliaRecords, stripUndefinedFromType, stripTsExtensions, sortByName, shouldEmitAliasTypeText, serializeVariable, serializeTypeAlias, serializeInterface, serializeFunctionExport, serializeEnum, serializeClass, scrubImportQualifiers, schemasAreEqual, schemaIsAny, resolveTypeRef, resolveExportTarget, resolveCompiledPath, renderTypeText, registerReferencedTypes, registerAdapter, recommendSemverBump, query, normalizeType, normalizeSchema, normalizeMembers, normalizeExport, mergeConfig, loadSpec, loadConfig, listExports, isTypeReference, isTypeOnlyExport, isSymbolDeprecated, isStandardJSONSchema, isSchemaType, isReadonlyPropertySymbol, isPureRefSchema, isProperty, isPrimitiveName, isMethod, isExported, isBuiltinSymbol, isBuiltinGeneric, isAnonymous, hasDeprecatedTag, groupByVisibility, getValidationErrors, getTypeOrigin, getSourceLocation, getProperties, getParamDescription, getNonNullableType, getNodeName, getMethods, getMemberBadges, getJSDocComment, getExportKind, getExport2 as getExport, getDeprecationMessage, getAvailableVersions, toMarkdown2 as generateDocs, formatTypeParameters, formatSchema, formatReturnType, formatParameters, formatMappedType, formatConditionalType, formatBadges, findMissingParamDocs, findDiscriminatorProperty, findAdapter, filterSpec, extractTypeParameters, extractStandardSchemasFromTs, extractStandardSchemasFromProject, extractStandardSchemas, extractSpec, extractSchemaType, extractParameters, extract, exportToMarkdown, exportToJsonSchema, ensureNonEmptySchema, diffSpec2 as diffSpecs, diffSpec, detectTsRuntime, deduplicateSchemas, decoratePropertySchema, declaredTypeNode, createProgram, createDocs, categorizeBreakingChanges, calculateNextVersion, bundleRefs, buildSignatureString, buildSchema, buildObjectSchema, buildFunctionSchema, assertSpec, asStandardSchema, arktypeAdapter, analyzeSpec, TypeRegistry, TypeReference2 as TypeReference, TsRuntime, ToolSchemaResult, ToolSchemaProvider, ToToolSchemaOptions, ToJsonSchemaOptions, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, StandardJSONSchemaTarget, StandardJSONSchemaOptions, SpecMappedType, SpecError, SpecDiff, SpecDiagnostics, SpecConditionalType, SkippedExportDetail, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SerializerContext, SemverRecommendation, SemverBump, SearchRecord, SearchOptions, SearchIndex, SchemaVersion, SchemaExtractionResult, SchemaAdapter, STRING_PROTOTYPE_METHODS, QueryBuilder, ProjectExtractionOutput, ProjectExtractionInfo, ProgramResult, ProgramOptions, PagefindRecord, PRIMITIVES, OpenpkgConfig, NormalizeOptions, NavOptions, NavItem, NavGroup, NavFormat, NUMBER_PROTOTYPE_METHODS, MemberChangeInfo, MarkdownOptions, LoadOptions, ListExportsResult, ListExportsOptions, LATEST_VERSION, JsonSchemaDocument, JSONSchema, JSONOptions, HTMLOptions, GroupBy, GetExportResult, GetExportOptions, GenericNav, FumadocsMetaItem, FumadocsMeta, FormatSchemaOptions, ForgottenExport, FilterResult, FilterCriteria, ExtractionWarningCode, ExtractionWarning, ExtractStandardSchemasOptions, ExtractResult, ExtractOptions, ExtractFromProjectOptions, ExternalsConfig, ExportVerification, ExportTracker, ExportMarkdownOptions, ExportItem, DocusaurusSidebarItem, DocusaurusSidebar, DocsInstance, DiagnosticItem, Diagnostic, CategorizedBreaking, CacheManagerOptions, CacheManager, CONFIG_FILENAME, BundleResult, BundleOptions, BuiltinSchema, BreakingSeverity, BUILTIN_TYPE_SCHEMAS, AsStandardSchemaOptions, AlgoliaRecord, ARRAY_PROTOTYPE_METHODS };
|
package/dist/index.js
CHANGED
|
@@ -480,7 +480,11 @@ function simplifyExport(exp) {
|
|
|
480
480
|
signature: buildSignatureString(exp),
|
|
481
481
|
description: exp.description,
|
|
482
482
|
deprecated: exp.deprecated === true,
|
|
483
|
-
tags: (exp.tags || []).map((t) => ({
|
|
483
|
+
tags: (exp.tags || []).map((t) => ({
|
|
484
|
+
name: t.name,
|
|
485
|
+
text: t.text,
|
|
486
|
+
...t.inlineTags ? { inlineTags: t.inlineTags } : {}
|
|
487
|
+
})),
|
|
484
488
|
extends: exp.extends,
|
|
485
489
|
implements: exp.implements,
|
|
486
490
|
sourceFile: exp.source?.file,
|
|
@@ -1305,6 +1309,26 @@ import ts12 from "typescript";
|
|
|
1305
1309
|
// src/ast/utils.ts
|
|
1306
1310
|
import * as path2 from "node:path";
|
|
1307
1311
|
import ts from "typescript";
|
|
1312
|
+
var INLINE_TAG_RE = /(^|[^\\])\{@([a-zA-Z][a-zA-Z0-9]*)((?:[^}\\]|\\.)*)\}/g;
|
|
1313
|
+
function parseInlineTags(...texts) {
|
|
1314
|
+
const inlineTags = [];
|
|
1315
|
+
for (const text of texts) {
|
|
1316
|
+
if (!text || !text.includes("{@"))
|
|
1317
|
+
continue;
|
|
1318
|
+
INLINE_TAG_RE.lastIndex = 0;
|
|
1319
|
+
let match = INLINE_TAG_RE.exec(text);
|
|
1320
|
+
while (match) {
|
|
1321
|
+
inlineTags.push({ name: match[2], text: match[3].trim() });
|
|
1322
|
+
INLINE_TAG_RE.lastIndex -= 1;
|
|
1323
|
+
match = INLINE_TAG_RE.exec(text);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
return inlineTags.length > 0 ? inlineTags : undefined;
|
|
1327
|
+
}
|
|
1328
|
+
function withInlineTags(node, ...texts) {
|
|
1329
|
+
const inlineTags = parseInlineTags(...texts);
|
|
1330
|
+
return inlineTags ? { ...node, inlineTags } : node;
|
|
1331
|
+
}
|
|
1308
1332
|
function parseExamplesFromTags(tags) {
|
|
1309
1333
|
const examples = [];
|
|
1310
1334
|
for (const tag of tags) {
|
|
@@ -1319,9 +1343,9 @@ function parseExamplesFromTags(tags) {
|
|
|
1319
1343
|
if (lang && ["ts", "js", "tsx", "jsx", "shell", "json"].includes(lang)) {
|
|
1320
1344
|
example.language = lang;
|
|
1321
1345
|
}
|
|
1322
|
-
examples.push(example);
|
|
1346
|
+
examples.push(withInlineTags(example, example.code));
|
|
1323
1347
|
} else if (text) {
|
|
1324
|
-
examples.push({ code: text });
|
|
1348
|
+
examples.push(withInlineTags({ code: text }, text));
|
|
1325
1349
|
}
|
|
1326
1350
|
}
|
|
1327
1351
|
return examples;
|
|
@@ -1416,17 +1440,17 @@ function getJSDocComment(node, symbol, checker) {
|
|
|
1416
1440
|
param.description = description2;
|
|
1417
1441
|
if (paramTag.isBracketed)
|
|
1418
1442
|
param.optional = true;
|
|
1419
|
-
return { name: tag.tagName.text, text, param };
|
|
1443
|
+
return withInlineTags({ name: tag.tagName.text, text, param }, text);
|
|
1420
1444
|
}
|
|
1421
1445
|
if (tag.tagName.text === "typeParam") {
|
|
1422
1446
|
const text = stripTypeParamSeparator(rawText) ?? "";
|
|
1423
|
-
return { name: tag.tagName.text, text };
|
|
1447
|
+
return withInlineTags({ name: tag.tagName.text, text }, text);
|
|
1424
1448
|
}
|
|
1425
1449
|
if (tag.tagName.text === "see") {
|
|
1426
1450
|
const text = extractSeeTagText(tag);
|
|
1427
|
-
return { name: tag.tagName.text, text };
|
|
1451
|
+
return withInlineTags({ name: tag.tagName.text, text }, text);
|
|
1428
1452
|
}
|
|
1429
|
-
return { name: tag.tagName.text, text: rawText };
|
|
1453
|
+
return withInlineTags({ name: tag.tagName.text, text: rawText }, rawText);
|
|
1430
1454
|
});
|
|
1431
1455
|
const jsDocComments = ts.getJSDocCommentsAndTags(node).filter(ts.isJSDoc);
|
|
1432
1456
|
let description;
|
|
@@ -1444,7 +1468,7 @@ function getJSDocComment(node, symbol, checker) {
|
|
|
1444
1468
|
}
|
|
1445
1469
|
}
|
|
1446
1470
|
const examples = parseExamplesFromTags(tags);
|
|
1447
|
-
return { description, tags, examples };
|
|
1471
|
+
return { description, tags, examples, inlineTags: parseInlineTags(description) };
|
|
1448
1472
|
}
|
|
1449
1473
|
function getSourceLocation(node, sourceFile) {
|
|
1450
1474
|
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile));
|
|
@@ -1993,6 +2017,22 @@ function scrubImportQualifiers(text) {
|
|
|
1993
2017
|
function renderTypeText(type, checker, enclosing, extraFlags = 0) {
|
|
1994
2018
|
return scrubImportQualifiers(checker.typeToString(type, enclosing, ts4.TypeFormatFlags.NoTruncation | extraFlags));
|
|
1995
2019
|
}
|
|
2020
|
+
function writtenTypeText(typeNode) {
|
|
2021
|
+
if (!typeNode)
|
|
2022
|
+
return;
|
|
2023
|
+
if (!ts4.isTypeReferenceNode(typeNode) && !ts4.isUnionTypeNode(typeNode))
|
|
2024
|
+
return;
|
|
2025
|
+
try {
|
|
2026
|
+
const text = scrubImportQualifiers(typeNode.getText().replace(/\s+/g, " ").replace(/^\|\s*/, "").trim());
|
|
2027
|
+
return text.length > 0 ? text : undefined;
|
|
2028
|
+
} catch {
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
function declaredTypeNode(decl) {
|
|
2033
|
+
const withType = decl;
|
|
2034
|
+
return withType?.type;
|
|
2035
|
+
}
|
|
1996
2036
|
function stripUndefinedFromType(type, checker) {
|
|
1997
2037
|
if (!type.isUnion())
|
|
1998
2038
|
return type;
|
|
@@ -2020,6 +2060,10 @@ function decoratePropertySchema(schema, prop, propType, checker) {
|
|
|
2020
2060
|
let result = obj;
|
|
2021
2061
|
if (!derivable && !("x-ts-type" in obj)) {
|
|
2022
2062
|
result = { ...result, "x-ts-type": text };
|
|
2063
|
+
const declared = writtenTypeText(declaredTypeNode(decl));
|
|
2064
|
+
if (declared && declared !== text && !PRIMITIVES.has(declared) && !("x-ts-declared" in obj)) {
|
|
2065
|
+
result = { ...result, "x-ts-declared": declared };
|
|
2066
|
+
}
|
|
2023
2067
|
}
|
|
2024
2068
|
if (isReadonlyPropertySymbol(prop) && !("readOnly" in obj)) {
|
|
2025
2069
|
result = { ...result, readOnly: true };
|
|
@@ -2030,7 +2074,12 @@ function decoratePropertySchema(schema, prop, propType, checker) {
|
|
|
2030
2074
|
return result;
|
|
2031
2075
|
}
|
|
2032
2076
|
function shouldEmitAliasTypeText(typeNode) {
|
|
2033
|
-
|
|
2077
|
+
if (ts4.isMappedTypeNode(typeNode))
|
|
2078
|
+
return false;
|
|
2079
|
+
if (ts4.isTypeLiteralNode(typeNode)) {
|
|
2080
|
+
return typeNode.members.length > 0 && typeNode.members.every((m) => ts4.isIndexSignatureDeclaration(m));
|
|
2081
|
+
}
|
|
2082
|
+
return true;
|
|
2034
2083
|
}
|
|
2035
2084
|
var PRIMITIVES = new Set([
|
|
2036
2085
|
"string",
|
|
@@ -2889,6 +2938,9 @@ function extractParameters(signature, ctx) {
|
|
|
2889
2938
|
};
|
|
2890
2939
|
if (description) {
|
|
2891
2940
|
paramResult.description = description;
|
|
2941
|
+
const inlineTags = parseInlineTags(description);
|
|
2942
|
+
if (inlineTags)
|
|
2943
|
+
paramResult.inlineTags = inlineTags;
|
|
2892
2944
|
}
|
|
2893
2945
|
if (decl.initializer) {
|
|
2894
2946
|
applyDefault(paramResult, decl.initializer);
|
|
@@ -2923,6 +2975,9 @@ function expandBindingPattern(paramDecl, paramType, jsdocTags, ctx) {
|
|
|
2923
2975
|
};
|
|
2924
2976
|
if (description) {
|
|
2925
2977
|
param.description = description;
|
|
2978
|
+
const inlineTags = parseInlineTags(description);
|
|
2979
|
+
if (inlineTags)
|
|
2980
|
+
param.inlineTags = inlineTags;
|
|
2926
2981
|
}
|
|
2927
2982
|
if (element.initializer) {
|
|
2928
2983
|
applyDefault(param, element.initializer);
|
|
@@ -3232,6 +3287,10 @@ class TypeRegistry {
|
|
|
3232
3287
|
const text = renderTypeText(type, checker, decl, ts6.TypeFormatFlags.InTypeAlias);
|
|
3233
3288
|
if (!PRIMITIVES.has(text) && text !== name) {
|
|
3234
3289
|
schema["x-ts-type"] = text;
|
|
3290
|
+
const declared = writtenTypeText(declaredTypeNode(decl));
|
|
3291
|
+
if (declared && declared !== text && !PRIMITIVES.has(declared)) {
|
|
3292
|
+
schema["x-ts-declared"] = declared;
|
|
3293
|
+
}
|
|
3235
3294
|
}
|
|
3236
3295
|
}
|
|
3237
3296
|
let typeParameters;
|
|
@@ -3505,7 +3564,7 @@ function serializeInheritedMember(symbol, inheritedFrom, ctx, isStatic) {
|
|
|
3505
3564
|
}
|
|
3506
3565
|
if (visibility === "private")
|
|
3507
3566
|
return null;
|
|
3508
|
-
const { description, tags } = getJSDocComment(decl);
|
|
3567
|
+
const { description, tags, inlineTags } = getJSDocComment(decl);
|
|
3509
3568
|
let kind = "property";
|
|
3510
3569
|
const callSigs = type.getCallSignatures();
|
|
3511
3570
|
if (callSigs.length > 0) {
|
|
@@ -3538,6 +3597,7 @@ function serializeInheritedMember(symbol, inheritedFrom, ctx, isStatic) {
|
|
|
3538
3597
|
},
|
|
3539
3598
|
...sigDoc.description ? { description: sigDoc.description } : {},
|
|
3540
3599
|
...sigDoc.tags.length > 0 ? { tags: sigDoc.tags } : {},
|
|
3600
|
+
...sigDoc.inlineTags ? { inlineTags: sigDoc.inlineTags } : {},
|
|
3541
3601
|
...callSigs.length > 1 ? { overloadIndex: index } : {}
|
|
3542
3602
|
};
|
|
3543
3603
|
});
|
|
@@ -3551,16 +3611,17 @@ function serializeInheritedMember(symbol, inheritedFrom, ctx, isStatic) {
|
|
|
3551
3611
|
visibility,
|
|
3552
3612
|
schema: kind !== "method" ? buildSchema(type, checker, ctx) : decoratePropertySchema({ "x-ts-function": true }, symbol, type, checker),
|
|
3553
3613
|
signatures,
|
|
3554
|
-
flags: Object.keys(flags).length > 0 ? flags : undefined
|
|
3614
|
+
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
3615
|
+
...inlineTags ? { inlineTags } : {}
|
|
3555
3616
|
};
|
|
3556
3617
|
}
|
|
3557
3618
|
|
|
3558
3619
|
// src/serializers/shared.ts
|
|
3559
3620
|
function extractExportMetadata(node, symbol, checker, jsdocNode) {
|
|
3560
3621
|
const { deprecated, reason: deprecationReason } = isSymbolDeprecated(symbol);
|
|
3561
|
-
const { description, tags, examples } = getJSDocComment(jsdocNode ?? node, symbol, checker);
|
|
3622
|
+
const { description, tags, examples, inlineTags } = getJSDocComment(jsdocNode ?? node, symbol, checker);
|
|
3562
3623
|
const source = getSourceLocation(node, node.getSourceFile());
|
|
3563
|
-
return { description, tags, examples, source, deprecated, deprecationReason };
|
|
3624
|
+
return { description, tags, examples, source, deprecated, deprecationReason, inlineTags };
|
|
3564
3625
|
}
|
|
3565
3626
|
function buildSignatures(callSignatures, checker, ctx) {
|
|
3566
3627
|
return callSignatures.map((sig, index) => {
|
|
@@ -3575,6 +3636,7 @@ function buildSignatures(callSignatures, checker, ctx) {
|
|
|
3575
3636
|
...sigDoc.description ? { description: sigDoc.description } : {},
|
|
3576
3637
|
...sigDoc.tags.length > 0 ? { tags: sigDoc.tags } : {},
|
|
3577
3638
|
...sigDoc.examples.length > 0 ? { examples: sigDoc.examples } : {},
|
|
3639
|
+
...sigDoc.inlineTags ? { inlineTags: sigDoc.inlineTags } : {},
|
|
3578
3640
|
...sigTypeParams ? { typeParameters: sigTypeParams } : {},
|
|
3579
3641
|
...callSignatures.length > 1 ? { overloadIndex: index } : {}
|
|
3580
3642
|
};
|
|
@@ -3588,7 +3650,7 @@ function serializeClass(node, ctx) {
|
|
|
3588
3650
|
const name = symbol?.getName() ?? node.name?.getText();
|
|
3589
3651
|
if (!name)
|
|
3590
3652
|
return null;
|
|
3591
|
-
const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, checker);
|
|
3653
|
+
const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, checker);
|
|
3592
3654
|
const typeParameters = extractTypeParameters(node, checker);
|
|
3593
3655
|
const members = [];
|
|
3594
3656
|
const signatures = [];
|
|
@@ -3664,6 +3726,7 @@ function serializeClass(node, ctx) {
|
|
|
3664
3726
|
implements: implementsClause?.length ? implementsClause : undefined,
|
|
3665
3727
|
...deprecated ? { deprecated: true, deprecationReason } : {},
|
|
3666
3728
|
...examples.length > 0 ? { examples } : {},
|
|
3729
|
+
...inlineTags ? { inlineTags } : {},
|
|
3667
3730
|
...Object.keys(classFlags).length > 0 ? { flags: classFlags } : {}
|
|
3668
3731
|
};
|
|
3669
3732
|
}
|
|
@@ -3705,7 +3768,7 @@ function serializeProperty(node, ctx) {
|
|
|
3705
3768
|
const name = getMemberName(node);
|
|
3706
3769
|
if (!name)
|
|
3707
3770
|
return null;
|
|
3708
|
-
const { description, tags } = getJSDocComment(node);
|
|
3771
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
3709
3772
|
const visibility = getVisibility(node);
|
|
3710
3773
|
if (!ctx.includePrivate && (visibility === "private" || visibility === "protected")) {
|
|
3711
3774
|
return null;
|
|
@@ -3734,6 +3797,7 @@ function serializeProperty(node, ctx) {
|
|
|
3734
3797
|
visibility,
|
|
3735
3798
|
schema,
|
|
3736
3799
|
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
3800
|
+
...inlineTags ? { inlineTags } : {},
|
|
3737
3801
|
...deprecated ? { deprecated: true, deprecationReason } : {}
|
|
3738
3802
|
};
|
|
3739
3803
|
}
|
|
@@ -3742,7 +3806,7 @@ function serializeMethod(node, ctx) {
|
|
|
3742
3806
|
const name = getMemberName(node);
|
|
3743
3807
|
if (!name)
|
|
3744
3808
|
return null;
|
|
3745
|
-
const { description, tags } = getJSDocComment(node);
|
|
3809
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
3746
3810
|
const visibility = getVisibility(node);
|
|
3747
3811
|
if (!ctx.includePrivate && (visibility === "private" || visibility === "protected")) {
|
|
3748
3812
|
return null;
|
|
@@ -3775,6 +3839,7 @@ function serializeMethod(node, ctx) {
|
|
|
3775
3839
|
schema,
|
|
3776
3840
|
signatures: signatures.length > 0 ? signatures : undefined,
|
|
3777
3841
|
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
3842
|
+
...inlineTags ? { inlineTags } : {},
|
|
3778
3843
|
...deprecated ? { deprecated: true, deprecationReason } : {}
|
|
3779
3844
|
};
|
|
3780
3845
|
}
|
|
@@ -3786,13 +3851,14 @@ function serializeConstructor(node, ctx) {
|
|
|
3786
3851
|
return serializeConstructorSignature(node, sig, ctx);
|
|
3787
3852
|
}
|
|
3788
3853
|
function serializeConstructorSignature(node, sig, ctx) {
|
|
3789
|
-
const { description, tags, examples } = getJSDocComment(node);
|
|
3854
|
+
const { description, tags, examples, inlineTags } = getJSDocComment(node);
|
|
3790
3855
|
const params = extractParameters(sig, ctx);
|
|
3791
3856
|
return {
|
|
3792
3857
|
description,
|
|
3793
3858
|
parameters: params.length > 0 ? params : undefined,
|
|
3794
3859
|
...tags.length > 0 ? { tags } : {},
|
|
3795
|
-
...examples.length > 0 ? { examples } : {}
|
|
3860
|
+
...examples.length > 0 ? { examples } : {},
|
|
3861
|
+
...inlineTags ? { inlineTags } : {}
|
|
3796
3862
|
};
|
|
3797
3863
|
}
|
|
3798
3864
|
function serializeInheritedConstructors(node, ctx) {
|
|
@@ -3823,7 +3889,7 @@ function serializeAccessor(node, ctx) {
|
|
|
3823
3889
|
const name = getMemberName(node);
|
|
3824
3890
|
if (!name)
|
|
3825
3891
|
return null;
|
|
3826
|
-
const { description, tags } = getJSDocComment(node);
|
|
3892
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
3827
3893
|
const visibility = getVisibility(node);
|
|
3828
3894
|
if (!ctx.includePrivate && (visibility === "private" || visibility === "protected")) {
|
|
3829
3895
|
return null;
|
|
@@ -3861,7 +3927,8 @@ function serializeAccessor(node, ctx) {
|
|
|
3861
3927
|
visibility,
|
|
3862
3928
|
schema,
|
|
3863
3929
|
signatures,
|
|
3864
|
-
flags: Object.keys(flags).length > 0 ? flags : undefined
|
|
3930
|
+
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
3931
|
+
...inlineTags ? { inlineTags } : {}
|
|
3865
3932
|
};
|
|
3866
3933
|
}
|
|
3867
3934
|
function getExtendsClause(node, checker) {
|
|
@@ -3901,7 +3968,7 @@ function serializeEnum(node, ctx) {
|
|
|
3901
3968
|
const name = symbol?.getName() ?? node.name?.getText();
|
|
3902
3969
|
if (!name)
|
|
3903
3970
|
return null;
|
|
3904
|
-
const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, checker);
|
|
3971
|
+
const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, checker);
|
|
3905
3972
|
const members = node.members.map((member) => {
|
|
3906
3973
|
const memberSymbol = checker.getSymbolAtLocation(member.name);
|
|
3907
3974
|
const memberName = memberSymbol?.getName() ?? member.name.getText();
|
|
@@ -3914,13 +3981,21 @@ function serializeEnum(node, ctx) {
|
|
|
3914
3981
|
} else if (member.initializer) {
|
|
3915
3982
|
schema = { type: member.initializer.getText() };
|
|
3916
3983
|
}
|
|
3917
|
-
const {
|
|
3984
|
+
const {
|
|
3985
|
+
description: memberDesc,
|
|
3986
|
+
tags: memberTags,
|
|
3987
|
+
inlineTags: memberInlineTags
|
|
3988
|
+
} = getJSDocComment(member);
|
|
3989
|
+
const { deprecated: deprecated2, reason: deprecationReason2 } = isSymbolDeprecated(memberSymbol);
|
|
3918
3990
|
return {
|
|
3919
3991
|
id: memberName,
|
|
3920
3992
|
name: memberName,
|
|
3921
3993
|
kind: "enum-member",
|
|
3922
3994
|
...schema ? { schema } : {},
|
|
3923
|
-
...memberDesc ? { description: memberDesc } : {}
|
|
3995
|
+
...memberDesc ? { description: memberDesc } : {},
|
|
3996
|
+
...memberTags.length > 0 ? { tags: memberTags } : {},
|
|
3997
|
+
...memberInlineTags ? { inlineTags: memberInlineTags } : {},
|
|
3998
|
+
...deprecated2 ? { deprecated: true, deprecationReason: deprecationReason2 } : {}
|
|
3924
3999
|
};
|
|
3925
4000
|
});
|
|
3926
4001
|
return {
|
|
@@ -3932,7 +4007,8 @@ function serializeEnum(node, ctx) {
|
|
|
3932
4007
|
source,
|
|
3933
4008
|
members,
|
|
3934
4009
|
...deprecated ? { deprecated: true, deprecationReason } : {},
|
|
3935
|
-
...examples.length > 0 ? { examples } : {}
|
|
4010
|
+
...examples.length > 0 ? { examples } : {},
|
|
4011
|
+
...inlineTags ? { inlineTags } : {}
|
|
3936
4012
|
};
|
|
3937
4013
|
}
|
|
3938
4014
|
|
|
@@ -3971,7 +4047,7 @@ function serializeFunctionExport(node, ctx, nameOverride) {
|
|
|
3971
4047
|
const name = nameOverride ?? symbol?.getName() ?? node.name?.getText();
|
|
3972
4048
|
if (!name)
|
|
3973
4049
|
return null;
|
|
3974
|
-
const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, ctx.typeChecker);
|
|
4050
|
+
const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, ctx.typeChecker);
|
|
3975
4051
|
const typeParameters = extractTypeParameters(node, ctx.typeChecker);
|
|
3976
4052
|
const type = ctx.typeChecker.getTypeAtLocation(node);
|
|
3977
4053
|
const callSignatures = type.getCallSignatures();
|
|
@@ -4008,7 +4084,8 @@ function serializeFunctionExport(node, ctx, nameOverride) {
|
|
|
4008
4084
|
signatures,
|
|
4009
4085
|
...Object.keys(flags).length > 0 ? { flags } : {},
|
|
4010
4086
|
...deprecated ? { deprecated: true, deprecationReason } : {},
|
|
4011
|
-
...examples.length > 0 ? { examples } : {}
|
|
4087
|
+
...examples.length > 0 ? { examples } : {},
|
|
4088
|
+
...inlineTags ? { inlineTags } : {}
|
|
4012
4089
|
};
|
|
4013
4090
|
}
|
|
4014
4091
|
|
|
@@ -4020,7 +4097,7 @@ function serializeInterface(node, ctx) {
|
|
|
4020
4097
|
const name = symbol?.getName() ?? node.name?.getText();
|
|
4021
4098
|
if (!name)
|
|
4022
4099
|
return null;
|
|
4023
|
-
const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, checker);
|
|
4100
|
+
const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, checker);
|
|
4024
4101
|
const typeParameters = extractTypeParameters(node, checker);
|
|
4025
4102
|
const members = [];
|
|
4026
4103
|
const methodsByName = new Map;
|
|
@@ -4098,13 +4175,14 @@ function serializeInterface(node, ctx) {
|
|
|
4098
4175
|
signatures: exportSignatures,
|
|
4099
4176
|
extends: extendsClause,
|
|
4100
4177
|
...deprecated ? { deprecated: true, deprecationReason } : {},
|
|
4101
|
-
...examples.length > 0 ? { examples } : {}
|
|
4178
|
+
...examples.length > 0 ? { examples } : {},
|
|
4179
|
+
...inlineTags ? { inlineTags } : {}
|
|
4102
4180
|
};
|
|
4103
4181
|
}
|
|
4104
4182
|
function serializePropertySignature(node, ctx) {
|
|
4105
4183
|
const { typeChecker: checker } = ctx;
|
|
4106
4184
|
const name = node.name.getText();
|
|
4107
|
-
const { description, tags } = getJSDocComment(node);
|
|
4185
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
4108
4186
|
const rawType = checker.getTypeAtLocation(node);
|
|
4109
4187
|
const type = node.questionToken ? stripUndefinedFromType(rawType, checker) : rawType;
|
|
4110
4188
|
let schema = buildSchema(type, checker, ctx);
|
|
@@ -4127,13 +4205,14 @@ function serializePropertySignature(node, ctx) {
|
|
|
4127
4205
|
tags: tags.length > 0 ? tags : undefined,
|
|
4128
4206
|
schema,
|
|
4129
4207
|
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
4208
|
+
...inlineTags ? { inlineTags } : {},
|
|
4130
4209
|
...deprecated ? { deprecated: true, deprecationReason } : {}
|
|
4131
4210
|
};
|
|
4132
4211
|
}
|
|
4133
4212
|
function serializeMethodSignature(node, ctx) {
|
|
4134
4213
|
const { typeChecker: checker } = ctx;
|
|
4135
4214
|
const name = node.name.getText();
|
|
4136
|
-
const { description, tags } = getJSDocComment(node);
|
|
4215
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
4137
4216
|
const type = checker.getTypeAtLocation(node);
|
|
4138
4217
|
const callSignatures = type.getCallSignatures();
|
|
4139
4218
|
const signatures = buildSignatures(callSignatures, checker, ctx);
|
|
@@ -4152,12 +4231,13 @@ function serializeMethodSignature(node, ctx) {
|
|
|
4152
4231
|
schema,
|
|
4153
4232
|
signatures: signatures.length > 0 ? signatures : undefined,
|
|
4154
4233
|
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
4234
|
+
...inlineTags ? { inlineTags } : {},
|
|
4155
4235
|
...deprecated ? { deprecated: true, deprecationReason } : {}
|
|
4156
4236
|
};
|
|
4157
4237
|
}
|
|
4158
4238
|
function serializeCallSignature(node, ctx) {
|
|
4159
4239
|
const { typeChecker: checker } = ctx;
|
|
4160
|
-
const { description, tags } = getJSDocComment(node);
|
|
4240
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
4161
4241
|
const sig = checker.getSignatureFromDeclaration(node);
|
|
4162
4242
|
if (!sig)
|
|
4163
4243
|
return null;
|
|
@@ -4169,6 +4249,7 @@ function serializeCallSignature(node, ctx) {
|
|
|
4169
4249
|
kind: "call-signature",
|
|
4170
4250
|
description,
|
|
4171
4251
|
tags: tags.length > 0 ? tags : undefined,
|
|
4252
|
+
...inlineTags ? { inlineTags } : {},
|
|
4172
4253
|
signatures: [
|
|
4173
4254
|
{
|
|
4174
4255
|
parameters: params.length > 0 ? params : undefined,
|
|
@@ -4181,7 +4262,7 @@ function serializeCallSignature(node, ctx) {
|
|
|
4181
4262
|
}
|
|
4182
4263
|
function serializeIndexSignature(node, ctx) {
|
|
4183
4264
|
const { typeChecker: checker } = ctx;
|
|
4184
|
-
const { description, tags } = getJSDocComment(node);
|
|
4265
|
+
const { description, tags, inlineTags } = getJSDocComment(node);
|
|
4185
4266
|
const valueType = node.type ? checker.getTypeAtLocation(node.type) : checker.getAnyType();
|
|
4186
4267
|
const valueSchema = buildSchema(valueType, checker, ctx);
|
|
4187
4268
|
registerReferencedTypes(valueType, ctx);
|
|
@@ -4193,7 +4274,8 @@ function serializeIndexSignature(node, ctx) {
|
|
|
4193
4274
|
kind: "index-signature",
|
|
4194
4275
|
description,
|
|
4195
4276
|
tags: tags.length > 0 ? tags : undefined,
|
|
4196
|
-
schema: valueSchema
|
|
4277
|
+
schema: valueSchema,
|
|
4278
|
+
...inlineTags ? { inlineTags } : {}
|
|
4197
4279
|
};
|
|
4198
4280
|
}
|
|
4199
4281
|
function getInterfaceExtends(node, checker) {
|
|
@@ -4234,7 +4316,7 @@ function serializeTypeAlias(node, ctx) {
|
|
|
4234
4316
|
const name = symbol?.getName() ?? node.name?.getText();
|
|
4235
4317
|
if (!name)
|
|
4236
4318
|
return null;
|
|
4237
|
-
const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, ctx.typeChecker);
|
|
4319
|
+
const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, ctx.typeChecker);
|
|
4238
4320
|
const typeParameters = extractTypeParameters(node, ctx.typeChecker);
|
|
4239
4321
|
const type = ctx.typeChecker.getTypeAtLocation(node);
|
|
4240
4322
|
registerReferencedTypes(type, ctx);
|
|
@@ -4247,6 +4329,9 @@ function serializeTypeAlias(node, ctx) {
|
|
|
4247
4329
|
}
|
|
4248
4330
|
} else if (isInlineFunctionAlias(node.type) && type.getCallSignatures().length > 0) {
|
|
4249
4331
|
schema = buildFunctionSchema(type.getCallSignatures(), ctx.typeChecker, ctx);
|
|
4332
|
+
if (type.getProperties().length > 0) {
|
|
4333
|
+
members = serializeResolvedMembers(type, node, ctx);
|
|
4334
|
+
}
|
|
4250
4335
|
} else if ((ts11.isMappedTypeNode(node.type) || ts11.isConditionalTypeNode(node.type)) && type.getProperties().length > 0 && type.getCallSignatures().length === 0 && !(type.flags & ts11.TypeFlags.Conditional) && !(type.flags & (ts11.TypeFlags.StringLike | ts11.TypeFlags.NumberLike))) {
|
|
4251
4336
|
schema = buildObjectSchema(type.getProperties(), ctx.typeChecker, ctx, type);
|
|
4252
4337
|
members = serializeResolvedMembers(type, node, ctx);
|
|
@@ -4260,6 +4345,10 @@ function serializeTypeAlias(node, ctx) {
|
|
|
4260
4345
|
const text = renderTypeText(type, ctx.typeChecker, node, ts11.TypeFormatFlags.InTypeAlias);
|
|
4261
4346
|
if (!PRIMITIVES.has(text) && text !== name) {
|
|
4262
4347
|
schema["x-ts-type"] = text;
|
|
4348
|
+
const declared = writtenTypeText(declaredTypeNode(node));
|
|
4349
|
+
if (declared && declared !== text && !PRIMITIVES.has(declared)) {
|
|
4350
|
+
schema["x-ts-declared"] = declared;
|
|
4351
|
+
}
|
|
4263
4352
|
}
|
|
4264
4353
|
}
|
|
4265
4354
|
return {
|
|
@@ -4273,7 +4362,8 @@ function serializeTypeAlias(node, ctx) {
|
|
|
4273
4362
|
schema,
|
|
4274
4363
|
...members && members.length > 0 ? { members } : {},
|
|
4275
4364
|
...deprecated ? { deprecated: true, deprecationReason } : {},
|
|
4276
|
-
...examples.length > 0 ? { examples } : {}
|
|
4365
|
+
...examples.length > 0 ? { examples } : {},
|
|
4366
|
+
...inlineTags ? { inlineTags } : {}
|
|
4277
4367
|
};
|
|
4278
4368
|
}
|
|
4279
4369
|
function isObjectShapedAlias(type, ctx) {
|
|
@@ -4372,6 +4462,7 @@ function serializeResolvedMembers(type, node, ctx) {
|
|
|
4372
4462
|
if (prop.flags & ts11.SymbolFlags.Method)
|
|
4373
4463
|
flags.methodSyntax = true;
|
|
4374
4464
|
const schema = kind === "property" ? decoratePropertySchema(buildSchema(propType, checker, ctx), prop, propType, checker) : decoratePropertySchema({ "x-ts-function": true }, prop, propType, checker);
|
|
4465
|
+
const inlineTags = parseInlineTags(description);
|
|
4375
4466
|
members.push({
|
|
4376
4467
|
name: prop.getName(),
|
|
4377
4468
|
kind,
|
|
@@ -4380,6 +4471,7 @@ function serializeResolvedMembers(type, node, ctx) {
|
|
|
4380
4471
|
schema,
|
|
4381
4472
|
signatures: kind === "method" ? buildSignatures(callSigs, checker, ctx) : undefined,
|
|
4382
4473
|
flags: Object.keys(flags).length > 0 ? flags : undefined,
|
|
4474
|
+
...inlineTags ? { inlineTags } : {},
|
|
4383
4475
|
...deprecated ? { deprecated: true, deprecationReason } : {}
|
|
4384
4476
|
});
|
|
4385
4477
|
}
|
|
@@ -4555,7 +4647,7 @@ function serializeVariable(node, statement, ctx) {
|
|
|
4555
4647
|
const name = symbol?.getName() ?? node.name.getText();
|
|
4556
4648
|
if (!name)
|
|
4557
4649
|
return null;
|
|
4558
|
-
const { description, tags, examples, source, deprecated, deprecationReason } = extractExportMetadata(node, symbol, ctx.typeChecker, statement);
|
|
4650
|
+
const { description, tags, examples, source, deprecated, deprecationReason, inlineTags } = extractExportMetadata(node, symbol, ctx.typeChecker, statement);
|
|
4559
4651
|
const type = ctx.typeChecker.getTypeAtLocation(node);
|
|
4560
4652
|
const schemaExtraction = extractSchemaType(type, ctx.typeChecker);
|
|
4561
4653
|
const typeToSerialize = schemaExtraction?.outputType ?? type;
|
|
@@ -4575,7 +4667,8 @@ function serializeVariable(node, statement, ctx) {
|
|
|
4575
4667
|
schema,
|
|
4576
4668
|
...flags ? { flags } : {},
|
|
4577
4669
|
...deprecated ? { deprecated: true, deprecationReason } : {},
|
|
4578
|
-
...examples.length > 0 ? { examples } : {}
|
|
4670
|
+
...examples.length > 0 ? { examples } : {},
|
|
4671
|
+
...inlineTags ? { inlineTags } : {}
|
|
4579
4672
|
};
|
|
4580
4673
|
}
|
|
4581
4674
|
|
|
@@ -7138,6 +7231,7 @@ function serializeDeclaration2(declaration, exportSymbol, exportName, ctx, isTyp
|
|
|
7138
7231
|
}
|
|
7139
7232
|
function serializeNamespaceExport(symbol, exportName, ctx) {
|
|
7140
7233
|
const { description, tags, examples } = getJSDocFromExportSymbol(symbol);
|
|
7234
|
+
const inlineTags = parseInlineTags(description);
|
|
7141
7235
|
const members = [];
|
|
7142
7236
|
const checker = ctx.program.getTypeChecker();
|
|
7143
7237
|
let targetSymbol = symbol;
|
|
@@ -7162,7 +7256,8 @@ function serializeNamespaceExport(symbol, exportName, ctx) {
|
|
|
7162
7256
|
description,
|
|
7163
7257
|
tags,
|
|
7164
7258
|
...examples.length > 0 ? { examples } : {},
|
|
7165
|
-
...members.length > 0 ? { members } : {}
|
|
7259
|
+
...members.length > 0 ? { members } : {},
|
|
7260
|
+
...inlineTags ? { inlineTags } : {}
|
|
7166
7261
|
};
|
|
7167
7262
|
}
|
|
7168
7263
|
function serializeNamespaceMember(symbol, memberName, ctx) {
|
|
@@ -7209,15 +7304,22 @@ function serializeNamespaceMember(symbol, memberName, ctx) {
|
|
|
7209
7304
|
registerReferencedTypes(type, ctx);
|
|
7210
7305
|
schema = buildSchema(type, ctx.typeChecker, ctx);
|
|
7211
7306
|
}
|
|
7307
|
+
const inlineTags = parseInlineTags(description);
|
|
7212
7308
|
return {
|
|
7213
7309
|
name: memberName,
|
|
7214
7310
|
kind,
|
|
7215
7311
|
...description ? { description } : {},
|
|
7216
7312
|
...signatures ? { signatures } : {},
|
|
7217
7313
|
...schema ? { schema } : {},
|
|
7314
|
+
...inlineTags ? { inlineTags } : {},
|
|
7218
7315
|
...deprecated ? { flags: { deprecated: true } } : {}
|
|
7219
7316
|
};
|
|
7220
7317
|
}
|
|
7318
|
+
function flattenJSDocComment(comment) {
|
|
7319
|
+
if (comment === undefined)
|
|
7320
|
+
return "";
|
|
7321
|
+
return typeof comment === "string" ? comment : ts18.getTextOfJSDocComment(comment) ?? "";
|
|
7322
|
+
}
|
|
7221
7323
|
function getJSDocFromExportSymbol(symbol) {
|
|
7222
7324
|
const tags = [];
|
|
7223
7325
|
const examples = [];
|
|
@@ -7228,7 +7330,7 @@ function getJSDocFromExportSymbol(symbol) {
|
|
|
7228
7330
|
const jsDocs = ts18.getJSDocCommentsAndTags(exportDecl);
|
|
7229
7331
|
for (const doc of jsDocs) {
|
|
7230
7332
|
if (ts18.isJSDoc(doc) && doc.comment) {
|
|
7231
|
-
const commentText =
|
|
7333
|
+
const commentText = flattenJSDocComment(doc.comment);
|
|
7232
7334
|
if (commentText) {
|
|
7233
7335
|
return {
|
|
7234
7336
|
description: commentText,
|
|
@@ -7258,8 +7360,9 @@ function extractJSDocTags(doc) {
|
|
|
7258
7360
|
const tags = [];
|
|
7259
7361
|
for (const tag of doc.tags ?? []) {
|
|
7260
7362
|
if (tag.tagName.text !== "example") {
|
|
7261
|
-
const text =
|
|
7262
|
-
|
|
7363
|
+
const text = flattenJSDocComment(tag.comment);
|
|
7364
|
+
const inlineTags = parseInlineTags(text);
|
|
7365
|
+
tags.push({ name: tag.tagName.text, text, ...inlineTags ? { inlineTags } : {} });
|
|
7263
7366
|
}
|
|
7264
7367
|
}
|
|
7265
7368
|
return tags;
|
|
@@ -7268,7 +7371,7 @@ function extractExamples(doc) {
|
|
|
7268
7371
|
const examples = [];
|
|
7269
7372
|
for (const tag of doc.tags ?? []) {
|
|
7270
7373
|
if (tag.tagName.text === "example") {
|
|
7271
|
-
const text =
|
|
7374
|
+
const text = flattenJSDocComment(tag.comment);
|
|
7272
7375
|
if (text)
|
|
7273
7376
|
examples.push(text);
|
|
7274
7377
|
}
|
|
@@ -7837,6 +7940,7 @@ function getNodeName(node) {
|
|
|
7837
7940
|
}
|
|
7838
7941
|
export {
|
|
7839
7942
|
zodAdapter,
|
|
7943
|
+
writtenTypeText,
|
|
7840
7944
|
withDescription,
|
|
7841
7945
|
withDeprecated,
|
|
7842
7946
|
validateSpec2 as validateSpec,
|
|
@@ -7942,6 +8046,7 @@ export {
|
|
|
7942
8046
|
detectTsRuntime,
|
|
7943
8047
|
deduplicateSchemas,
|
|
7944
8048
|
decoratePropertySchema,
|
|
8049
|
+
declaredTypeNode,
|
|
7945
8050
|
createProgram,
|
|
7946
8051
|
createDocs,
|
|
7947
8052
|
categorizeBreakingChanges,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpkg-ts/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "TypeScript API extraction SDK - programmatic primitives for OpenPkg specs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openpkg",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"test": "bun test"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@openpkg-ts/spec": "^0.
|
|
46
|
+
"@openpkg-ts/spec": "^0.50.0",
|
|
47
47
|
"picomatch": "4.0.3",
|
|
48
48
|
"typescript": "^5.0.0"
|
|
49
49
|
},
|