Skip to content

Commit

Permalink
docs and publish 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
amcdnl committed Jul 30, 2024
1 parent 88a595d commit 89db890
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 3 deletions.
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "reachat",
"version": "0.0.1",
"version": "1.0.0",
"description": "Chat UI for Building LLMs",
"scripts": {
"build-storybook": "storybook build",
"build": "vite build --mode library",
"build": "npm run build:js && npm run build:docs",
"build:js": "vite build --mode library",
"build:docs": "node scripts/docs.js",
"lint": "eslint --ext js,ts,tsx",
"lint:fix": "eslint --ext js,ts,tsx --fix src",
"lint:prettier": "prettier --loglevel warn --write 'src/**/*.{ts,tsx,js,jsx}'",
Expand All @@ -29,6 +31,7 @@
"require": "./dist/index.umd.cjs",
"types": "./dist/index.d.ts"
},
"./docs.json": "./dist/docs.json",
"./index.css": "./dist/index.css"
},
"browser": "dist/index.js",
Expand All @@ -39,7 +42,7 @@
"framer-motion": "^10.16.16",
"highlight.js": "^11.10.0",
"mdast-util-find-and-replace": "^3.0.1",
"reablocks": "^8.4.3",
"reablocks": "^8.4.0",
"react-markdown": "^9.0.1",
"reakeys": "^2.0.3",
"remark-gfm": "^4.0.0",
Expand Down
59 changes: 59 additions & 0 deletions scripts/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { readFileSync, writeFileSync } from 'fs';
import fg from 'fast-glob';
import { resolve } from 'path';
import docgen from 'react-docgen-typescript';

/**
* Builds the doc types.
*/
function buildDocs() {
const files = fg.sync('src/**/!(*.stories).tsx');

const result = [];
let count = 0;
let fail = 0;
const options = {
savePropValueAsString: true,
// Skip generating docs for HTML attributes
propFilter: (prop) => {
if (prop.declarations !== undefined && prop.declarations.length > 0) {
const hasPropAdditionalDescription = prop.declarations.find((declaration) => {
return !declaration.fileName.includes('node_modules');
});

return Boolean(hasPropAdditionalDescription);
}

return true;
},
};

const docgenWithTSConfig = docgen.withCustomConfig(
'./tsconfig.json',
options
);

files.forEach(file => {
console.log('Reading', file);

try {
const documentation = docgenWithTSConfig.parse(file, options);
if (documentation) {
result.push(...documentation);
count++;
}
} catch (e) {
fail++;
console.error('Error reading', file, e);
}
});

const fileName = resolve('dist', 'docs.json');
writeFileSync(fileName, JSON.stringify(result, null, 2));

console.info('Docs created!', fileName);
console.info('Failed:', fail);
console.info('Total Doc:', count);
}

buildDocs();

0 comments on commit 89db890

Please sign in to comment.