import * as React from 'react';
import classNames from 'classnames';
import hljs from 'highlight.js';
import { getUdfDocs } from '../../actions/DocActions';
import usePromiseResult from '../../hooks/usePromiseResult';
import { UdfArgumentSpec, UdfCategory, UdfMethodSpec } from '../../types/DocTypes';
import Text, { TextSizes } from '../../uikit/Text';
import { renderFromPromiseResult } from '../../utils/PromiseResultUtils';
import styles from './UdfDocsView.module.css';
/*
TODO:
- Set up page for other non-UDF documentation (eg have UDF header, probably change URL to be just `/docs`)
- Ability to link to individual function's position on page, have hover button on each UDF title that navigates to
the UDF's URL
- TOC at side
- Render markdown (or at least simple subsets?) in the docs
*/
interface UdfDocProps {
udf: UdfMethodSpec;
}
const UdfDoc = ({ udf }: UdfDocProps) => {
const argumentAsParam = (arg: UdfArgumentSpec): string => {
const defaultPart = arg.default != null ? ` = ${arg.default}` : '';
return `${arg.name}: ${arg.type}${defaultPart}`;
};
const params = udf.argument_specs.map(argumentAsParam).join(', ');
const hasAnyArgDocs = udf.argument_specs.some((spec) => spec.doc != null);
const mainDoc = udf.doc != null && {spec.name}: {spec.doc}