docs/src/scripts/createDocgen.js
async function createDocgen() {
  const customPropTypes = await getCustomPropTypes();
  const components = await getDocumentableComponents();
  const propTypesDatabase = getPropTypeLinks(components);
  const docgens = await Promise.all(components.map(c => createComponentsDocgen(c, customPropTypes)));

  const database = docgens.reduce((db, { group, docgens }) => {
    if (NESTED_GROUPS.indexOf(group) !== -1) {
      db[group] = docgens.reduce((entry, docgen) => {
        let name = kebabCase(docgen.component);
        if (!name.endsWith('ss')) {
          name = pluralize(name);
        }

        if (name.match(/selection-control-group/)) {
          entry[name.replace(/-group/, '')].push(docgen);
        } else {
          entry[name.replace(/-(pickers|progress)/, '')] = [docgen];
        }

        return entry;
      }, {});
    } else {
      db[group] = docgens;
    }

    return db;
  }, {});

  await writeFile(DOCGEN_DATABASE, JSON.stringify(database), 'UTF-8');
  console.log(`Wrote docgen database to \`${DOCGEN_DATABASE}\``);

  await writeFile(PROP_TYPE_DATABASE, JSON.stringify(propTypesDatabase), 'UTF-8');
  console.log(`Wrote docgen database to \`${PROP_TYPE_DATABASE}\``);
}
async function createDocgen() {
  const customPropTypes = await getCustomPropTypes();
  const components = await getDocumentableComponents();
  const propTypesDatabase = getPropTypeLinks(components);
  const docgens = await Promise.all(components.map(c => createComponentsDocgen(c, customPropTypes)));

  const database = docgens.reduce((db, { group, docgens }) => {
    if (NESTED_GROUPS.indexOf(group) !== -1) {
      db[group] = docgens.reduce((entry, docgen) => {
        let name = kebabCase(docgen.component);
        if (!name.endsWith('ss')) {
          name = pluralize(name);
        }

        if (name.match(/selection-control-group/)) {
          entry[name.replace(/-group/, '')].push(docgen);
        } else {
          entry[name.replace(/-(pickers|progress)/, '')] = [docgen];
        }

        return entry;
      }, {});
    } else {
      db[group] = docgens;
    }

    return db;
  }, {});

  await writeFile(DOCGEN_DATABASE, JSON.stringify(database), 'UTF-8');
  console.log(`Wrote docgen database to \`${DOCGEN_DATABASE}\``);

  await writeFile(PROP_TYPE_DATABASE, JSON.stringify(propTypesDatabase), 'UTF-8');
  console.log(`Wrote docgen database to \`${PROP_TYPE_DATABASE}\``);
}
async function createDocgen ( ) { const customPropTypes = await getCustomPropTypes ( ) ; const components = await getDocumentableComponents ( ) ; const propTypesDatabase = getPropTypeLinks ( components ) ; const docgens = await Promise . all ( components . map ( c => createComponentsDocgen ( c , customPropTypes ) ) ) ; const database = docgens . reduce ( ( db , { group , docgens } ) => { if ( NESTED_GROUPS . indexOf ( group ) !== - 1 ) { db [ group ] = docgens . reduce ( ( entry , docgen ) => { let name = kebabCase ( docgen . component ) ; if ( ! name . endsWith ( 'ss' ) ) { name = pluralize ( name ) ; } if ( name . match ( / selection-control-group / ) ) { entry [ name . replace ( / -group / , '' ) ] . push ( docgen ) ; } else { entry [ name . replace ( / -(pickers|progress) / , '' ) ] = [ docgen ] ; } return entry ; } , { } ) ; } else { db [ group ] = docgens ; } return db ; } , { } ) ; await writeFile ( DOCGEN_DATABASE , JSON . stringify ( database ) , 'UTF-8' ) ; console . log ( ` \` ${ DOCGEN_DATABASE } \` ` ) ; await writeFile ( PROP_TYPE_DATABASE , JSON . stringify ( propTypesDatabase ) , 'UTF-8' ) ; console . log ( ` \` ${ PROP_TYPE_DATABASE } \` ` ) ; }
Creates the "database" file of all the documentation for the components.
Creates the database file of all the documentation for the components .