Skip to content

Commit

Permalink
Address @tofumatt review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jun 19, 2018
1 parent 973a0b5 commit 6d465a5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/data/tool/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
namespaces: {
core: {
title: 'WordPress Core Data',
// Figures out a way to generate docs for the dynamic actions/selectors
// TODO: Figure out a way to generate docs for dynamic actions/selectors
selectors: [ path.resolve( root, 'packages/core-data/src/selectors.js' ) ],
actions: [ path.resolve( root, 'packages/core-data/src/actions.js' ) ],
},
Expand All @@ -34,7 +34,7 @@ module.exports = {
actions: [ path.resolve( root, 'viewport/store/actions.js' ) ],
},
'core/nux': {
title: 'The NUX module Data',
title: 'The NUX (New User Experience) module Data',
selectors: [ path.resolve( root, 'nux/store/selectors.js' ) ],
actions: [ path.resolve( root, 'nux/store/actions.js' ) ],
},
Expand Down
12 changes: 6 additions & 6 deletions docs/data/tool/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const lodash = require( 'lodash' );
/**
* Generates the table of contents' markdown.
*
* @param {Object} parsed Parsed Namespace Object
* @param {Object} parsedNamespaces Parsed Namespace Object
*
* @return {string} Markdown string
*/
function generateTableOfContent( parsed ) {
function generateTableOfContent( parsedNamespaces ) {
return [
'# Data Module Reference',
'',
Object.values( parsed ).map( ( parsedNamespace ) => {
Object.values( parsedNamespaces ).map( ( parsedNamespace ) => {
return ` - [**${ parsedNamespace.name }**: ${ parsedNamespace.title }](./${ lodash.kebabCase( parsedNamespace.name ) }.md)`;
} ).join( '\n' ),
].join( '\n' );
Expand Down Expand Up @@ -77,14 +77,14 @@ function generateNamespaceDocs( parsedNamespace ) {
].join( '\n' );
}

module.exports = function( parsed, rootFolder ) {
const tableOfContent = generateTableOfContent( parsed );
module.exports = function( parsedNamespaces, rootFolder ) {
const tableOfContent = generateTableOfContent( parsedNamespaces );
fs.writeFileSync(
path.join( rootFolder, 'index.md' ),
tableOfContent
);

Object.values( parsed ).forEach( ( parsedNamespace ) => {
Object.values( parsedNamespaces ).forEach( ( parsedNamespace ) => {
const namespaceDocs = generateNamespaceDocs( parsedNamespace );
fs.writeFileSync(
path.join( rootFolder, lodash.kebabCase( parsedNamespace.name ) + '.md' ),
Expand Down
1 change: 1 addition & 0 deletions docs/data/tool/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = function( config ) {
const code = fs.readFileSync( file, 'utf8' );
const parsedCode = espree.parse( code, {
attachComment: true,
// This should ideally match our babel config, but espree doesn't support it.
ecmaVersion: 9,
sourceType: 'module',
} );
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
"predev": "npm run check-engines",
"dev": "npm run build:packages && concurrently \"cross-env webpack --watch\" \"npm run dev:packages\"",
"dev:packages": "node ./bin/packages/watch.js",
"docs:generate-data-reference": "node docs/data/tool",
"fixtures:clean": "rimraf \"core-blocks/test/fixtures/*.+(json|serialized.html)\"",
"fixtures:server-registered": "docker-compose run -w /var/www/html/wp-content/plugins/gutenberg --rm wordpress ./bin/get-server-blocks.php > core-blocks/test/server-registered.json",
"fixtures:generate": "npm run fixtures:server-registered && cross-env GENERATE_MISSING_FIXTURES=y npm run test-unit",
Expand All @@ -173,7 +174,6 @@
"test-unit:coverage-ci": "npm run test-unit -- --coverage --maxWorkers 1 && codecov",
"test-unit:watch": "npm run test-unit -- --watch",
"test-unit-php": "docker-compose run --rm wordpress_phpunit phpunit",
"test-unit-php-multisite": "docker-compose run -e WP_MULTISITE=1 --rm wordpress_phpunit phpunit",
"docs:generate-data-reference": "node docs/data/tool"
"test-unit-php-multisite": "docker-compose run -e WP_MULTISITE=1 --rm wordpress_phpunit phpunit"
}
}

0 comments on commit 6d465a5

Please sign in to comment.