import { css } from '@emotion/react';
import { theme } from '@expo/styleguide';
import MDX from '@mdx-js/runtime';
import * as React from 'react';
import * as components from '~/common/translate-markdown';
const STYLES_TABLE = css`
font-size: 1rem;
margin-top: 24px;
`;
const STYLES_HEAD = css`
background-color: ${theme.background.tertiary};
`;
const STYLES_DESCRIPTION_CELL = css`
word-break: break-word;
white-space: break-spaces;
padding-bottom: 0.2rem;
`;
export type Property = {
description?: string[];
name: string;
type?: string | string[];
enum?: string[];
properties?: Property[];
};
type FormattedProperty = {
name: string;
description: string;
nestingLevel: number;
};
export function formatSchema(rawSchema: Property[]) {
const formattedSchema: FormattedProperty[] = [];
rawSchema.map(property => {
appendProperty(formattedSchema, property, 0);
});
return formattedSchema;
}
//appends a property and recursively appends sub-properties
function appendProperty(
formattedSchema: FormattedProperty[],
property: Property,
_nestingLevel: number
) {
let nestingLevel = _nestingLevel;
formattedSchema.push({
name: nestingLevel
? `
| Property | Description |
|
|
|