From 41be78b0456e6f4ae6486b0e2bdf8ea7875e4249 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 28 Jun 2018 08:37:02 +0100 Subject: [PATCH] Documentation: Generates the manifest dynamically to include the data module docs in the handbook (#7411) * Documentation: Generates the manifest dynamically to include the data module docs in the handbook * Using tabs instead of spaces in the generated manifest * Destructure lodash * Data Docs: rename index.md => README.md --- docs/data/{index.md => README.md} | 2 +- docs/data/core-edit-post.md | 2 +- docs/data/core-nux.md | 20 ++- docs/data/core.md | 2 +- docs/data/tool/index.js | 9 -- docs/manifest.json | 114 +++++++++++----- docs/root-manifest.json | 212 ++++++++++++++++++++++++++++++ docs/{data => }/tool/config.js | 10 +- docs/{data => }/tool/generator.js | 8 +- docs/tool/index.js | 22 ++++ docs/tool/manifest.js | 30 +++++ docs/{data => }/tool/parser.js | 4 +- package.json | 2 +- 13 files changed, 377 insertions(+), 60 deletions(-) rename docs/data/{index.md => README.md} (81%) delete mode 100644 docs/data/tool/index.js create mode 100644 docs/root-manifest.json rename docs/{data => }/tool/config.js (84%) rename docs/{data => }/tool/generator.js (91%) create mode 100644 docs/tool/index.js create mode 100644 docs/tool/manifest.js rename docs/{data => }/tool/parser.js (94%) diff --git a/docs/data/index.md b/docs/data/README.md similarity index 81% rename from docs/data/index.md rename to docs/data/README.md index acd84a70f4e421..ee3e9876305edd 100644 --- a/docs/data/index.md +++ b/docs/data/README.md @@ -5,4 +5,4 @@ - [**core/editor**: The Editor's Data](./core-editor.md) - [**core/edit-post**: The Editor's UI Data](./core-edit-post.md) - [**core/viewport**: The viewport module Data](./core-viewport.md) - - [**core/nux**: The NUX module Data](./core-nux.md) \ No newline at end of file + - [**core/nux**: The NUX (New User Experience) module Data](./core-nux.md) \ No newline at end of file diff --git a/docs/data/core-edit-post.md b/docs/data/core-edit-post.md index be5e8acfe1c08b..06947353599fa4 100644 --- a/docs/data/core-edit-post.md +++ b/docs/data/core-edit-post.md @@ -233,7 +233,7 @@ Returns an action object used to request meta box update. ### metaBoxUpdatesSuccess -Returns an action object used signal a successfull meta box update. +Returns an action object used signal a successful meta box update. ### setMetaBoxSavedData diff --git a/docs/data/core-nux.md b/docs/data/core-nux.md index 7da5192f596add..6f32549f36f8c5 100644 --- a/docs/data/core-nux.md +++ b/docs/data/core-nux.md @@ -1,4 +1,4 @@ -# **core/nux**: The NUX module Data +# **core/nux**: The NUX (New User Experience) module Data ## Selectors @@ -13,6 +13,18 @@ guide that they have been added to. * state: Global application state. * id: The tip to query. +### areTipsEnabled + +Returns whether or not tips are globally enabled. + +*Parameters* + + * state: Global application state. + +*Returns* + +Whether tips are globally enabled. + ## Actions ### triggerGuide @@ -36,4 +48,8 @@ dismissed tip will not show again. ### disableTips Returns an action object that, when dispatched, prevents all tips from -showing again. \ No newline at end of file +showing again. + +### enableTips + +Returns an action object that, when dispatched, makes all tips show again. \ No newline at end of file diff --git a/docs/data/core.md b/docs/data/core.md index 433923d4090886..7dd17fa91a664f 100644 --- a/docs/data/core.md +++ b/docs/data/core.md @@ -106,7 +106,7 @@ Record. ### getThemeSupports -Return theme suports data in the index. +Return theme supports data in the index. *Parameters* diff --git a/docs/data/tool/index.js b/docs/data/tool/index.js deleted file mode 100644 index 7fd22fbb770248..00000000000000 --- a/docs/data/tool/index.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Internal dependencies - */ -const config = require( './config' ); -const parser = require( './parser' ); -const generator = require( './generator' ); - -const parsedModules = parser( config.namespaces ); -generator( parsedModules, config.output ); diff --git a/docs/manifest.json b/docs/manifest.json index a6ba988310e3a0..45bf2d9284bf75 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -2,211 +2,253 @@ { "title": "Introduction", "slug": "handbook", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/readme.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/readme.md", "parent": null }, { "title": "The Language of Gutenberg", "slug": "language", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/language.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/language.md", "parent": null }, { "title": "Block API", "slug": "block-api", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/block-api.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/block-api.md", "parent": null }, { "title": "Attributes", "slug": "attributes", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/block-api\/attributes.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/block-api/attributes.md", "parent": "block-api" }, { "title": "Edit and Save", "slug": "block-edit-save", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/block-api\/block-edit-save.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/block-api/block-edit-save.md", "parent": "block-api" }, { "title": "RichText API", "slug": "rich-text-api", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/editor\/components\/rich-text\/README.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/editor/components/rich-text/README.md", "parent": "block-api" }, { "title": "Deprecated Blocks", "slug": "deprecated-blocks", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/block-api\/deprecated-blocks.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/block-api/deprecated-blocks.md", "parent": "block-api" }, { "title": "Templates", "slug": "templates", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/templates.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/templates.md", "parent": null }, { "title": "Extensibility", "slug": "extensibility", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/extensibility.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/extensibility.md", "parent": null }, { "title": "Extending Blocks", "slug": "extending-blocks", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/extensibility/extending-blocks.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/extensibility/extending-blocks.md", "parent": "extensibility" }, { "title": "Meta Boxes", "slug": "meta-box", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/extensibility/meta-box.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/extensibility/meta-box.md", "parent": "extensibility" }, { "title": "Theme Support", "slug": "theme-support", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/extensibility/theme-support.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/extensibility/theme-support.md", "parent": "extensibility" }, { "title": "Autocomplete", "slug": "autocomplete", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/extensibility/autocomplete.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/extensibility/autocomplete.md", "parent": "extensibility" }, { "title": "Creating Block Types", "slug": "blocks", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/blocks.md", "parent": null }, { "title": "Writing Your First Block Type", "slug": "writing-your-first-block-type", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks\/writing-your-first-block-type.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/blocks/writing-your-first-block-type.md", "parent": "blocks" }, { "title": "Applying Styles With Stylesheets", "slug": "applying-styles-with-stylesheets", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks\/applying-styles-with-stylesheets.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/blocks/applying-styles-with-stylesheets.md", "parent": "blocks" }, { "title": "Introducing Attributes and Editable Fields", "slug": "introducing-attributes-and-editable-fields", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks\/introducing-attributes-and-editable-fields.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/blocks/introducing-attributes-and-editable-fields.md", "parent": "blocks" }, { "title": "Block Controls: Toolbars and Inspector", "slug": "block-controls-toolbars-and-inspector", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks\/block-controls-toolbars-and-inspector.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/blocks/block-controls-toolbars-and-inspector.md", "parent": "blocks" }, { "title": "Creating dynamic blocks", "slug": "creating-dynamic-blocks", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks\/creating-dynamic-blocks.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/blocks/creating-dynamic-blocks.md", "parent": "blocks" }, { "title": "Generate Blocks with WP-CLI", "slug": "generate-blocks-with-wp-cli", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks\/generate-blocks-with-wp-cli.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/blocks/generate-blocks-with-wp-cli.md", "parent": "blocks" }, { "title": "Reference", "slug": "reference", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/reference.md", "parent": null }, { "title": "Glossary", "slug": "glossary", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/glossary.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/reference/glossary.md", "parent": "reference" }, { "title": "Design Principles", "slug": "design-principles", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/design-principles.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/reference/design-principles.md", "parent": "reference" }, { "title": "History", "slug": "history", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/history.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/reference/history.md", "parent": "reference" }, { "title": "Coding Guidelines", "slug": "coding-guidelines", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/coding-guidelines.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/reference/coding-guidelines.md", "parent": "reference" }, { "title": "Testing Overview", "slug": "testing-overview", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/testing-overview.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/reference/testing-overview.md", "parent": "reference" }, { "title": "Frequently Asked Questions", "slug": "faq", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/faq.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/reference/faq.md", "parent": "reference" }, { "title": "Release Process", "slug": "release", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/release.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/reference/release.md", "parent": "reference" }, { "title": "Deprecated Features", "slug": "deprecated", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/deprecated.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/reference/deprecated.md", "parent": "reference" }, { "title": "Repository Management", "slug": "repository-management", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/repository-management.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/reference/repository-management.md", "parent": "reference" }, { "title": "Outreach", "slug": "outreach", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/outreach.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/outreach.md", "parent": null }, { "title": "Articles", "slug": "articles", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/outreach\/docs\/articles.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/outreach/docs/articles.md", "parent": "outreach" }, { "title": "Meetups", "slug": "meetups", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/outreach\/meetups.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/outreach/meetups.md", "parent": "outreach" }, { "title": "Talks", "slug": "talks", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/outreach\/talks.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/outreach/talks.md", "parent": "outreach" }, { "title": "Resources", "slug": "resources", - "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/outreach\/resources.md", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/outreach/resources.md", "parent": "outreach" + }, + { + "title": "Data Package Reference", + "slug": "packages-data", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/data/README.md", + "parent": "reference" + }, + { + "title": "WordPress Core Data", + "slug": "packages-data-core", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/data/core.md", + "parent": "packages-data" + }, + { + "title": "Block Types Data", + "slug": "packages-data-core-blocks", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/data/core-blocks.md", + "parent": "packages-data" + }, + { + "title": "The Editor's Data", + "slug": "packages-data-core-editor", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/data/core-editor.md", + "parent": "packages-data" + }, + { + "title": "The Editor's UI Data", + "slug": "packages-data-core-edit-post", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/data/core-edit-post.md", + "parent": "packages-data" + }, + { + "title": "The viewport module Data", + "slug": "packages-data-core-viewport", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/data/core-viewport.md", + "parent": "packages-data" + }, + { + "title": "The NUX (New User Experience) module Data", + "slug": "packages-data-core-nux", + "markdown_source": "https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/data/core-nux.md", + "parent": "packages-data" } -] +] \ No newline at end of file diff --git a/docs/root-manifest.json b/docs/root-manifest.json new file mode 100644 index 00000000000000..a6ba988310e3a0 --- /dev/null +++ b/docs/root-manifest.json @@ -0,0 +1,212 @@ +[ + { + "title": "Introduction", + "slug": "handbook", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/readme.md", + "parent": null + }, + { + "title": "The Language of Gutenberg", + "slug": "language", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/language.md", + "parent": null + }, + { + "title": "Block API", + "slug": "block-api", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/block-api.md", + "parent": null + }, + { + "title": "Attributes", + "slug": "attributes", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/block-api\/attributes.md", + "parent": "block-api" + }, + { + "title": "Edit and Save", + "slug": "block-edit-save", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/block-api\/block-edit-save.md", + "parent": "block-api" + }, + { + "title": "RichText API", + "slug": "rich-text-api", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/editor\/components\/rich-text\/README.md", + "parent": "block-api" + }, + { + "title": "Deprecated Blocks", + "slug": "deprecated-blocks", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/block-api\/deprecated-blocks.md", + "parent": "block-api" + }, + { + "title": "Templates", + "slug": "templates", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/templates.md", + "parent": null + }, + { + "title": "Extensibility", + "slug": "extensibility", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/extensibility.md", + "parent": null + }, + { + "title": "Extending Blocks", + "slug": "extending-blocks", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/extensibility/extending-blocks.md", + "parent": "extensibility" + }, + { + "title": "Meta Boxes", + "slug": "meta-box", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/extensibility/meta-box.md", + "parent": "extensibility" + }, + { + "title": "Theme Support", + "slug": "theme-support", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/extensibility/theme-support.md", + "parent": "extensibility" + }, + { + "title": "Autocomplete", + "slug": "autocomplete", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/extensibility/autocomplete.md", + "parent": "extensibility" + }, + { + "title": "Creating Block Types", + "slug": "blocks", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks.md", + "parent": null + }, + { + "title": "Writing Your First Block Type", + "slug": "writing-your-first-block-type", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks\/writing-your-first-block-type.md", + "parent": "blocks" + }, + { + "title": "Applying Styles With Stylesheets", + "slug": "applying-styles-with-stylesheets", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks\/applying-styles-with-stylesheets.md", + "parent": "blocks" + }, + { + "title": "Introducing Attributes and Editable Fields", + "slug": "introducing-attributes-and-editable-fields", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks\/introducing-attributes-and-editable-fields.md", + "parent": "blocks" + }, + { + "title": "Block Controls: Toolbars and Inspector", + "slug": "block-controls-toolbars-and-inspector", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks\/block-controls-toolbars-and-inspector.md", + "parent": "blocks" + }, + { + "title": "Creating dynamic blocks", + "slug": "creating-dynamic-blocks", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks\/creating-dynamic-blocks.md", + "parent": "blocks" + }, + { + "title": "Generate Blocks with WP-CLI", + "slug": "generate-blocks-with-wp-cli", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/blocks\/generate-blocks-with-wp-cli.md", + "parent": "blocks" + }, + { + "title": "Reference", + "slug": "reference", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference.md", + "parent": null + }, + { + "title": "Glossary", + "slug": "glossary", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/glossary.md", + "parent": "reference" + }, + { + "title": "Design Principles", + "slug": "design-principles", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/design-principles.md", + "parent": "reference" + }, + { + "title": "History", + "slug": "history", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/history.md", + "parent": "reference" + }, + { + "title": "Coding Guidelines", + "slug": "coding-guidelines", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/coding-guidelines.md", + "parent": "reference" + }, + { + "title": "Testing Overview", + "slug": "testing-overview", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/testing-overview.md", + "parent": "reference" + }, + { + "title": "Frequently Asked Questions", + "slug": "faq", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/faq.md", + "parent": "reference" + }, + { + "title": "Release Process", + "slug": "release", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/release.md", + "parent": "reference" + }, + { + "title": "Deprecated Features", + "slug": "deprecated", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/deprecated.md", + "parent": "reference" + }, + { + "title": "Repository Management", + "slug": "repository-management", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/reference\/repository-management.md", + "parent": "reference" + }, + { + "title": "Outreach", + "slug": "outreach", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/outreach.md", + "parent": null + }, + { + "title": "Articles", + "slug": "articles", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/outreach\/docs\/articles.md", + "parent": "outreach" + }, + { + "title": "Meetups", + "slug": "meetups", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/outreach\/meetups.md", + "parent": "outreach" + }, + { + "title": "Talks", + "slug": "talks", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/outreach\/talks.md", + "parent": "outreach" + }, + { + "title": "Resources", + "slug": "resources", + "markdown_source": "https:\/\/raw.githubusercontent.com\/WordPress\/gutenberg\/master\/docs\/outreach\/resources.md", + "parent": "outreach" + } +] diff --git a/docs/data/tool/config.js b/docs/tool/config.js similarity index 84% rename from docs/data/tool/config.js rename to docs/tool/config.js index ef755ea4ebd116..3c608e69a3186b 100644 --- a/docs/data/tool/config.js +++ b/docs/tool/config.js @@ -3,10 +3,10 @@ */ const path = require( 'path' ); -const root = path.resolve( __dirname, '../../../' ); +const root = path.resolve( __dirname, '../../' ); module.exports = { - namespaces: { + dataNamespaces: { core: { title: 'WordPress Core Data', // TODO: Figure out a way to generate docs for dynamic actions/selectors @@ -40,5 +40,9 @@ module.exports = { }, }, - output: path.resolve( __dirname, '../' ), + dataDocsOutput: path.resolve( __dirname, '../data' ), + + rootManifest: path.resolve( __dirname, '../root-manifest.json' ), + + manifestOutput: path.resolve( __dirname, '../manifest.json' ), }; diff --git a/docs/data/tool/generator.js b/docs/tool/generator.js similarity index 91% rename from docs/data/tool/generator.js rename to docs/tool/generator.js index 63869c67872e21..1e6b7c940bbf8e 100644 --- a/docs/data/tool/generator.js +++ b/docs/tool/generator.js @@ -3,7 +3,7 @@ */ const path = require( 'path' ); const fs = require( 'fs' ); -const lodash = require( 'lodash' ); +const { kebabCase } = require( 'lodash' ); /** * Generates the table of contents' markdown. @@ -17,7 +17,7 @@ function generateTableOfContent( parsedNamespaces ) { '# Data Module Reference', '', Object.values( parsedNamespaces ).map( ( parsedNamespace ) => { - return ` - [**${ parsedNamespace.name }**: ${ parsedNamespace.title }](./${ lodash.kebabCase( parsedNamespace.name ) }.md)`; + return ` - [**${ parsedNamespace.name }**: ${ parsedNamespace.title }](./${ kebabCase( parsedNamespace.name ) }.md)`; } ).join( '\n' ), ].join( '\n' ); } @@ -80,14 +80,14 @@ function generateNamespaceDocs( parsedNamespace ) { module.exports = function( parsedNamespaces, rootFolder ) { const tableOfContent = generateTableOfContent( parsedNamespaces ); fs.writeFileSync( - path.join( rootFolder, 'index.md' ), + path.join( rootFolder, 'README.md' ), tableOfContent ); Object.values( parsedNamespaces ).forEach( ( parsedNamespace ) => { const namespaceDocs = generateNamespaceDocs( parsedNamespace ); fs.writeFileSync( - path.join( rootFolder, lodash.kebabCase( parsedNamespace.name ) + '.md' ), + path.join( rootFolder, kebabCase( parsedNamespace.name ) + '.md' ), namespaceDocs ); } ); diff --git a/docs/tool/index.js b/docs/tool/index.js new file mode 100644 index 00000000000000..33f2331e402cd2 --- /dev/null +++ b/docs/tool/index.js @@ -0,0 +1,22 @@ +/** + * Node dependencies + */ +const fs = require( 'fs' ); + +/** + * Internal dependencies + */ +const config = require( './config' ); +const parser = require( './parser' ); +const generator = require( './generator' ); +const getManifest = require( './manifest' ); + +const parsedModules = parser( config.dataNamespaces ); +generator( parsedModules, config.dataDocsOutput ); +const rootManifest = require( config.rootManifest ); +const dataModuleManifest = getManifest( parsedModules ); + +fs.writeFileSync( + config.manifestOutput, + JSON.stringify( rootManifest.concat( dataModuleManifest ), undefined, '\t' ) +); diff --git a/docs/tool/manifest.js b/docs/tool/manifest.js new file mode 100644 index 00000000000000..65b3e522972ef8 --- /dev/null +++ b/docs/tool/manifest.js @@ -0,0 +1,30 @@ +/** + * Node dependencies + */ +const { kebabCase } = require( 'lodash' ); + +/** + * Generates the manifest for the given namespaces. + * + * @param {Object} parsedNamespaces Parsed Namespace Object. + * + * @return {Array} manifest. + */ +module.exports = function( parsedNamespaces ) { + return [ { + title: 'Data Package Reference', + slug: 'packages-data', + markdown_source: 'https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/data/README.md', + parent: 'reference', + } ].concat( + Object.values( parsedNamespaces ).map( ( parsedNamespace ) => { + const slug = kebabCase( parsedNamespace.name ); + return { + title: parsedNamespace.title, + slug: 'packages-data-' + slug, + markdown_source: 'https://raw.githubusercontent.com/WordPress/gutenberg/master/docs/data/' + slug + '.md', + parent: 'packages-data', + }; + } ) + ); +}; diff --git a/docs/data/tool/parser.js b/docs/tool/parser.js similarity index 94% rename from docs/data/tool/parser.js rename to docs/tool/parser.js index ab719d8f4d3dd0..234af0b252a8dc 100644 --- a/docs/data/tool/parser.js +++ b/docs/tool/parser.js @@ -6,7 +6,7 @@ const fs = require( 'fs' ); /** * External dependencies */ -const lodash = require( 'lodash' ); +const { last } = require( 'lodash' ); const espree = require( 'espree' ); const doctrine = require( 'doctrine' ); @@ -38,7 +38,7 @@ module.exports = function( config ) { node.leadingComments.length !== 0 ) { const docBlock = doctrine.parse( - lodash.last( node.leadingComments ).value, + last( node.leadingComments ).value, { unwrap: true, recoverable: true } ); const func = { diff --git a/package.json b/package.json index 6b0472320f8f2c..7aa357824d92e3 100644 --- a/package.json +++ b/package.json @@ -168,7 +168,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", + "docs:build": "node docs/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",