Skip to content
This repository was archived by the owner on Aug 26, 2021. It is now read-only.

Commit 5c2935f

Browse files
author
Adam A. Zerella
committed
Playing around with scrips and generating README.md
1 parent 79fb752 commit 5c2935f

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

components/accordion/src/js/react.js components/accordion/src/react/react.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ class AUaccordion extends React.PureComponent {
350350
/**
351351
* Toggle an accordion on click
352352
*
353-
* @param {event object} event - The event object of the click
353+
* @param {object} event - The event object of the click
354354
*/
355355
toggle( event ) {
356356
event.preventDefault();

scripts/generate-readme/package-lock.json

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/generate-readme/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"@babel/preset-env": "^7.3.1",
1414
"@babel/preset-react": "^7.0.0",
1515
"jsdoc-to-markdown": "^4.0.1",
16+
"pkg-dep-tree": "^0.2.1",
1617
"prismjs": "^1.15.0",
1718
"react": "^16.8.1",
1819
"react-dom": "^16.8.1"

scripts/generate-readme/src/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ const Path = require( 'path' );
33
const Fs = require( 'fs' );
44

55
module.exports = {
6-
"componentPath": Path.join( __dirname, `/../../../components` ),
6+
"workspace": Path.join( __dirname, `/../../../components` ),
77
"prismTheme": Fs.readFileSync( Path.join( __dirname, '/../node_modules/prismjs/themes/prism-dark.css' ), 'utf-8' )
88
}

scripts/generate-readme/src/index.js

+30-17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const Fs = require( 'fs' );
33
const Fsp = Fs.promises;
44
const Path = require( 'path' );
55
const JSDoc = require( 'jsdoc-to-markdown' );
6+
const { GetMonoDepTree, PrintTreeTrim } = require( 'pkg-dep-tree' );
67

78
// Local Dependencies
89
const { GetFolders } = require( './helper' );
@@ -15,34 +16,48 @@ const { Render, RenderExample } = require( './renderer' );
1516
* @param {filePath} reactSource
1617
*/
1718
const RenderReactDocs = async ( reactSource ) => {
18-
return await JSDoc.render( reactSource );
19+
let templateData = await JSDoc.getTemplateData( reactSource );
20+
21+
return templateData
22+
.map( item => {
23+
return { name } = item;
24+
})
25+
26+
27+
// console.log( templateData );
28+
// console.log( await JSDoc.getJsdocData( reactSource ) );
29+
// return await JSDoc.getTemplateData( reactSource );
1930
}
2031

32+
const GenerateReactProps = async( reactSourceFile ) => {
33+
return await RenderReactDocs( { files: reactSourceFile } );
34+
}
2135

2236
const GenerateDocPage = async () => {
23-
let components = await GetFolders( Config.componentPath );
37+
let components = await GetFolders( Config.workspace );
2438

25-
let markdown = await Fsp.readFile( `${components[ 0 ]}/doc/OVERVIEW.md`, 'utf-8' );
39+
let markdown = ''
2640

2741
// Append React component comments to OVERVIEW.md file
28-
markdown += await RenderReactDocs( { files: `${components[ 0 ]}/src/react/button.js` }, 'utf-8' );
29-
30-
let html = Render( markdown );
31-
html += `<style>${ Config.prismTheme }</style>`
42+
markdown += await RenderReactDocs( { files: `${components[ 0 ]}/src/react/react.js` }, 'utf-8' );
3243

33-
Fsp.writeFile( `index.html`, html );
44+
// let html = Render( markdown );
45+
// html += `<style>${ Config.prismTheme }</style>`
46+
47+
// console.log( html );
48+
return markdown
49+
// Fsp.writeFile( `index.html`, html );
3450
}
3551

3652

3753
// Start thing
38-
( async () => {
39-
// await GenerateDocPage();
40-
41-
let components = await GetFolders( Config.componentPath );
54+
( async () => {
55+
let components = await GetFolders( Config.workspace );
4256

4357
let packageMeta = JSON.parse( await Fsp.readFile( `${components[ 0 ]}/package.json` ) );
4458
let packageNamePlain = packageMeta.name.split('/')[1]
4559

60+
let sourceFiles = { "files": `${ components[ 0 ] }/src/react/react.js` }
4661
let readme = `${packageMeta.name}
4762
4863
---
@@ -58,16 +73,14 @@ npm i ${packageMeta.name}
5873
\`\`\`
5974
6075
## Usage
61-
\`\`\`jsx
62-
63-
\`\`\`
6476
6577
## Props
66-
todo
78+
${ await RenderReactDocs( sourceFiles ) }
6779
6880
## Dependency Graph
6981
\`\`\`bash
70-
82+
${ packageNamePlain }
83+
${ await( PrintTreeTrim( await GetMonoDepTree( Config.workspace, packageNamePlain, '@gov.au') ) ) }
7184
\`\`\`
7285
7386
## Test

0 commit comments

Comments
 (0)