Skip to Content
🎉 Nextra 4.0 is released. dimaMachina is looking for a new job or consulting .
APIgenerateDefinition

generateDefinition Function

Generate documentation for properties of type and interface and parameters and returns signature of function.

Exported from nextra/tsdoc.

Signature

Parameters:
NameTypeDefault
[0].codestring

TypeScript source code to be processed.

[0].exportNamestring

The name of the exported declaration.

"default"
[0].flattenedboolean

Whether to flatten nested objects. E.g. { foo: { bar: string } } will be represented as: { foo.bar: string }

false
Returns:
GeneratedDefinition & (GeneratedType | GeneratedFunction)

Parsed TSDoc definition from TypeScript type, interface or function.

Example

To generate documentation for a type, interface, or function, export it via the code argument.

As a default export

import { generateDefinition, TSDoc } from 'nextra/tsdoc' <TSDoc definition={generateDefinition({ code: "export { yourTypeOrFunction as default } from 'your-package'", })} />

As a named export

import { generateDefinition, TSDoc } from 'nextra/tsdoc' <TSDoc definition={generateDefinition({ code: "export { yourTypeOrFunction } from 'your-package'", exportName: 'yourTypeOrFunction' })} />