Skip to content

Commit d4a3444

Browse files
committed
chore(docs): add ai, extensions, foundations, styles guidance
* testing, metadata checks * update version refs for org links, align org links * adds for ai, extensions, foundations, styles, includes design tokens * add for ouia
1 parent d0fa57a commit d4a3444

3 files changed

Lines changed: 615 additions & 180 deletions

File tree

src/__tests__/__snapshots__/tool.searchPatternFlyDocs.test.ts.snap

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ exports[`searchPatternFlyDocsTool should have a consistent return structure: str
88
}
99
`;
1010

11-
exports[`searchPatternFlyDocsTool, callback should parse parameters, default: search 1`] = `"# Search results for "Button". Showing 1 exact match."`;
11+
exports[`searchPatternFlyDocsTool, callback should parse parameters, default: search 1`] = `"# Search results for "Button". Showing 2 exact matches."`;
1212

13-
exports[`searchPatternFlyDocsTool, callback should parse parameters, with "*" searchQuery all: search 1`] = `"# Search results for "all" resources. Only showing the first 10 results. There are 546 potential match variations. Try searching with a more specific query."`;
13+
exports[`searchPatternFlyDocsTool, callback should parse parameters, with "*" searchQuery all: search 1`] = `"# Search results for "all" resources. Only showing the first 10 results. There are 732 potential match variations. Try searching with a more specific query."`;
1414

15-
exports[`searchPatternFlyDocsTool, callback should parse parameters, with "all" searchQuery all: search 1`] = `"# Search results for "all" resources. Only showing the first 10 results. There are 546 potential match variations. Try searching with a more specific query."`;
15+
exports[`searchPatternFlyDocsTool, callback should parse parameters, with "all" searchQuery all: search 1`] = `"# Search results for "all" resources. Only showing the first 10 results. There are 732 potential match variations. Try searching with a more specific query."`;
1616

17-
exports[`searchPatternFlyDocsTool, callback should parse parameters, with explicit valid version: search 1`] = `"# Search results for "Button". Showing 1 exact match."`;
17+
exports[`searchPatternFlyDocsTool, callback should parse parameters, with explicit valid version: search 1`] = `"# Search results for "Button". Showing 2 exact matches."`;
1818

19-
exports[`searchPatternFlyDocsTool, callback should parse parameters, with lower case componentName: search 1`] = `"# Search results for "button". Showing 1 exact match."`;
19+
exports[`searchPatternFlyDocsTool, callback should parse parameters, with lower case componentName: search 1`] = `"# Search results for "button". Showing 2 exact matches."`;
2020

2121
exports[`searchPatternFlyDocsTool, callback should parse parameters, with made up componentName: search 1`] = `"No PatternFly resources found matching "lorem ipsum dolor sit amet""`;
2222

23-
exports[`searchPatternFlyDocsTool, callback should parse parameters, with multiple words: search 1`] = `"# Search results for "Button Card Table". Showing 3 related matches."`;
23+
exports[`searchPatternFlyDocsTool, callback should parse parameters, with multiple words: search 1`] = `"# Search results for "Button Card Table". Showing 4 related matches."`;
2424

25-
exports[`searchPatternFlyDocsTool, callback should parse parameters, with partial componentName: search 1`] = `"# Search results for "ton". Showing 4 related matches."`;
25+
exports[`searchPatternFlyDocsTool, callback should parse parameters, with partial componentName: search 1`] = `"# Search results for "ton". Showing 5 related matches."`;
2626

27-
exports[`searchPatternFlyDocsTool, callback should parse parameters, with trimmed componentName: search 1`] = `"# Search results for " Button ". Showing 1 exact match."`;
27+
exports[`searchPatternFlyDocsTool, callback should parse parameters, with trimmed componentName: search 1`] = `"# Search results for " Button ". Showing 2 exact matches."`;
2828

29-
exports[`searchPatternFlyDocsTool, callback should parse parameters, with upper case componentName: search 1`] = `"# Search results for "BUTTON". Showing 1 exact match."`;
29+
exports[`searchPatternFlyDocsTool, callback should parse parameters, with upper case componentName: search 1`] = `"# Search results for "BUTTON". Showing 2 exact matches."`;

src/__tests__/docs.json.test.ts

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,49 @@
11
import docs from '../docs.json';
22

33
describe('docs.json', () => {
4-
it('should have metadata reflective of its JSON content', () => {
5-
expect(docs.meta.totalEntries).toBeDefined();
6-
expect(Object.entries(docs.docs).length).toBe(docs.meta.totalEntries);
7-
8-
expect(docs.meta.totalDocs).toBeDefined();
9-
4+
it('should have metadata reflective of its content and unique links per each entry', () => {
5+
const allLinks = new Set<string>();
6+
const baseHashes = new Set<string | undefined>();
7+
const flatDocs = Object.values(docs.docs).flat();
108
let totalDocs = 0;
119

12-
Object.values(docs.docs).forEach(entries => {
13-
if (Array.isArray(entries)) {
14-
totalDocs += entries.length;
10+
flatDocs.forEach(entry => {
11+
totalDocs += 1;
12+
allLinks.add(entry.path);
13+
14+
if (entry.path.includes('documentation:')) {
15+
baseHashes.add('documentation:');
16+
} else if (entry.path.includes('/patternfly/patternfly-org/')) {
17+
baseHashes.add(entry.path.split('/patternfly/patternfly-org/')[1]?.split('/')[0]);
18+
} else if (entry.path.includes('/patternfly/patternfly-react/')) {
19+
baseHashes.add(entry.path.split('/patternfly/patternfly-react/')[1]?.split('/')[0]);
20+
} else {
21+
baseHashes.add(`new-resource-${entry.path}`);
1522
}
1623
});
1724

25+
expect(docs.meta.totalEntries).toBeDefined();
26+
expect(docs.meta.totalDocs).toBeDefined();
27+
expect(Object.entries(docs.docs).length).toBe(docs.meta.totalEntries);
28+
29+
/**
30+
* Confirm we have limited hashes, avoid variation within pf versions
31+
* If this increases, hashes need to be realigned. Do not randomly change this value.
32+
* 1 (v6 org) + 1 (v6 react) + 1 (v5 org) + 1 (local)
33+
*/
34+
expect(baseHashes.size).toBe(4);
35+
36+
/**
37+
* Confirm total docs count matches metadata
38+
* Update the JSON metadata accordingly
39+
*/
1840
expect(totalDocs).toBe(docs.meta.totalDocs);
41+
42+
/**
43+
* Confirm unique links against metadata totals
44+
* Update the JSON metadata accordingly
45+
*/
46+
expect(allLinks.size).toBe(flatDocs.length);
47+
expect(allLinks.size).toBe(docs.meta.totalDocs);
1948
});
2049
});

0 commit comments

Comments
 (0)