Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { useLocation } from '@reach/router';
import { Badge, CodeBlock, CodeBlockCode, debounce, Switch } from '@patternfly/react-core';
import * as reactCoreModule from '@patternfly/react-core';
import * as reactCoreNextModule from '@patternfly/react-core/next';
import * as reactCoreDeprecatedModule from '@patternfly/react-core/deprecated';
import * as reactTableModule from '@patternfly/react-table';
import * as reactTableDeprecatedModule from '@patternfly/react-table/deprecated';
import { css } from '@patternfly/react-styles';
import { getParameters } from 'codesandbox/lib/api/define';
import { ExampleToolbar } from './exampleToolbar';
Expand Down Expand Up @@ -109,7 +111,8 @@ export const Example = ({
// These 2 are in the bundle anyways for the site since we dogfood
...reactCoreModule,
...reactTableModule,
...(source === 'react-next' ? reactCoreNextModule : {})
...(source === 'react-next' ? reactCoreNextModule : {}),
...(source === 'react-deprecated' ? {...reactCoreDeprecatedModule, ...reactTableDeprecatedModule} : {})
};

let livePreview = null;
Expand Down
3 changes: 2 additions & 1 deletion packages/documentation-framework/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ const sourceOrder = {
react: 1,
'react-next': 1.1,
'react-composable': 1.2,
'react-legacy': 1.3,
'react-deprecated': 1.3,
'react-legacy': 1.4,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still have plans to use react-legacy after this change and introduction of react-deprecated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ultimately react-deprecated will replace the legacy here so I can remove it, but probably not until it's been removed after the breaking change. I don't want to remove it before then.
The deprecated work is going in the v5 branch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, so maybe we make a follow-up issue to remove this when we're ready?

'react-demos': 2,
html: 3,
'html-demos': 4,
Expand Down
22 changes: 16 additions & 6 deletions packages/documentation-framework/scripts/md/parseMD.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function toReactComponent(mdFilePath, source, buildMode) {
}

const propComponents = [...new Set(frontmatter.propComponents || [])].reduce((acc, componentName) => {
const name = getTsDocName(componentName, source === 'react-next');
const name = getTsDocName(componentName, getTsDocNameVariant(source));

if (tsDocs[name]) {
acc.push(tsDocs[name]);
Expand Down Expand Up @@ -242,7 +242,7 @@ function sourcePropsFile(file) {
tsDocgen(file)
.filter(({ hide }) => !hide)
.forEach(({ name, description, props }) => {
tsDocs[getTsDocName(name, file.includes('/next'))] = { name, description, props };
tsDocs[getTsDocName(name, getTsDocNameVariant(file))] = { name, description, props };
});
}

Expand Down Expand Up @@ -283,10 +283,20 @@ function writeIndex() {
return exitCode;
}

// Build unique names for components if they are a part of the "next" module.
function getTsDocName(name, isNextComponent) {
return `${name}${isNextComponent ? '-next' : ''}`;
};
// Build unique names for components with a "variant" extension
function getTsDocName(name, variant) {
return `${name}${variant ? `-${variant}` : ''}`;
}

function getTsDocNameVariant(source) {
if (source.includes('next')) {
return 'next';
}

if (source.includes('deprecated')) {
return 'deprecated';
}
}

module.exports = {
sourceProps(glob, ignore) {
Expand Down
2 changes: 2 additions & 0 deletions packages/documentation-framework/scripts/md/typecheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const defaultImports = [
'react',
'@reach/router',
'@patternfly/react-core/next',
'@patternfly/react-core/deprecated',
'@patternfly/react-table/deprecated',
'react-dropzone',
];
const files = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ module.exports = (_env, argv) => {
alias: {
'client-styles': path.resolve(process.cwd(), 'patternfly-docs/patternfly-docs.css.js'),
'./routes-client': path.resolve(process.cwd(), 'patternfly-docs/patternfly-docs.routes.js'),
'./routes-generated': path.resolve(process.cwd(), 'patternfly-docs/generated/index.js'),
'@patternfly/react-core/next': '@patternfly/react-core/dist/esm/next/index.js' // Can remove when webpack is updated to v5
'./routes-generated': path.resolve(process.cwd(), 'patternfly-docs/generated/index.js')
},
modules: [
'node_modules',
Expand Down
7 changes: 5 additions & 2 deletions packages/v4/patternfly-docs/patternfly-docs.source.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module.exports = (sourceMD, sourceProps) => {
const reactChartsPath = require
.resolve('@patternfly/react-charts/package.json')
.replace('package.json', 'src');

const reactLogViewerPath = require
.resolve('@patternfly/react-log-viewer/package.json')
.replace('package.json', 'src');
Expand All @@ -59,12 +60,14 @@ module.exports = (sourceMD, sourceProps) => {
sourceMD(path.join(reactCorePath, '/components/**/examples/*.md'), 'react');
sourceMD(path.join(reactCorePath, '/layouts/**/examples/*.md'), 'react');
sourceMD(path.join(reactCorePath, '/next/components/**/examples/*.md'), 'react-next');
sourceMD(path.join(reactCorePath, '/deprecated/components/**/examples/*.md'), 'react-deprecated');
sourceMD(path.join(reactCorePath, '/**/demos/**/*.md'), 'react-demos');

// React-table MD
sourceMD(path.join(reactTablePath, '/**/TableComposable/examples/*.md'), 'react-composable');
sourceMD(path.join(reactTablePath, '/**/demos/*.md'), 'react-demos');
sourceMD(path.join(reactTablePath, '/**/TableComposable/examples/*.md'), 'react');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this tested locally by any chance? This regex might conflict with the deprecated path regex on line 61. To prevent the potential for that we can remove the wildcard at the beginning of this line and replace it with components (e.g. /components/TableComposable/...).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not recently but i'll do that

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeffpuzzo so i'm realizing now that this line will be better tested in the react-docs package where we have our own patternfly-docs.source.js file defined. patternfly-react does not consume org's v4 package, it's actually the other way around, so if these lines dont work in the react workspace when the change is made there, then we can update it here to match whatever worked in the workspace. If this is good to be merged, hopefully this will unblock the work to deprecate table

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, that makes sense.

sourceMD(path.join(reactTablePath, '/**/Table/examples/*.md'), 'react-legacy');
sourceMD(path.join(reactTablePath, '/deprecated/components/**/examples/*.md'), 'react-deprecated');
sourceMD(path.join(reactTablePath, '/**/demos/*.md'), 'react-demos');

// Charts MD (no demos yet)
sourceMD(path.join(reactChartsPath, '/**/examples/*.md'), 'react');
Expand Down