doczjs / docz

✍ It has never been so easy to document your things!
https://docz.site
MIT License
23.55k stars 1.46k forks source link

Customized prop type description #1657

Open bedrich-schindler opened 2 years ago

bedrich-schindler commented 2 years ago

I've implemented custom prop type checker like this:

...

const elementOfType = (allowedTypes) => {
  if (!Array.isArray(allowedTypes) || allowedTypes.length === 0) {
    throw new TypeError('Prop type `elementOfType` requires at least 1 type.');
  }

  const elementOfTypeInternal = (
    props,
    propName,
    componentName,
  ) => validateChildren(props, propName, componentName, allowedTypes, false);
  elementOfTypeInternal.isRequired = (
    props,
    propName,
    componentName,
  ) => validateChildren(props, propName, componentName, allowedTypes, true);

  return elementOfTypeInternal;
};

export default elementOfType;

It is rendered like this:

image

Is there any way to render customized text instead of custom? I would expect to have something like elementOfTypeInternal.propType = 'CTAStart | CTACenter | CTAEnd' so it gets rendered as I want.

matheuspoleza commented 2 years ago

@bedrich-schindler before diving into it: is it something that still applies since the react-ui PR was closed since you guys decided to not move on with this feature?