diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5c21980f7372a3..59958bc68a3594 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -55,7 +55,6 @@ # Tooling /bin @ntwb @nerrad @ajitbohra /bin/api-docs @ntwb @nerrad @ajitbohra -/docs/tool @ajitbohra /packages/babel-plugin-import-jsx-pragma @ntwb @nerrad @ajitbohra /packages/babel-plugin-makepot @ntwb @nerrad @ajitbohra /packages/babel-preset-default @ntwb @nerrad @ajitbohra diff --git a/docs/contributors/folder-structure.md b/docs/contributors/folder-structure.md index 0cfbc76bf13db9..fd61ce05515cd0 100644 --- a/docs/contributors/folder-structure.md +++ b/docs/contributors/folder-structure.md @@ -59,8 +59,8 @@ The following snippet explains how the Gutenberg repository is structured omitti ├── .github/* │ Config of the different GitHub features (issues and PR templates, CI, owners). │ - ├── tools/api-docs - │ Tool/script used to generate the API Docs. + ├── tools/docs + │ Tools for generating Gutenberg documentation (manifest generator, API docs, block library list, component docs, theme reference). │ ├── tools/build-scripts │ Build orchestration scripts for the Gutenberg monorepo (@wordpress/build-scripts). @@ -68,9 +68,6 @@ The following snippet explains how the Gutenberg repository is structured omitti ├── tools/release │ CLI tool used to perform the Gutenberg plugin release and the npm releases as well. │ - ├── docs/tool - │ Tool used to generate the Block editor handbook's markdown pages. - │ ├── docs/*.md │ Set of documentation pages composing the [Block editor handbook](https://developer.wordpress.org/block-editor/). │ diff --git a/package-lock.json b/package-lock.json index 80775964404fee..ad2499537c76f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,6 @@ "babel-jest": "29.7.0", "babel-loader": "9.2.1", "babel-plugin-inline-json-import": "0.3.2", - "change-case": "4.1.2", "concurrently": "3.5.0", "cross-env": "7.0.3", "css-loader": "^6.2.0", @@ -20626,10 +20625,6 @@ "resolved": "packages/annotations", "link": true }, - "node_modules/@wordpress/api-docs-generator": { - "resolved": "tools/api-docs", - "link": true - }, "node_modules/@wordpress/api-fetch": { "resolved": "packages/api-fetch", "link": true @@ -20794,6 +20789,10 @@ "resolved": "packages/docgen", "link": true }, + "node_modules/@wordpress/docs-tools": { + "resolved": "tools/docs", + "link": true + }, "node_modules/@wordpress/dom": { "resolved": "packages/dom", "link": true @@ -64963,22 +64962,6 @@ "timezone-mock": "^1.3.6" } }, - "tools/api-docs": { - "name": "@wordpress/api-docs-generator", - "version": "0.0.0", - "license": "GPL-2.0-or-later", - "devDependencies": { - "@apidevtools/json-schema-ref-parser": "^11.6.4", - "@babel/core": "^7.25.7", - "chalk": "^4.1.1", - "comment-parser": "^1.1.1", - "execa": "^4.0.2", - "fast-glob": "^3.2.7", - "glob": "^7.1.2", - "json2md": "^2.0.1", - "react-docgen-typescript": "^2.2.2" - } - }, "tools/build-scripts": { "name": "@wordpress/build-scripts", "version": "0.0.0", @@ -64994,6 +64977,23 @@ "source-map": "^0.6.1" } }, + "tools/docs": { + "name": "@wordpress/docs-tools", + "version": "0.0.0", + "license": "GPL-2.0-or-later", + "devDependencies": { + "@apidevtools/json-schema-ref-parser": "^11.6.4", + "@babel/core": "^7.25.7", + "chalk": "^4.1.1", + "change-case": "4.1.2", + "comment-parser": "^1.1.1", + "execa": "^4.0.2", + "fast-glob": "^3.2.7", + "glob": "^7.1.2", + "json2md": "^2.0.1", + "react-docgen-typescript": "^2.2.2" + } + }, "tools/eslint": { "name": "@wordpress/eslint-tools", "version": "1.0.0", diff --git a/package.json b/package.json index d19cca9189a4ee..85ef43d5904c77 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ "babel-jest": "29.7.0", "babel-loader": "9.2.1", "babel-plugin-inline-json-import": "0.3.2", - "change-case": "4.1.2", "concurrently": "3.5.0", "cross-env": "7.0.3", "css-loader": "^6.2.0", @@ -104,13 +103,13 @@ "component-usage-stats": "node ./node_modules/react-scanner/bin/react-scanner -c ./react-scanner.config.js", "dev": "npm run --workspace @wordpress/build-scripts dev --", "distclean": "git clean --force -d -X", - "docs:api-ref": "npm run --workspace @wordpress/api-docs-generator docs:api-ref", - "docs:blocks": "npm run --workspace @wordpress/api-docs-generator docs:blocks", + "docs:api-ref": "npm run --workspace @wordpress/docs-tools docs:api-ref --", + "docs:blocks": "npm run --workspace @wordpress/docs-tools docs:blocks --", "docs:build": "npm-run-all docs:components docs:gen docs:blocks docs:api-ref docs:theme-ref", - "docs:check-api-docs-unstaged": "node ./tools/api-docs/are-api-docs-unstaged.js", - "docs:components": "npm run --workspace @wordpress/api-docs-generator docs:components", - "docs:gen": "node ./docs/tool/index.js", - "docs:theme-ref": "npm run --workspace tools/api-docs docs:theme-ref", + "docs:check-api-docs-unstaged": "npm run --workspace @wordpress/docs-tools docs:check-api-docs-unstaged --", + "docs:components": "npm run --workspace @wordpress/docs-tools docs:components --", + "docs:gen": "npm run --workspace @wordpress/docs-tools docs:gen --", + "docs:theme-ref": "npm run --workspace @wordpress/docs-tools docs:theme-ref --", "env": "wp-env", "fixtures:clean": "rimraf --glob \"test/integration/fixtures/blocks/*.{json,serialized.html}\"", "fixtures:generate": "cross-env GENERATE_MISSING_FIXTURES=y npm run test:unit -- test/integration/full-content/ && npm run format test/integration/fixtures/blocks/*.json", @@ -205,14 +204,14 @@ "packages/*/package.json": [ "wp-scripts lint-pkg-json" ], - "{docs/{toc.json,tool/*.js},packages/{*/README.md,components/src/*/**/README.md}}": [ - "node ./docs/tool/index.js" + "{docs/toc.json,tools/docs/*.cjs,packages/{*/README.md,components/src/*/**/README.md}}": [ + "npm run docs:gen" ], "packages/**/*.{js,ts,tsx,json}": [ "npm run docs:api-ref", "npm run docs:blocks", "npm run docs:theme-ref", - "node ./tools/api-docs/are-api-docs-unstaged.js" + "npm run docs:check-api-docs-unstaged" ], "packages/icons/src/library/*": [ "npm run -w packages/icons build" diff --git a/tools/api-docs/are-api-docs-unstaged.js b/tools/docs/are-api-docs-unstaged.js similarity index 77% rename from tools/api-docs/are-api-docs-unstaged.js rename to tools/docs/are-api-docs-unstaged.js index 18e0ec4fb469d0..4ab66b4f5d5789 100644 --- a/tools/api-docs/are-api-docs-unstaged.js +++ b/tools/docs/are-api-docs-unstaged.js @@ -3,18 +3,22 @@ /** * External dependencies */ -const { extname } = require( 'path' ); +const { extname, join, resolve } = require( 'path' ); const { readFile } = require( 'fs' ).promises; const execSync = require( 'child_process' ).execSync; const chalk = require( 'chalk' ); +const ROOT_DIR = resolve( __dirname, '../..' ); + const getUnstagedFiles = () => - execSync( 'git diff --name-only', { encoding: 'utf8' } ) + execSync( 'git diff --name-only', { encoding: 'utf8', cwd: ROOT_DIR } ) .split( '\n' ) .filter( Boolean ); const fileHasToken = async ( file ) => - ( await readFile( file, 'utf8' ) ).includes( '