@patternfly/documentation-framework 1.4.9 → 1.4.11

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,25 @@
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.4.11 (2023-02-01)
7
+
8
+ **Note:** Version bump only for package @patternfly/documentation-framework
9
+
10
+
11
+
12
+
13
+
14
+ ## 1.4.10 (2023-01-26)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * update codesandbox dependencies per example import ([#3367](https://github.com/patternfly/patternfly-org/issues/3367)) ([31b75a3](https://github.com/patternfly/patternfly-org/commit/31b75a346dd0ba03bb697d9917a729a32dad76be))
20
+
21
+
22
+
23
+
24
+
6
25
  ## 1.4.9 (2023-01-25)
7
26
 
8
27
  **Note:** Version bump only for package @patternfly/documentation-framework
@@ -81,7 +81,11 @@ export const Example = ({
81
81
  // Show dark theme switcher on full page examples
82
82
  hasDarkThemeSwitcher = process.env.hasDarkThemeSwitcher,
83
83
  // Map of relative imports matched to their npm package import path (passed to Codesandbox)
84
- relativeImports
84
+ relativeImports,
85
+ // md file location in node_modules, used to resolve relative import paths in examples
86
+ relPath = '',
87
+ // absolute url to hosted file
88
+ sourceLink = ''
85
89
  }) => {
86
90
  if (isFullscreenPreview) {
87
91
  isFullscreen = false;
@@ -160,13 +164,13 @@ export const Example = ({
160
164
  const codeBoxParams = getParameters(
161
165
  lang === 'html'
162
166
  ? getStaticParams(title, editorCode)
163
- : getReactParams(title, editorCode, scope, lang, relativeImports)
167
+ : getReactParams(title, editorCode, scope, lang, relativeImports, relPath, sourceLink)
164
168
  );
165
169
  const fullscreenLink = loc.pathname.replace(/\/$/, '')
166
170
  + (loc.pathname.endsWith(source) ? '' : `/${source}`)
167
171
  + '/'
168
172
  + slugger(title);
169
-
173
+
170
174
  return (
171
175
  <div className="ws-example">
172
176
  <div className="ws-example-header">
@@ -12,7 +12,7 @@ export const InlineAlert = ({
12
12
  className="pf-u-my-md"
13
13
  style={{ marginBottom: '1rem' }}
14
14
  isInline
15
- titleHeadingLevel="h2"
15
+ component="h2"
16
16
  >
17
17
  {children}
18
18
  </Alert>
@@ -2,6 +2,7 @@ const { parse } = require('@patternfly/ast-helpers');
2
2
  const versions = require('../versions.json');
3
3
  const overpass = require('./fonts');
4
4
  const { capitalize } = require('./capitalize');
5
+ const path = require('path');
5
6
  const pathPrefix = process.env.pathPrefix;
6
7
 
7
8
  const getStaticParams = (title, html) => {
@@ -107,7 +108,7 @@ function prettyExampleCode(title, code, declaration, identifier) {
107
108
  }
108
109
 
109
110
  // TODO: Make React examples work and use a template that has our assets.
110
- function getReactParams(title, code, scope, lang, relativeImports) {
111
+ function getReactParams(title, code, scope, lang, relativeImports, relPath, sourceLink) {
111
112
  let toRender = null;
112
113
  try {
113
114
  let declaration = getExampleDeclaration(code);
@@ -130,12 +131,18 @@ function getReactParams(title, code, scope, lang, relativeImports) {
130
131
  catch (err) {
131
132
  // Ignore
132
133
  }
133
- // Update image imports to point to pf.org
134
- const imgImportRegex = /import\s*(\w*).*['"](.*)(\.(png|jpe?g|webp|gif|svg))['"]/g;
135
- let imgImportMatch;
136
- while ((imgImportMatch = imgImportRegex.exec(code))) {
137
- const imgName = imgImportMatch[1];
138
- code = code.replace(imgImportMatch[0], `const ${imgName} = "https://www.patternfly.org/v4${scope[imgName]}"`);
134
+
135
+ // Point to sourcelink for @patternfly images
136
+ if (relPath.includes('@patternfly')) {
137
+ const imgImportRegex = /(import \W*(\w*)\W*[^'"`]*['"`](.*\.(?:png|jpe?g|webp|gif|svg))['"])/gm;
138
+ let imgImportMatch;
139
+ while ((imgImportMatch = imgImportRegex.exec(code))) {
140
+ const [match, importDeclaration, imgName, relImgPath] = imgImportMatch;
141
+ // Point to sourceLink hosted file
142
+ const sourceLinkPath = new URL(relImgPath, sourceLink.replace('/blob/', '/raw/')).href;
143
+ const hostedImageDeclaration = `const ${imgName} = "${sourceLinkPath}"`;
144
+ code = code.replace(importDeclaration, hostedImageDeclaration);
145
+ }
139
146
  }
140
147
 
141
148
  const relImportRegex = /(import[\s*{])([\w*{}\n\r\t, ]+)([\s*]from\s["']([\.\/]+.*)["'])/gm;
@@ -160,8 +167,7 @@ function getReactParams(title, code, scope, lang, relativeImports) {
160
167
  .filter(([pkg]) => code.includes(pkg))
161
168
  .forEach(([pkg, version]) => dependencies[pkg] = version);
162
169
 
163
-
164
- // Get any additional dependencies from example code
170
+ // Get any additional dependencies from example code, exclude relative imports
165
171
  const importMatch = /(?:import [^'"`]*)(?:['"`])((?!.\/)[^'"`]*)/gm;
166
172
  let depImport;
167
173
  while (depImport = importMatch.exec(code)) {
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.4.9",
4
+ "version": "1.4.11",
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": "61f579285f5edfcfe92659f90ccc38b2616fc15d"
87
+ "gitHead": "0df1271cf0539cb5dc3ad7704ffe7bf328a6d672"
88
88
  }
package/routes.js CHANGED
@@ -28,7 +28,7 @@ const isNull = o => o === null || o === undefined;
28
28
  const groupedRoutes = Object.entries(routes)
29
29
  .filter(([_slug, { id, section }]) => !isNull(id) && !isNull(section))
30
30
  .reduce((accum, [slug, pageData]) => {
31
- const { section, subsection = null, id, title, source, katacodaLayout, hideNavItem } = pageData;
31
+ const { section, subsection = null, id, title, source, katacodaLayout, hideNavItem, relPath } = pageData;
32
32
  pageData.slug = slug;
33
33
  // add section to groupedRoutes obj if not yet created
34
34
  accum[section] = accum[section] || {};
@@ -41,7 +41,8 @@ const groupedRoutes = Object.entries(routes)
41
41
  slug: makeSlug(source, section, id, true, subsection),
42
42
  sources: [],
43
43
  katacodaLayout,
44
- hideNavItem
44
+ hideNavItem,
45
+ relPath
45
46
  }
46
47
  // add page to groupedRoutes obj section or subsection
47
48
  if (subsection) {
@@ -86,7 +86,8 @@ function toReactComponent(mdFilePath, source, buildMode) {
86
86
  sourceLink: frontmatter.sourceLink || `https://github.com/patternfly/${
87
87
  sourceRepo}/blob/main/${
88
88
  normalizedPath}`,
89
- hideTOC: frontmatter.hideTOC || false
89
+ hideTOC: frontmatter.hideTOC || false,
90
+ relPath
90
91
  };
91
92
  // Temporarily override section for Demo tabs until we port this upstream
92
93
  if (frontmatter.section === 'demos' && routes[slug.replace('demos', 'components')]) {
package/versions.json CHANGED
@@ -1,9 +1,27 @@
1
1
  {
2
2
  "Releases": [
3
3
  {
4
+ "name": "2023.01",
5
+ "date": "2022-01-31",
6
+ "latest": true,
7
+ "versions": {
8
+ "@patternfly/patternfly": "4.224.2",
9
+ "@patternfly/react-catalog-view-extension": "4.95.1",
10
+ "@patternfly/react-charts": "6.94.18",
11
+ "@patternfly/react-code-editor": "4.82.113",
12
+ "@patternfly/react-core": "4.276.6",
13
+ "@patternfly/react-icons": "4.93.6",
14
+ "@patternfly/react-inline-edit-extension": "4.86.118",
15
+ "@patternfly/react-log-viewer": "4.87.100",
16
+ "@patternfly/react-styles": "4.92.6",
17
+ "@patternfly/react-table": "4.112.39",
18
+ "@patternfly/react-tokens": "4.94.6",
19
+ "@patternfly/react-topology": "4.91.27",
20
+ "@patternfly/react-virtualized-extension": "4.88.113"
21
+ }
22
+ },{
4
23
  "name": "2022.16",
5
24
  "date": "2022-12-15",
6
- "latest": true,
7
25
  "versions": {
8
26
  "@patternfly/patternfly": "4.222.4",
9
27
  "@patternfly/react-catalog-view-extension": "4.93.15",