From 0a8ee268afae1f3a1359f2e27afdababb41844f5 Mon Sep 17 00:00:00 2001 From: Bob Ippolito Date: Thu, 25 Apr 2024 17:06:48 -0700 Subject: [PATCH] feat(@lexical/website): Packages documentation automatic generation --- packages/lexical-website/.gitignore | 1 + .../docs/packages/_category_.json | 4 -- .../docs/packages/lexical-clipboard.md | 6 --- .../docs/packages/lexical-code.md | 6 --- .../docs/packages/lexical-devtools-core.md | 6 --- .../docs/packages/lexical-dragon.md | 6 --- .../docs/packages/lexical-file.md | 6 --- .../docs/packages/lexical-hashtag.md | 6 --- .../docs/packages/lexical-headless.md | 6 --- .../docs/packages/lexical-history.md | 6 --- .../docs/packages/lexical-html.md | 6 --- .../docs/packages/lexical-link.md | 6 --- .../docs/packages/lexical-list.md | 6 --- .../docs/packages/lexical-mark.md | 6 --- .../docs/packages/lexical-markdown.md | 6 --- .../docs/packages/lexical-offset.md | 6 --- .../docs/packages/lexical-overflow.md | 6 --- .../docs/packages/lexical-plain-text.md | 6 --- .../docs/packages/lexical-react.md | 6 --- .../docs/packages/lexical-rich-text.md | 6 --- .../docs/packages/lexical-selection.md | 6 --- .../docs/packages/lexical-table.md | 6 --- .../docs/packages/lexical-text.md | 6 --- .../docs/packages/lexical-utils.md | 6 --- .../docs/packages/lexical-yjs.md | 6 --- .../lexical-website/docs/packages/lexical.md | 7 ---- packages/lexical-website/docusaurus.config.js | 7 ++++ .../plugins/package-docs/index.js | 39 +++++++++++++++++++ packages/lexical/README.md | 5 +++ 29 files changed, 52 insertions(+), 149 deletions(-) delete mode 100644 packages/lexical-website/docs/packages/_category_.json delete mode 100644 packages/lexical-website/docs/packages/lexical-clipboard.md delete mode 100644 packages/lexical-website/docs/packages/lexical-code.md delete mode 100644 packages/lexical-website/docs/packages/lexical-devtools-core.md delete mode 100644 packages/lexical-website/docs/packages/lexical-dragon.md delete mode 100644 packages/lexical-website/docs/packages/lexical-file.md delete mode 100644 packages/lexical-website/docs/packages/lexical-hashtag.md delete mode 100644 packages/lexical-website/docs/packages/lexical-headless.md delete mode 100644 packages/lexical-website/docs/packages/lexical-history.md delete mode 100644 packages/lexical-website/docs/packages/lexical-html.md delete mode 100644 packages/lexical-website/docs/packages/lexical-link.md delete mode 100644 packages/lexical-website/docs/packages/lexical-list.md delete mode 100644 packages/lexical-website/docs/packages/lexical-mark.md delete mode 100644 packages/lexical-website/docs/packages/lexical-markdown.md delete mode 100644 packages/lexical-website/docs/packages/lexical-offset.md delete mode 100644 packages/lexical-website/docs/packages/lexical-overflow.md delete mode 100644 packages/lexical-website/docs/packages/lexical-plain-text.md delete mode 100644 packages/lexical-website/docs/packages/lexical-react.md delete mode 100644 packages/lexical-website/docs/packages/lexical-rich-text.md delete mode 100644 packages/lexical-website/docs/packages/lexical-selection.md delete mode 100644 packages/lexical-website/docs/packages/lexical-table.md delete mode 100644 packages/lexical-website/docs/packages/lexical-text.md delete mode 100644 packages/lexical-website/docs/packages/lexical-utils.md delete mode 100644 packages/lexical-website/docs/packages/lexical-yjs.md delete mode 100644 packages/lexical-website/docs/packages/lexical.md create mode 100644 packages/lexical-website/plugins/package-docs/index.js diff --git a/packages/lexical-website/.gitignore b/packages/lexical-website/.gitignore index 5f2229121262..34291925ae0c 100644 --- a/packages/lexical-website/.gitignore +++ b/packages/lexical-website/.gitignore @@ -8,6 +8,7 @@ .docusaurus .cache-loader /docs/api +/docs/packages # Misc .DS_Store diff --git a/packages/lexical-website/docs/packages/_category_.json b/packages/lexical-website/docs/packages/_category_.json deleted file mode 100644 index 94ed42720de7..000000000000 --- a/packages/lexical-website/docs/packages/_category_.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "label": "Packages", - "position": 4 -} diff --git a/packages/lexical-website/docs/packages/lexical-clipboard.md b/packages/lexical-website/docs/packages/lexical-clipboard.md deleted file mode 100644 index b8ccd62108b2..000000000000 --- a/packages/lexical-website/docs/packages/lexical-clipboard.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/clipboard' ---- - -{@import ../../../lexical-clipboard/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-code.md b/packages/lexical-website/docs/packages/lexical-code.md deleted file mode 100644 index 059d41ca302f..000000000000 --- a/packages/lexical-website/docs/packages/lexical-code.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/code' ---- - -{@import ../../../lexical-code/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-devtools-core.md b/packages/lexical-website/docs/packages/lexical-devtools-core.md deleted file mode 100644 index e649f09270dd..000000000000 --- a/packages/lexical-website/docs/packages/lexical-devtools-core.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/devtools-core' ---- - -{@import ../../../lexical-devtools-core/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-dragon.md b/packages/lexical-website/docs/packages/lexical-dragon.md deleted file mode 100644 index 0f94bb0b9b6c..000000000000 --- a/packages/lexical-website/docs/packages/lexical-dragon.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/dragon' ---- - -{@import ../../../lexical-dragon/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-file.md b/packages/lexical-website/docs/packages/lexical-file.md deleted file mode 100644 index 83c5962a5c37..000000000000 --- a/packages/lexical-website/docs/packages/lexical-file.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/file' ---- - -{@import ../../../lexical-file/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-hashtag.md b/packages/lexical-website/docs/packages/lexical-hashtag.md deleted file mode 100644 index af135d6d6d5d..000000000000 --- a/packages/lexical-website/docs/packages/lexical-hashtag.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/hashtag' ---- - -{@import ../../../lexical-hashtag/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-headless.md b/packages/lexical-website/docs/packages/lexical-headless.md deleted file mode 100644 index 20c35591dfa8..000000000000 --- a/packages/lexical-website/docs/packages/lexical-headless.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/headless' ---- - -{@import ../../../lexical-headless/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-history.md b/packages/lexical-website/docs/packages/lexical-history.md deleted file mode 100644 index ac72a1524000..000000000000 --- a/packages/lexical-website/docs/packages/lexical-history.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/history' ---- - -{@import ../../../lexical-history/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-html.md b/packages/lexical-website/docs/packages/lexical-html.md deleted file mode 100644 index 0ebd9016399e..000000000000 --- a/packages/lexical-website/docs/packages/lexical-html.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/html' ---- - -{@import ../../../lexical-html/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-link.md b/packages/lexical-website/docs/packages/lexical-link.md deleted file mode 100644 index eb748f61c17e..000000000000 --- a/packages/lexical-website/docs/packages/lexical-link.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/link' ---- - -{@import ../../../lexical-link/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-list.md b/packages/lexical-website/docs/packages/lexical-list.md deleted file mode 100644 index f1bda7d938b8..000000000000 --- a/packages/lexical-website/docs/packages/lexical-list.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/list' ---- - -{@import ../../../lexical-list/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-mark.md b/packages/lexical-website/docs/packages/lexical-mark.md deleted file mode 100644 index 33607576a8b4..000000000000 --- a/packages/lexical-website/docs/packages/lexical-mark.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/mark' ---- - -{@import ../../../lexical-mark/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-markdown.md b/packages/lexical-website/docs/packages/lexical-markdown.md deleted file mode 100644 index 8354cc5c9f16..000000000000 --- a/packages/lexical-website/docs/packages/lexical-markdown.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/markdown' ---- - -{@import ../../../lexical-markdown/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-offset.md b/packages/lexical-website/docs/packages/lexical-offset.md deleted file mode 100644 index 44f1e2760015..000000000000 --- a/packages/lexical-website/docs/packages/lexical-offset.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/offset' ---- - -{@import ../../../lexical-offset/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-overflow.md b/packages/lexical-website/docs/packages/lexical-overflow.md deleted file mode 100644 index d79d1b213271..000000000000 --- a/packages/lexical-website/docs/packages/lexical-overflow.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/overflow' ---- - -{@import ../../../lexical-overflow/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-plain-text.md b/packages/lexical-website/docs/packages/lexical-plain-text.md deleted file mode 100644 index 28043e3af05d..000000000000 --- a/packages/lexical-website/docs/packages/lexical-plain-text.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/plain-text' ---- - -{@import ../../../lexical-plain-text/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-react.md b/packages/lexical-website/docs/packages/lexical-react.md deleted file mode 100644 index fd26ef088b6b..000000000000 --- a/packages/lexical-website/docs/packages/lexical-react.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/react' ---- - -{@import ../../../lexical-react/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-rich-text.md b/packages/lexical-website/docs/packages/lexical-rich-text.md deleted file mode 100644 index b38ef264a91c..000000000000 --- a/packages/lexical-website/docs/packages/lexical-rich-text.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/rich-text' ---- - -{@import ../../../lexical-rich-text/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-selection.md b/packages/lexical-website/docs/packages/lexical-selection.md deleted file mode 100644 index e0b47043c5a6..000000000000 --- a/packages/lexical-website/docs/packages/lexical-selection.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/selection' ---- - -{@import ../../../lexical-selection/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-table.md b/packages/lexical-website/docs/packages/lexical-table.md deleted file mode 100644 index 54c258f1e009..000000000000 --- a/packages/lexical-website/docs/packages/lexical-table.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/table' ---- - -{@import ../../../lexical-table/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-text.md b/packages/lexical-website/docs/packages/lexical-text.md deleted file mode 100644 index df9dce9d1943..000000000000 --- a/packages/lexical-website/docs/packages/lexical-text.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/text' ---- - -{@import ../../../lexical-text/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-utils.md b/packages/lexical-website/docs/packages/lexical-utils.md deleted file mode 100644 index 3363ea8d9ebb..000000000000 --- a/packages/lexical-website/docs/packages/lexical-utils.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/utils' ---- - -{@import ../../../lexical-utils/README.md} diff --git a/packages/lexical-website/docs/packages/lexical-yjs.md b/packages/lexical-website/docs/packages/lexical-yjs.md deleted file mode 100644 index 9fc76e814a74..000000000000 --- a/packages/lexical-website/docs/packages/lexical-yjs.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: '' -sidebar_label: '@lexical/yjs' ---- - -{@import ../../../lexical-yjs/README.md} diff --git a/packages/lexical-website/docs/packages/lexical.md b/packages/lexical-website/docs/packages/lexical.md deleted file mode 100644 index e03e7a472b92..000000000000 --- a/packages/lexical-website/docs/packages/lexical.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -sidebar_position: 1 ---- - -# lexical (core) - -This package contains the core library, including the Editor, EditorState, Selection, and core nodes. It also contains logic for the fundamental logic of the library, such as updates and DOM reconciliation. diff --git a/packages/lexical-website/docusaurus.config.js b/packages/lexical-website/docusaurus.config.js index cac524e91447..09ac53f9b0d5 100644 --- a/packages/lexical-website/docusaurus.config.js +++ b/packages/lexical-website/docusaurus.config.js @@ -207,6 +207,13 @@ const config = { onBrokenMarkdownLinks: 'throw', organizationName: 'facebook', plugins: [ + [ + './plugins/package-docs', + { + baseDir: path.resolve(__dirname, '..'), + targetDir: path.resolve(__dirname, 'docs/packages'), + }, + ], './plugins/webpack-buffer', ['docusaurus-plugin-typedoc', docusaurusPluginTypedocConfig], async function tailwindcss() { diff --git a/packages/lexical-website/plugins/package-docs/index.js b/packages/lexical-website/plugins/package-docs/index.js new file mode 100644 index 000000000000..a39e1db7f533 --- /dev/null +++ b/packages/lexical-website/plugins/package-docs/index.js @@ -0,0 +1,39 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + +'use strict'; + +const fs = require('fs'); +const path = require('path'); + +module.exports = async function (context, options) { + const folders = fs + .readdirSync(options.baseDir, {withFileTypes: true}) + .filter( + (dirent) => + dirent.isDirectory() && + dirent.name !== 'lexical-website' && + fs.existsSync(path.resolve(options.baseDir, dirent.name, 'README.md')), + ) + .map((dirent) => [ + dirent.name, + path.resolve(options.baseDir, dirent.name, 'README.md'), + ]); + + fs.mkdirSync(options.targetDir, {recursive: true}); + for (const [folderName, srcPath] of folders) { + fs.copyFileSync( + srcPath, + path.resolve(options.targetDir, `${folderName}.md`), + ); + } + + return { + name: 'package-docs', + }; +}; diff --git a/packages/lexical/README.md b/packages/lexical/README.md index 57efd413fa91..4a420180122b 100644 --- a/packages/lexical/README.md +++ b/packages/lexical/README.md @@ -1,3 +1,8 @@ +--- +sidebar_position: 1 +sidebar_label: lexical (core) +--- + # `lexical` [![See API Documentation](https://lexical.dev/img/see-api-documentation.svg)](https://lexical.dev/docs/api/modules/lexical)