@patternfly/documentation-framework 1.1.34 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 1.2.0 (2022-08-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * **doc-framework:** Allow for 'next' core component usage alongside core components ([#3126](https://github.com/patternfly/patternfly-org/issues/3126)) ([8617112](https://github.com/patternfly/patternfly-org/commit/8617112840dd7c26cd6660120c6b24b8ca91e7d3))
12
+
13
+
14
+
15
+
16
+
17
+ ## 1.1.36 (2022-08-17)
18
+
19
+ **Note:** Version bump only for package @patternfly/documentation-framework
20
+
21
+
22
+
23
+
24
+
25
+ ## 1.1.35 (2022-08-17)
26
+
27
+ **Note:** Version bump only for package @patternfly/documentation-framework
28
+
29
+
30
+
31
+
32
+
6
33
  ## 1.1.34 (2022-08-16)
7
34
 
8
35
  **Note:** Version bump only for package @patternfly/documentation-framework
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import { useLocation } from '@reach/router';
3
- import { Badge, CodeBlock, CodeBlockCode, debounce, Switch } from '@patternfly/react-core';
3
+ import { Badge, CodeBlock, CodeBlockCode, debounce } from '@patternfly/react-core';
4
4
  import * as reactCoreModule from '@patternfly/react-core';
5
+ import * as reactCoreNextModule from '@patternfly/react-core/next';
5
6
  import * as reactTableModule from '@patternfly/react-table';
6
7
  import { css } from '@patternfly/react-styles';
7
8
  import { getParameters } from 'codesandbox/lib/api/define';
@@ -25,7 +26,7 @@ class ErrorBoundary extends React.Component {
25
26
  super(props);
26
27
  this.state = { error: null, errorInfo: null };
27
28
  }
28
-
29
+
29
30
  componentDidCatch(error, errorInfo) {
30
31
  errorInfo._suppressLogging = true;
31
32
  this.setState({
@@ -39,13 +40,13 @@ class ErrorBoundary extends React.Component {
39
40
  this.setState({ error: null, errorInfo: null });
40
41
  }
41
42
  }
42
-
43
+
43
44
  render() {
44
45
  if (this.state.errorInfo) {
45
46
  return errorComponent(this.state.error);
46
47
  }
47
48
  return this.props.children;
48
- }
49
+ }
49
50
  }
50
51
 
51
52
  // Props come from mdx-ast-to-mdx-hast.js
@@ -100,10 +101,11 @@ export const Example = ({
100
101
 
101
102
  const scope = {
102
103
  ...liveContext,
103
- // These 2 are in the bundle anyways for the site since we dogfood
104
104
  ...reactCoreModule,
105
105
  ...reactTableModule,
106
+ ...(source === 'react-next' ? reactCoreNextModule : {})
106
107
  };
108
+
107
109
  let livePreview = null;
108
110
  if (lang === 'html') {
109
111
  livePreview = (
@@ -120,8 +122,13 @@ export const Example = ({
120
122
  } else {
121
123
  lang = 'js';
122
124
  }
123
- const getPreviewComponent = new Function('React', ...Object.keys(scope), transformedCode);
124
- const PreviewComponent = getPreviewComponent(React, ...Object.values(scope));
125
+
126
+ const componentNames = Object.keys(scope);
127
+ const componentValues = Object.values(scope);
128
+
129
+ const getPreviewComponent = new Function('React', ...componentNames, transformedCode);
130
+ const PreviewComponent = getPreviewComponent(React, ...componentValues);
131
+
125
132
  livePreview = (
126
133
  <ErrorBoundary>
127
134
  <PreviewComponent />
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@patternfly/documentation-framework",
3
3
  "description": "A framework to build documentation for PatternFly.",
4
- "version": "1.1.34",
4
+ "version": "1.2.0",
5
5
  "author": "Red Hat",
6
6
  "license": "MIT",
7
7
  "private": false,
@@ -84,5 +84,5 @@
84
84
  "react": "^16.8.0 || ^17.0.0",
85
85
  "react-dom": "^16.8.0 || ^17.0.0"
86
86
  },
87
- "gitHead": "8a2730747a4fd5e566262bf6bbf37ae2d4e138f3"
87
+ "gitHead": "e2b7e27265434339d7fb49783a5518a06c04467d"
88
88
  }
package/routes.js CHANGED
@@ -48,8 +48,9 @@ const groupedRoutes = Object.entries(routes)
48
48
 
49
49
  const sourceOrder = {
50
50
  react: 1,
51
- 'react-composable': 1.1,
52
- 'react-legacy': 1.2,
51
+ 'react-next': 1.1,
52
+ 'react-composable': 1.2,
53
+ 'react-legacy': 1.3,
53
54
  'react-demos': 2,
54
55
  html: 3,
55
56
  'html-demos': 4,
@@ -46,7 +46,9 @@ async function buildWebpack(webpackConfig) {
46
46
  async function execFile(file, args) {
47
47
  const start = new Date();
48
48
  return new Promise((res, rej) => {
49
- const child = fork(path.join(__dirname, file), args);
49
+ const child = fork(path.join(__dirname, file), args, {
50
+ execArgv: ['--max-old-space-size=4096']
51
+ });
50
52
  function errorHandler(err) {
51
53
  console.error(err);
52
54
  process.exit(1);
@@ -60,15 +60,17 @@ function toReactComponent(mdFilePath, source, buildMode) {
60
60
  sourceRepo = 'patternfly-react';
61
61
  }
62
62
 
63
- const propComponents = [...new Set(frontmatter.propComponents || [])]
64
- .filter(propComponent => {
65
- if (tsDocs[propComponent]) {
66
- return true;
67
- }
68
- file.message(`Prop component ${propComponent} missing from tsDocgen`);
69
- return false;
70
- })
71
- .map(propComponent => tsDocs[propComponent])
63
+ const propComponents = [...new Set(frontmatter.propComponents || [])].reduce((acc, componentName) => {
64
+ const name = getTsDocName(componentName, source === 'react-next');
65
+
66
+ if (tsDocs[name]) {
67
+ acc.push(tsDocs[name]);
68
+ } else {
69
+ file.message(`Prop component ${name} is missing from tsDocgen`);
70
+ }
71
+
72
+ return acc;
73
+ }, []);
72
74
 
73
75
  const normalizedPath = relPath
74
76
  .replace('node_modules/@patternfly/patternfly/docs', 'src/patternfly')
@@ -123,7 +125,7 @@ function toReactComponent(mdFilePath, source, buildMode) {
123
125
  // Delete HTML comments
124
126
  .use(require('./remove-comments'))
125
127
  // remark-mdx removes auto-link support
126
- // this adds it back ONLY for links which are easily differentiable from JSX
128
+ // this adds it back ONLY for links which are easily differentiable from JSX
127
129
  .use(require('./auto-link-url'))
128
130
  // Support for JSX in MD
129
131
  .use(require('remark-mdx'))
@@ -148,7 +150,7 @@ function toReactComponent(mdFilePath, source, buildMode) {
148
150
  // .use(require('remark-rehype'))
149
151
  // .use(require('rehype-react'), { createElement: require('react').createElement })
150
152
  // Transform AST to JSX elements. Includes special code block parsing
151
- .use(require('./mdx-ast-to-mdx-hast'), {
153
+ .use(require('./mdx-ast-to-mdx-hast'), {
152
154
  watchExternal(file) {
153
155
  if (buildMode === 'start') {
154
156
  const watcher = chokidar.watch(file, { ignoreInitial: true });
@@ -220,7 +222,6 @@ function toReactComponent(mdFilePath, source, buildMode) {
220
222
  console.error(vfileReport(err));
221
223
  exitCode = 2;
222
224
  } else {
223
- // console.log(relPath, '->', path.relative(process.cwd(), outPath));
224
225
  if (file.messages.length > 0) {
225
226
  console.log(vfileReport(file));
226
227
  }
@@ -239,7 +240,7 @@ function sourcePropsFile(file) {
239
240
  tsDocgen(file)
240
241
  .filter(({ hide }) => !hide)
241
242
  .forEach(({ name, description, props }) => {
242
- tsDocs[name] = { name, description, props };
243
+ tsDocs[getTsDocName(name, file.includes('/next'))] = { name, description, props };
243
244
  });
244
245
  }
245
246
 
@@ -279,6 +280,11 @@ function writeIndex() {
279
280
  return exitCode;
280
281
  }
281
282
 
283
+ // Build unique names for components if they are a part of the "next" module.
284
+ function getTsDocName(name, isNextComponent) {
285
+ return `${name}${isNextComponent ? '-next' : ''}`;
286
+ };
287
+
282
288
  module.exports = {
283
289
  sourceProps(glob, ignore) {
284
290
  globs.props.push({ glob, ignore });
@@ -34,13 +34,18 @@ declare module '\\*.svg' {
34
34
  const reactStylesDir = path.join(require.resolve('@patternfly/react-styles/package.json'), '../');
35
35
  const reactStyles = glob.sync(path.join(reactStylesDir, 'css/**/*.d.ts'))
36
36
  .map(f => f.replace(reactStylesDir, '@patternfly/react-styles/').replace(/\.d.ts$/, ''));
37
+ const defaultImports = [
38
+ 'react',
39
+ '@reach/router',
40
+ '@patternfly/react-core/next',
41
+ ];
37
42
  const files = {
38
- 'imports.ts': ['react', '@reach/router']
39
- .concat(Object.keys(versions.Releases[0].versions))
40
- .concat(reactStyles)
41
- .filter(p => p !== '@patternfly/patternfly')
42
- .map(p => `import '${p}';`)
43
- .join('\n'),
43
+ 'imports.ts': defaultImports
44
+ .concat(Object.keys(versions.Releases[0].versions))
45
+ .concat(reactStyles)
46
+ .filter(p => p !== '@patternfly/patternfly')
47
+ .map(p => `import '${p}';`)
48
+ .join('\n'),
44
49
  'declarations.d.ts': defaultDeclarations
45
50
  };
46
51
 
@@ -130,4 +135,3 @@ function typecheck(fname, text) {
130
135
  module.exports = {
131
136
  typecheck
132
137
  };
133
-
@@ -117,6 +117,7 @@ module.exports = (_env, argv) => {
117
117
  'client-styles': path.resolve(process.cwd(), 'patternfly-docs/patternfly-docs.css.js'),
118
118
  './routes-client': path.resolve(process.cwd(), 'patternfly-docs/patternfly-docs.routes.js'),
119
119
  './routes-generated': path.resolve(process.cwd(), 'patternfly-docs/generated/index.js'),
120
+ '@patternfly/react-core/next': '@patternfly/react-core/dist/esm/next/index.js', // Can remove when webpack is updated to v5
120
121
  'lodash': 'lodash-es' // Sanely bundle react-charts.
121
122
  },
122
123
  modules: [