From d849383f502ccdd3a4f9a4f912bafb81260dfdc7 Mon Sep 17 00:00:00 2001 From: atanasster Date: Thu, 25 Jun 2020 12:41:12 -0400 Subject: [PATCH] feat: ts-md in own package --- core/config/package.json | 3 +- core/core/README.md | 71 ++++++------ core/core/package.json | 3 +- core/instrument/package.json | 3 +- core/loader/package.json | 3 +- core/store/package.json | 3 +- core/webpack-compile/package.json | 3 +- core/webpack-configs/package.json | 3 +- .../gatsby-theme-stories/package.json | 3 +- integrations/storybook/package.json | 3 +- misc/storybook-custom-docs/README.md | 103 ++++++++++++++++++ misc/storybook-custom-docs/package.json | 3 +- misc/ts-markdown/.eslintignore | 1 + misc/ts-markdown/LICENSE.md | 21 ++++ misc/ts-markdown/README.md | 17 +++ misc/ts-markdown/bin/index.js | 3 + misc/ts-markdown/package.json | 55 ++++++++++ misc/ts-markdown/rollup.config.js | 5 + .../ts-markdown/src}/blocks/props-table.ts | 0 .../ts-markdown/src}/common/package-info.ts | 0 .../ts-markdown/src}/common/types.ts | 0 .../ts-markdown/src}/common/utils.ts | 0 misc/ts-markdown/src/index.ts | 42 +++++++ .../src}/overview-sections/insert-overview.ts | 0 .../insert-react-docgen-typescript.ts | 0 .../ts-markdown/src}/tsdoc/extract-tsdoc.ts | 1 + .../ts-markdown/src}/tsdoc/insert-tsdoc.ts | 0 misc/ts-markdown/tsconfig.json | 16 +++ package.json | 6 +- plugins/axe-plugin/package.json | 3 +- .../react-docgen-typescript/package.json | 3 +- props-info/react-docgen/package.json | 3 +- scripts/docs.ts | 18 --- ui/app/package.json | 3 +- ui/blocks/package.json | 3 +- ui/components/package.json | 3 +- ui/editors/package.json | 3 +- ui/pages/package.json | 3 +- yarn.lock | 2 +- 39 files changed, 339 insertions(+), 76 deletions(-) create mode 100644 misc/ts-markdown/.eslintignore create mode 100644 misc/ts-markdown/LICENSE.md create mode 100644 misc/ts-markdown/README.md create mode 100755 misc/ts-markdown/bin/index.js create mode 100644 misc/ts-markdown/package.json create mode 100644 misc/ts-markdown/rollup.config.js rename {scripts => misc/ts-markdown/src}/blocks/props-table.ts (100%) rename {scripts => misc/ts-markdown/src}/common/package-info.ts (100%) rename {scripts => misc/ts-markdown/src}/common/types.ts (100%) rename {scripts => misc/ts-markdown/src}/common/utils.ts (100%) create mode 100644 misc/ts-markdown/src/index.ts rename {scripts => misc/ts-markdown/src}/overview-sections/insert-overview.ts (100%) rename {scripts => misc/ts-markdown/src}/react-docgen-typescript/insert-react-docgen-typescript.ts (100%) rename {scripts => misc/ts-markdown/src}/tsdoc/extract-tsdoc.ts (99%) rename {scripts => misc/ts-markdown/src}/tsdoc/insert-tsdoc.ts (100%) create mode 100644 misc/ts-markdown/tsconfig.json delete mode 100644 scripts/docs.ts diff --git a/core/config/package.json b/core/config/package.json index 5c61da5ec..935dc6fcb 100644 --- a/core/config/package.json +++ b/core/config/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\" }' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -36,6 +36,7 @@ "yargs": "^15.3.1" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/faker": "^4.1.9", "@types/jest": "^25.1.2", "cross-env": "^5.2.1", diff --git a/core/core/README.md b/core/core/README.md index c29973e48..2fbe97adb 100644 --- a/core/core/README.md +++ b/core/core/README.md @@ -939,7 +939,7 @@ _defined in [@component-controls/core/src/utility.ts](https://github.com/ccontro global configuration used at build time stored in a file named main.js/main.ts -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L86)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L87)_ @@ -955,7 +955,7 @@ _defined in [@component-controls/core/src/configuration.ts](https://github.com/c ## PageConfiguration -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L31)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L32)_ @@ -976,32 +976,33 @@ _defined in [@component-controls/core/src/configuration.ts](https://github.com/c global configuration used at build time stored in a file named main.js/main.ts -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L113)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L114)_ ### properties -| Name | Type | Description | -| ----------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `author` | string | author: Default is "@component-controls" | -| `decorators` | [StoryRenderFn](#storyrenderfn)\[] | story decorator functions - used to wrap stories example: \[story => <ThemeProvider>{story()}</ThemeProvider>] | -| `pages` | [PagesConfiguration](#pagesconfiguration) | page types configurations | -| `siteDescription` | string | site description. siteDescription: Default is "Component controls stories. Write your components documentation with MDX and JSX. Design, develop, test and review in a single site." | -| `siteHeadline` | string | Site headline. Default is "Component controls gatsby" | -| `siteImage` | string | link to site image | -| `siteLanguage` | string | site language, Deault is "en" | -| `siteTitle` | string | standalone site title. Default is "Component controls" | -| `siteTitleAlt` | string | site alt for images. Default is "Component controls - https://github.com/ccontrols/component-controls" | -| `siteUrl` | string | Deployed site url. Default is "https://component-controls-gatsby.netlify.app" | -| `storySort` | **function** (`a`\*: string, `b`\*: string): number; | story sorting function | -| `theme` | \[key: string]: any | theme-ui theme configuration | +| Name | Type | Description | +| ----------------- | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `author` | string | author: Default is "@component-controls" | +| `decorators` | [StoryRenderFn](#storyrenderfn)\[] | story decorator functions - used to wrap stories example: \[story => <ThemeProvider>{story()}</ThemeProvider>] | +| `pages` | [PagesConfiguration](#pagesconfiguration) | page types configurations | +| `siteDescription` | string | site description. siteDescription: Default is "Component controls stories. Write your components documentation with MDX and JSX. Design, develop, test and review in a single site." | +| `siteHeadline` | string | Site headline. Default is "Component controls gatsby" | +| `siteImage` | string | link to site image | +| `siteLanguage` | string | site language, Deault is "en" | +| `siteTitle` | string | standalone site title. Default is "Component controls" | +| `siteTitleAlt` | string | site alt for images. Default is "Component controls - https://github.com/ccontrols/component-controls" | +| `siteUrl` | string | Deployed site url. Default is "https://component-controls-gatsby.netlify.app" | +| `storySort` | **function** (`a`\*: string, `b`\*: string): number; | story sorting function | +| `theme` | \[key: string]: any | theme-ui theme configuration | +| `toolbar` | left side toolbar items**left**: [ActionItems](#actionitems)right side toolbar items**right**: [ActionItems](#actionitems) | custom toolbar items | ## TabConfiguration story type pages can have multiple tabs with separate page configurations. -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L8)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L9)_ @@ -1016,19 +1017,19 @@ _defined in [@component-controls/core/src/configuration.ts](https://github.com/c ## PageTabs -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L27)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L28)_ [TabConfiguration](#tabconfiguration)\[] ## PageType -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L29)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L30)_ 'story' | 'blog' | 'page' | 'tags' | 'author' ## PagesConfiguration -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L68)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L69)_ Record< @@ -1042,7 +1043,7 @@ Record< ## PagesOnlyRoutes -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L76)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L77)_ Record< @@ -1061,7 +1062,7 @@ Record< ## RunConfiguration -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L174)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L190)_ ### properties @@ -1072,13 +1073,13 @@ _defined in [@component-controls/core/src/configuration.ts](https://github.com/c ## WebpackConfig -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L74)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L75)_ [WebpackConfiguration](#webpackconfiguration) \| [WebpackConfigFn](#webpackconfigfn) ## WebpackConfigFn -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L70)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L71)_ **function** (`config`\*: [WebpackConfiguration](#webpackconfiguration), `options`: any): [WebpackConfiguration](#webpackconfiguration); @@ -1092,7 +1093,7 @@ _defined in [@component-controls/core/src/configuration.ts](https://github.com/c ## defaultBuildConfig -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L215)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L231)_ @@ -1105,7 +1106,7 @@ _defined in [@component-controls/core/src/configuration.ts](https://github.com/c ## defaultRunConfig -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L177)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L193)_ @@ -1140,13 +1141,13 @@ _defined in [@component-controls/core/src/utility.ts](https://github.com/ccontro ## PageType -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L29)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L30)_ 'story' | 'blog' | 'page' | 'tags' | 'author' ## RunConfiguration -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L174)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L190)_ ### properties @@ -1166,7 +1167,7 @@ _defined in [@component-controls/core/src/stories.ts](https://github.com/ccontro ## PagesOnlyRoutes -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L76)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L77)_ Record< @@ -1211,19 +1212,19 @@ string ## WebpackConfig -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L74)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L75)_ [WebpackConfiguration](#webpackconfiguration) \| [WebpackConfigFn](#webpackconfigfn) ## PageTabs -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L27)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L28)_ [TabConfiguration](#tabconfiguration)\[] ## PagesConfiguration -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L68)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L69)_ Record< @@ -1237,7 +1238,7 @@ Record< ## WebpackConfigFn -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L70)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L71)_ **function** (`config`\*: [WebpackConfiguration](#webpackconfiguration), `options`: any): [WebpackConfiguration](#webpackconfiguration); @@ -1251,7 +1252,7 @@ _defined in [@component-controls/core/src/configuration.ts](https://github.com/c ## PageType -_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L29)_ +_defined in [@component-controls/core/src/configuration.ts](https://github.com/ccontrols/component-controls/tree/master/core/core/src/configuration.ts#L30)_ 'story' | 'blog' | 'page' | 'tags' | 'author' diff --git a/core/core/package.json b/core/core/package.json index 6d39d6bc3..ec638c38c 100644 --- a/core/core/package.json +++ b/core/core/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -38,6 +38,7 @@ "typescript": "^3.8.3" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/faker": "^4.1.9", "@types/jest": "^25.1.2", "cross-env": "^5.2.1", diff --git a/core/instrument/package.json b/core/instrument/package.json index d46dcac1e..7c82dd534 100644 --- a/core/instrument/package.json +++ b/core/instrument/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -49,6 +49,7 @@ "typescript": "^3.8.3" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@babel/types": "^7.9.0", "@rollup/plugin-node-resolve": "^7.1.1", "@types/find-cache-dir": "^3.2.0", diff --git a/core/loader/package.json b/core/loader/package.json index e9a9227a1..27183feca 100644 --- a/core/loader/package.json +++ b/core/loader/package.json @@ -18,7 +18,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\" }' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -46,6 +46,7 @@ "webpack": "^4.41.6" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/jest": "^25.1.2", "@types/loader-utils": "^1.1.3", "cross-env": "^5.2.1", diff --git a/core/store/package.json b/core/store/package.json index 97256fea4..861bcd878 100644 --- a/core/store/package.json +++ b/core/store/package.json @@ -19,7 +19,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -43,6 +43,7 @@ "typescript": "^3.8.3" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/jest": "^25.1.2", "@types/webpack-env": "^1.15.1", "cross-env": "^5.2.1", diff --git a/core/webpack-compile/package.json b/core/webpack-compile/package.json index e84cf2ccd..8511b3785 100644 --- a/core/webpack-compile/package.json +++ b/core/webpack-compile/package.json @@ -15,7 +15,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\" }' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -39,6 +39,7 @@ "webpack": "^4.43.0" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/jest": "^25.1.2", "@types/memory-fs": "^0.3.2", "cross-env": "^5.2.1", diff --git a/core/webpack-configs/package.json b/core/webpack-configs/package.json index 8776c92f2..234b8a1d7 100644 --- a/core/webpack-configs/package.json +++ b/core/webpack-configs/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\" }' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -37,6 +37,7 @@ }, "devDependencies": { "@babel/preset-env": "^7.9.0", + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/jest": "^25.1.2", "cross-env": "^5.2.1", "eslint": "^6.5.1", diff --git a/integrations/gatsby-theme-stories/package.json b/integrations/gatsby-theme-stories/package.json index cfd6cd837..2690cfd59 100644 --- a/integrations/gatsby-theme-stories/package.json +++ b/integrations/gatsby-theme-stories/package.json @@ -19,7 +19,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -50,6 +50,7 @@ "theme-ui": "next" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "typescript": "^3.8.3" }, "peerDependencies": { diff --git a/integrations/storybook/package.json b/integrations/storybook/package.json index 0c8acc257..e350effb0 100644 --- a/integrations/storybook/package.json +++ b/integrations/storybook/package.json @@ -18,7 +18,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -53,6 +53,7 @@ "typescript": "^3.8.3" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@storybook/addons": "next", "@storybook/api": "next", "@storybook/client-api": "next", diff --git a/misc/storybook-custom-docs/README.md b/misc/storybook-custom-docs/README.md index 861c62d8a..24b7bc4b4 100644 --- a/misc/storybook-custom-docs/README.md +++ b/misc/storybook-custom-docs/README.md @@ -10,6 +10,16 @@ - [Simple page](#simple-page) - [Render story](#render-story) - [API](#api) + - [globalStoryId](#globalstoryid) + - [getCurrentStoryId](#getcurrentstoryid) + - [getGlobalOptions](#getglobaloptions) + - [getGlobalStoryId](#getglobalstoryid) + - [useContext](#usecontext) + - [useStoryId](#usestoryid) + - [CustomPageDef](#custompagedef) + - [CustomPageRenderFnParams](#custompagerenderfnparams) + - [CustomPageRenderFn](#custompagerenderfn) + - [UPDATE_STORY_CONTEXT](#update_story_context) # In action @@ -120,4 +130,97 @@ export default { +## globalStoryId + +_defined in [@component-controls/storybook-custom-docs/src/index.tsx](https://github.com/ccontrols/component-controls/tree/master/misc/storybook-custom-docs/src/index.tsx#L38)_ + + + +## getCurrentStoryId + +function returning the current story id + +_defined in [@component-controls/storybook-custom-docs/src/index.tsx](https://github.com/ccontrols/component-controls/tree/master/misc/storybook-custom-docs/src/index.tsx#L25)_ + +**function** getCurrentStoryId(): string | undefined; + +## getGlobalOptions + +function returning the global options +parameters and decorators + +_defined in [@component-controls/storybook-custom-docs/src/index.tsx](https://github.com/ccontrols/component-controls/tree/master/misc/storybook-custom-docs/src/index.tsx#L11)_ + +**function** getGlobalOptions(): any; + +## getGlobalStoryId + +_defined in [@component-controls/storybook-custom-docs/src/index.tsx](https://github.com/ccontrols/component-controls/tree/master/misc/storybook-custom-docs/src/index.tsx#L39)_ + +**function** getGlobalStoryId(): string; + +## useContext + +React hook - returns a context similar (but not identical) that can be used as an input attribute to \`<DocsContainer />\` + +_defined in [@component-controls/storybook-custom-docs/src/index.tsx](https://github.com/ccontrols/component-controls/tree/master/misc/storybook-custom-docs/src/index.tsx#L72)_ + +**function** useContext(): any; + +## useStoryId + +React hook hook that tracks the changes to the current story and returns it's id + +_defined in [@component-controls/storybook-custom-docs/src/index.tsx](https://github.com/ccontrols/component-controls/tree/master/misc/storybook-custom-docs/src/index.tsx#L50)_ + +**function** useStoryId(): string; + +## CustomPageDef + +_defined in [@component-controls/storybook-custom-docs/src/types.ts](https://github.com/ccontrols/component-controls/tree/master/misc/storybook-custom-docs/src/types.ts#L29)_ + + + +### properties + +| Name | Type | Description | +| --------- | ----------------------------------------- | ------------------------------ | +| `key*` | string | key used for router navigation | +| `render*` | [CustomPageRenderFn](#custompagerenderfn) | react render function. | +| `title*` | string | title of the page's tab | + +## CustomPageRenderFnParams + +Custom page default export +example: + +_defined in [@component-controls/storybook-custom-docs/src/types.ts](https://github.com/ccontrols/component-controls/tree/master/misc/storybook-custom-docs/src/types.ts#L18)_ + + + +### properties + +| Name | Type | Description | +| --------- | ------- | -------------------------------------------- | +| `active*` | boolean | is the page active (visible) or not (hidden) | + +## CustomPageRenderFn + +_defined in [@component-controls/storybook-custom-docs/src/types.ts](https://github.com/ccontrols/component-controls/tree/master/misc/storybook-custom-docs/src/types.ts#L25)_ + +**function** (`params`\*: [CustomPageRenderFnParams](#custompagerenderfnparams)): [React.ReactNode](#react.reactnode); + +### parameters + +| Name | Type | Description | +| --------- | ----------------------------------------------------- | ----------- | +| `params*` | [CustomPageRenderFnParams](#custompagerenderfnparams) | | +| `returns` | [React.ReactNode](#react.reactnode) | | + +## UPDATE_STORY_CONTEXT + +_defined in [@component-controls/storybook-custom-docs/src/types.ts](https://github.com/ccontrols/component-controls/tree/master/misc/storybook-custom-docs/src/types.ts#L51)_ + + + diff --git a/misc/storybook-custom-docs/package.json b/misc/storybook-custom-docs/package.json index e9dea237a..a666b24ab 100644 --- a/misc/storybook-custom-docs/package.json +++ b/misc/storybook-custom-docs/package.json @@ -18,7 +18,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -39,6 +39,7 @@ "react-dom": "^16.13.1" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@storybook/addons": "next", "@storybook/api": "next", "@storybook/client-api": "next", diff --git a/misc/ts-markdown/.eslintignore b/misc/ts-markdown/.eslintignore new file mode 100644 index 000000000..53c37a166 --- /dev/null +++ b/misc/ts-markdown/.eslintignore @@ -0,0 +1 @@ +dist \ No newline at end of file diff --git a/misc/ts-markdown/LICENSE.md b/misc/ts-markdown/LICENSE.md new file mode 100644 index 000000000..a64cf9401 --- /dev/null +++ b/misc/ts-markdown/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Atanas Stoyanov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/misc/ts-markdown/README.md b/misc/ts-markdown/README.md new file mode 100644 index 000000000..a1680e9d9 --- /dev/null +++ b/misc/ts-markdown/README.md @@ -0,0 +1,17 @@ +# Table of contents + +- [Overview](#overview) +- [Getting Started](#getting-started) + - [Install](#install) + +# Overview + +Markdown documentation generator/enhancer tailored mostly for typescript and react typescript projects + +# Getting Started + +## Install + +```sh +yarn add @component-controls/ts-markdown-docs --dev +``` diff --git a/misc/ts-markdown/bin/index.js b/misc/ts-markdown/bin/index.js new file mode 100755 index 000000000..6161119a1 --- /dev/null +++ b/misc/ts-markdown/bin/index.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node +const run = require('../dist/index.js'); +run(); diff --git a/misc/ts-markdown/package.json b/misc/ts-markdown/package.json new file mode 100644 index 000000000..99fd5ebc8 --- /dev/null +++ b/misc/ts-markdown/package.json @@ -0,0 +1,55 @@ +{ + "name": "@component-controls/ts-markdown-docs", + "version": "1.3.0", + "description": "Typescript documentation generator for markdown files", + "keywords": [ + "markdown", + "typescript", + "readme" + ], + "main": "bin/index.js", + "files": [ + "dist/", + "package.json", + "README.md" + ], + "scripts": { + "build": "yarn cross-env NODE_ENV=production rollup -c", + "dev": "yarn cross-env NODE_ENV=development rollup -cw", + "docs": "node .", + "fix": "yarn lint --fix", + "lint": "yarn eslint . --ext mdx,ts,tsx", + "prepare": "yarn build", + "test": "yarn jest --passWithNoTests" + }, + "homepage": "https://github.com/ccontrols/component-controls", + "bugs": { + "url": "https://github.com/ccontrols/component-controls/issues" + }, + "bin": { + "ts-md": "./bin/index.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/ccontrols/component-controls.git", + "directory": "misc/ts-markdown" + }, + "license": "MIT", + "dependencies": { + "chalk": "^4.0.0", + "react-docgen-typescript": "^1.16.1", + "remark": "^11.0.2", + "remark-toc": "^7.0.0", + "typedoc": "^0.17.7", + "typescript": "^3.8.3", + "unified": "^9.0.0", + "yargs": "^15.3.1" + }, + "publishConfig": { + "access": "public" + }, + "authors": [ + "Atanas Stoyanov" + ], + "gitHead": "c5145d66c6b8a355839e53c3bca97fd361ce9377" +} diff --git a/misc/ts-markdown/rollup.config.js b/misc/ts-markdown/rollup.config.js new file mode 100644 index 000000000..ba1c61c86 --- /dev/null +++ b/misc/ts-markdown/rollup.config.js @@ -0,0 +1,5 @@ +import { config } from '../../rollup-config'; + +export default config({ + input: ['./src/index.ts'], +}); diff --git a/scripts/blocks/props-table.ts b/misc/ts-markdown/src/blocks/props-table.ts similarity index 100% rename from scripts/blocks/props-table.ts rename to misc/ts-markdown/src/blocks/props-table.ts diff --git a/scripts/common/package-info.ts b/misc/ts-markdown/src/common/package-info.ts similarity index 100% rename from scripts/common/package-info.ts rename to misc/ts-markdown/src/common/package-info.ts diff --git a/scripts/common/types.ts b/misc/ts-markdown/src/common/types.ts similarity index 100% rename from scripts/common/types.ts rename to misc/ts-markdown/src/common/types.ts diff --git a/scripts/common/utils.ts b/misc/ts-markdown/src/common/utils.ts similarity index 100% rename from scripts/common/utils.ts rename to misc/ts-markdown/src/common/utils.ts diff --git a/misc/ts-markdown/src/index.ts b/misc/ts-markdown/src/index.ts new file mode 100644 index 000000000..c6a1c5da9 --- /dev/null +++ b/misc/ts-markdown/src/index.ts @@ -0,0 +1,42 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import * as chalk from 'chalk'; +import * as yargs from 'yargs'; +import remark from 'remark'; +import toc from 'remark-toc'; +import { insertOverview } from './overview-sections/insert-overview'; +import { insertTSDoc } from './tsdoc/insert-tsdoc'; +import { insertReactDocgenTypescript } from './react-docgen-typescript/insert-react-docgen-typescript'; + +export default () => { + const options = yargs + .usage('ts-md -f ') + .option('f', { + alias: 'file', + describe: 'Input file name', + type: 'string', + }) + .option('t', { + alias: 'toc', + describe: 'Table of content', + type: 'boolean', + }).argv; + const fileName: string = (options.file as string) || 'README.md'; + const useToc: boolean = + typeof options.toc !== 'undefined' ? (options.toc as boolean) : true; + console.log('processing file:', chalk.red(path.resolve(fileName))); + let r = remark() + .use(insertReactDocgenTypescript) + .use(insertTSDoc) + .use(insertOverview); + if (useToc) { + r = r.use(toc, { tight: true }); + } + + r.process(fs.readFileSync(fileName, 'utf8'), function(err, file) { + if (err) { + throw err; + } + fs.writeFileSync(fileName, String(file)); + }); +}; diff --git a/scripts/overview-sections/insert-overview.ts b/misc/ts-markdown/src/overview-sections/insert-overview.ts similarity index 100% rename from scripts/overview-sections/insert-overview.ts rename to misc/ts-markdown/src/overview-sections/insert-overview.ts diff --git a/scripts/react-docgen-typescript/insert-react-docgen-typescript.ts b/misc/ts-markdown/src/react-docgen-typescript/insert-react-docgen-typescript.ts similarity index 100% rename from scripts/react-docgen-typescript/insert-react-docgen-typescript.ts rename to misc/ts-markdown/src/react-docgen-typescript/insert-react-docgen-typescript.ts diff --git a/scripts/tsdoc/extract-tsdoc.ts b/misc/ts-markdown/src/tsdoc/extract-tsdoc.ts similarity index 99% rename from scripts/tsdoc/extract-tsdoc.ts rename to misc/ts-markdown/src/tsdoc/extract-tsdoc.ts index 7d6c6e569..2fe93feba 100644 --- a/scripts/tsdoc/extract-tsdoc.ts +++ b/misc/ts-markdown/src/tsdoc/extract-tsdoc.ts @@ -20,6 +20,7 @@ app.bootstrap({ includeDeclarations: true, excludeExternals: true, excludePrivate: true, + esModuleInterop: true, }); export const extractTSDoc = ( diff --git a/scripts/tsdoc/insert-tsdoc.ts b/misc/ts-markdown/src/tsdoc/insert-tsdoc.ts similarity index 100% rename from scripts/tsdoc/insert-tsdoc.ts rename to misc/ts-markdown/src/tsdoc/insert-tsdoc.ts diff --git a/misc/ts-markdown/tsconfig.json b/misc/ts-markdown/tsconfig.json new file mode 100644 index 000000000..d0bae71d4 --- /dev/null +++ b/misc/ts-markdown/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "esModuleInterop": true, + "module": "esnext", + "declaration": true, + "resolveJsonModule": true, + "sourceMap": false, + "outDir": "./dist", + "rootDir": "./src", + "baseUrl": "./", + "typeRoots": ["../../node_modules/@types", "node_modules/@types"] + }, + "include": ["src/**/*"], + "exclude": ["node_modules/**"] +} \ No newline at end of file diff --git a/package.json b/package.json index 9a8e9bbb1..d2a100176 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "scripts": { "bootstrap": "lerna bootstrap", "clean": "lerna clean && rm -rf node_modules", - "docs": "lerna run docs && ts-node -O '{\"module\": \"commonjs\"}' ./scripts/docs.ts", + "docs": "lerna run docs && ts-md", "packages": "yarn fix && yarn lint && yarn build && yarn test", "fix": "lerna run --parallel fix && echo", "startup": "yarn bootstrap && yarn build && yarn dev", @@ -51,6 +51,7 @@ "@commitlint/cli": "^8.2.0", "@commitlint/config-conventional": "^8.2.0", "@commitlint/config-lerna-scopes": "^8.2.0", + "@component-controls/ts-markdown-docs": "^1.3.0", "@rollup/plugin-node-resolve": "^7.1.1", "@rollup/plugin-json": "^4.0.2", "@rollup/plugin-commonjs": "^11.0.2", @@ -79,14 +80,11 @@ "lint-staged": "^9.2.0", "npm-run-all": "^4.1.5", "prettier": "^1.18.2", - "remark": "^11.0.2", - "remark-toc": "^7.0.0", "rollup": "^2.3.2", "rollup-plugin-typescript2": "^0.27.0", "trash-cli": "^3.0.0", "ts-jest": "^24.0.2", "ts-node": "^8.5.4", - "typedoc": "^0.17.6", "typescript": "^3.8.3" }, "workspaces": { diff --git a/plugins/axe-plugin/package.json b/plugins/axe-plugin/package.json index c98501097..152193e56 100644 --- a/plugins/axe-plugin/package.json +++ b/plugins/axe-plugin/package.json @@ -18,7 +18,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -45,6 +45,7 @@ "theme-ui": "next" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/react": "^16.9.34", "@types/recoil": "^0.0.0", "typescript": "^3.8.3" diff --git a/props-info/react-docgen-typescript/package.json b/props-info/react-docgen-typescript/package.json index 1eb0d25db..a994ed635 100644 --- a/props-info/react-docgen-typescript/package.json +++ b/props-info/react-docgen-typescript/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -35,6 +35,7 @@ "react-docgen-typescript": "^1.16.1" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/jest": "^25.1.2", "@types/react": "^16.9.23", "cross-env": "^5.2.1", diff --git a/props-info/react-docgen/package.json b/props-info/react-docgen/package.json index 267c29642..41b2053eb 100644 --- a/props-info/react-docgen/package.json +++ b/props-info/react-docgen/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -35,6 +35,7 @@ "react-docgen": "^5.3.0" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/jest": "^25.1.2", "@types/prop-types": "^15.7.3", "@types/react": "^16.9.23", diff --git a/scripts/docs.ts b/scripts/docs.ts deleted file mode 100644 index 37675af05..000000000 --- a/scripts/docs.ts +++ /dev/null @@ -1,18 +0,0 @@ -import fs from 'fs'; -import remark from 'remark'; -import toc from 'remark-toc'; -import { insertOverview } from './overview-sections/insert-overview'; -import { insertTSDoc } from './tsdoc/insert-tsdoc'; -import { insertReactDocgenTypescript } from './react-docgen-typescript/insert-react-docgen-typescript'; - -remark() - .use(insertReactDocgenTypescript) - .use(insertTSDoc) - .use(insertOverview) - .use(toc, { tight: true }) - .process(fs.readFileSync('README.md', 'utf8'), function(err, file) { - if (err) { - throw err; - } - fs.writeFileSync('README.md', String(file)); - }); diff --git a/ui/app/package.json b/ui/app/package.json index 418a60a10..ac61caa5e 100644 --- a/ui/app/package.json +++ b/ui/app/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -41,6 +41,7 @@ "theme-ui": "next" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/jest": "^25.1.2", "@types/react-helmet": "^6.0.0", "cross-env": "^5.2.1", diff --git a/ui/blocks/package.json b/ui/blocks/package.json index e390e29ff..ba672f71e 100644 --- a/ui/blocks/package.json +++ b/ui/blocks/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -48,6 +48,7 @@ "theme-ui": "next" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@theme-ui/presets": "^0.3.0", "@types/jest": "^25.1.2", "@types/lunr": "^2.3.3", diff --git a/ui/components/package.json b/ui/components/package.json index cf374df08..cc405556d 100644 --- a/ui/components/package.json +++ b/ui/components/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -48,6 +48,7 @@ "theme-ui": "next" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/jest": "^25.1.2", "@types/markdown-to-jsx": "^6.11.0", "@types/react-table": "^7.0.10", diff --git a/ui/editors/package.json b/ui/editors/package.json index 459253c5b..06452a4de 100644 --- a/ui/editors/package.json +++ b/ui/editors/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -42,6 +42,7 @@ "theme-ui": "next" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/jest": "^25.1.2", "@types/react-color": "^3.0.1", "cross-env": "^5.2.1", diff --git a/ui/pages/package.json b/ui/pages/package.json index c1207cb69..13f8ee836 100644 --- a/ui/pages/package.json +++ b/ui/pages/package.json @@ -13,7 +13,7 @@ "scripts": { "build": "yarn cross-env NODE_ENV=production rollup -c", "dev": "yarn cross-env NODE_ENV=development rollup -cw", - "docs": "ts-node -O '{\"module\": \"commonjs\"}' ../../scripts/docs.ts", + "docs": "ts-md", "fix": "yarn lint --fix", "lint": "yarn eslint . --ext mdx,ts,tsx", "prepare": "yarn build", @@ -35,6 +35,7 @@ "react": "^16.8.3" }, "devDependencies": { + "@component-controls/ts-markdown-docs": "^1.3.0", "@types/jest": "^25.1.2", "cross-env": "^5.2.1", "eslint": "^6.5.1", diff --git a/yarn.lock b/yarn.lock index 977b4b604..822a3afa3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -20761,7 +20761,7 @@ typedoc-default-themes@^0.10.1: dependencies: lunr "^2.3.8" -typedoc@^0.17.6: +typedoc@^0.17.7: version "0.17.7" resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.17.7.tgz#70797401140403a5f91589ed3f4f24c03841bf7a" integrity sha512-PEnzjwQAGjb0O8a6VDE0lxyLAadqNujN5LltsTUhZETolRMiIJv6Ox+Toa8h0XhKHqAOh8MOmB0eBVcWz6nuAw==