xyd 0.1.0-alpha - Coming Soon

Reference
/
@uniform

@uniformExperimental

Learn how to use @uniform function

The @uniform function is a powerful tool for generating API reference documentation from your source code. It automatically extracts and formats code documentation, including types, parameters, return values, and examples.

The @uniform function is still in experimental stage.

Basic Usage

Import documentation from a TypeScript/JavaScript file:

@uniform "./path/to/file.ts"

Supported File Types

The function supports various file types and formats:

  • TypeScript/JavaScript files (.ts, .tsx, .js, .jsx)
  • GraphQL schema files (.graphql)
  • OpenAPI/Swagger specifications (.yaml, .json)
  • React components (.tsx, .jsx)

Features

Automatic Type Detection

The function automatically detects and documents:

  • Function parameters and return types
  • Interface and type definitions
  • Class properties and methods
  • React component props

Code Examples

You can include code examples in your documentation using TypeDoc comments:

/**
* @example
* ```ts
* const result = myFunction("example");
* console.log(result);
* ```
*/

Region Selection

Like @importCode, you can select specific regions of code:

@uniform "./file.ts#regionName"

Line Ranges

You can also specify line ranges:

@uniform "./file.ts{1-10}"

Integration with Components

The @uniform function can be used with the Atlas component to display API documentation:

::atlas{references="@uniform('./api.ts')"}

Output Format

The function generates a structured JSON output containing:

  • Title and description
  • Function/type signatures
  • Parameters and return types
  • Examples
  • Source code location
  • Related references

Plugins

You can configure the uniform plugins in your docs.json:

{
"uniform": {
"plugins": [
// Custom plugins for processing uniform output
]
}
}
Edit page
Built with

Show your support! Star us on GitHub ⭐️