aboutsummaryrefslogtreecommitdiff
path: root/scripts/apidoc/format.ts
blob: 0a502c5fc2a7d231a35c2fa509caa321b5815a48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type { Options } from 'prettier';
import { format } from 'prettier';
import prettierConfig from '../../.prettierrc.cjs';

/**
 * Formats markdown contents.
 *
 * @param text The text to format.
 */
export function formatMarkdown(text: string): string {
  return format(text, prettierMarkdown);
}

/**
 * Formats typedoc contents.
 *
 * @param text The text to format.
 */
export function formatTypescript(text: string): string {
  return format(text, prettierTypescript);
}

const prettierMarkdown: Options = {
  ...prettierConfig,
  parser: 'markdown',
};

const prettierTypescript: Options = {
  ...prettierConfig,
  parser: 'typescript',
};