Skip to content

Commit

Permalink
feat(@lexical/website): Packages documentation automatic generation
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum committed Apr 26, 2024
1 parent 881258b commit 0a8ee26
Show file tree
Hide file tree
Showing 29 changed files with 52 additions and 149 deletions.
1 change: 1 addition & 0 deletions packages/lexical-website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.docusaurus
.cache-loader
/docs/api
/docs/packages

# Misc
.DS_Store
Expand Down
4 changes: 0 additions & 4 deletions packages/lexical-website/docs/packages/_category_.json

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-clipboard.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-code.md

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-dragon.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-file.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-hashtag.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-headless.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-history.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-html.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-link.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-list.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-mark.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-markdown.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-offset.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-overflow.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-plain-text.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-react.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-rich-text.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-selection.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-table.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-text.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-utils.md

This file was deleted.

6 changes: 0 additions & 6 deletions packages/lexical-website/docs/packages/lexical-yjs.md

This file was deleted.

7 changes: 0 additions & 7 deletions packages/lexical-website/docs/packages/lexical.md

This file was deleted.

7 changes: 7 additions & 0 deletions packages/lexical-website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
39 changes: 39 additions & 0 deletions packages/lexical-website/plugins/package-docs/index.js
Original file line number Diff line number Diff line change
@@ -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',
};
};
5 changes: 5 additions & 0 deletions packages/lexical/README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 0a8ee26

Please sign in to comment.