FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: add build-time validation for inline JavaDoc code snippets · patternfly-java/patternfly-java@2756fce · GitHub

Commit 2756fce

Browse files
committed
feat: add build-time validation for inline JavaDoc code snippets
Add a snippet-tests module that uses reflection to validate import targets and identifiers in {@snippet :} blocks. The module runs as part of the check profile (./check.sh) and caught several real errors: - cog → gear (renamed icon in fas) - plusCircle → circlePlus (renamed icon in fas) - undo moved from fas to rhUi - import static org.jboss.elemento.By → import (wrong import form) Also updates check.sh from process-sources to test phase so the JUnit-based snippet validation can run alongside existing checks.
1 parent b84fbc3 commit 2756fce

11 files changed

Lines changed: 468 additions & 12 deletions

File tree

‎CLAUDE.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ PatternFly Java is a pure Java implementation of [PatternFly](https://www.patter
1313
| `mvn clean verify` | Full build (tests, javadoc — no formatting/linting) |
1414
| `mvn verify -Dquickly` | Quick build (skip tests, javadoc) |
1515
| `mvn process-sources -P format,showcase` | Auto-format sources (editorconfig, imports, license headers) |
16-
| `mvn process-sources -P check,showcase` | Validate sources (enforcer, checkstyle, editorconfig, imports, license) |
16+
| `mvn test -P check,showcase` | Validate sources (enforcer, checkstyle, editorconfig, imports, license, snippet validation) |
1717
| `./format.sh` | Shortcut for `mvn process-sources -P format,showcase` |
18-
| `./check.sh` | Shortcut for `mvn process-sources -P check,showcase` |
18+
| `./check.sh` | Shortcut for `mvn test -P check,showcase` |
1919
| `mvn test -Dtest=ModifierTest` | Run a single test class |
2020
| `mvn test -Dtest=ModifierTest#testModifiers` | Run a single test method |
2121
| `mvn j2cl:watch -P showcase` | Watch J2CL compilation for showcase dev |
@@ -36,6 +36,7 @@ Uses Maven Wrapper (`mvnw`). Requires Java 21+ and Maven 3.9.9+.
3636
- **charts** - Chart web components wrapper — standalone NPM package (`@patternfly-java/charts`), built and published independently with pnpm, not part of the Maven build lifecycle
3737
- **extensions/codeeditor**, **extensions/finder** - Extensions
3838
- **gwt**, **j2cl** - Compilation target support
39+
- **snippet-tests** - Build-time validation of inline JavaDoc code snippets (activated via `-P check` profile, not deployed)
3940
- **showcase** - Interactive demo website (activated via `-P showcase` profile)
4041

4142
## Architecture & Patterns

‎check.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,4 @@ parse_params() {
9494

9595
parse_params "$@"
9696
setup_colors
97-
mvn process-sources -P check,showcase
97+
mvn test -P check,showcase

‎components/src/main/java/org/patternfly/component/icon/package-info.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838
* import static org.patternfly.component.icon.IconSize.sm;
3939
* import static org.patternfly.component.icon.IconSize.xl;
4040
* import static org.patternfly.icon.IconSets.rhUi.checkCircleFill;
41-
* import static org.patternfly.icon.IconSets.fas.cog;
41+
* import static org.patternfly.icon.IconSets.fas.gear;
4242
* import static org.patternfly.icon.IconSets.rhUi.errorFill;
4343
* import static org.patternfly.style.Status.danger;
4444
* import static org.patternfly.style.Status.success;
4545
*
4646
* // Basic icons
47-
* Icon settingsIcon = icon(cog());
47+
* Icon settingsIcon = icon(gear());
4848
*
4949
* // Icons with sizes
5050
* Icon smallIcon = icon(checkCircleFill()).size(sm);

‎components/src/main/java/org/patternfly/component/page/PageSidebar.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.jboss.elemento.ElementContainerDelegate;
2222
import org.patternfly.component.Expandable;
2323
import org.patternfly.handler.ToggleHandler;
24+
2425
import elemental2.dom.Element;
2526
import elemental2.dom.Event;
2627
import elemental2.dom.HTMLElement;

‎components/src/main/java/org/patternfly/component/togglegroup/package-info.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* import static org.patternfly.component.togglegroup.ToggleGroup.toggleGroup;
4949
* import static org.patternfly.component.togglegroup.ToggleGroupItem.toggleGroupItem;
5050
* import static org.patternfly.icon.IconSets.rhUi.copy;
51-
* import static org.patternfly.icon.IconSets.fas.undo;
51+
* import static org.patternfly.icon.IconSets.rhUi.undo;
5252
*
5353
* ToggleGroup iconGroup = toggleGroup(multi)
5454
* .addItem(toggleGroupItem("copy").iconAndText(copy(), "Copy"))

‎components/src/main/java/org/patternfly/component/tooltip/package-info.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* <p>Create a tooltip attached to a trigger element:
3333
*
3434
* {@snippet :
35-
* import static org.jboss.elemento.By;
35+
* import org.jboss.elemento.By;
3636
* import static org.patternfly.component.button.Button.button;
3737
* import static org.patternfly.component.tooltip.Tooltip.tooltip;
3838
*
@@ -43,7 +43,7 @@
4343
* <p>Create a tooltip with placement and dynamic content:
4444
*
4545
* {@snippet :
46-
* import static org.jboss.elemento.By;
46+
* import org.jboss.elemento.By;
4747
* import static org.patternfly.component.tooltip.Tooltip.tooltip;
4848
* import static org.patternfly.style.Placement.bottom;
4949
*

‎icons/src/main/java/org/patternfly/icon/package-info.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* import static org.patternfly.icon.IconSets.fas.cube;
5050
* import static org.patternfly.icon.IconSets.fas.flag;
5151
* import static org.patternfly.icon.IconSets.fas.globe;
52-
* import static org.patternfly.icon.IconSets.fas.plusCircle;
52+
* import static org.patternfly.icon.IconSets.fas.circlePlus;
5353
* import static org.patternfly.icon.IconSets.patternfly.key;
5454
*
5555
* DescriptionList dl = descriptionList()
@@ -66,7 +66,7 @@
6666
* .addGroup(descriptionListGroup()
6767
* .addTerm(descriptionListTerm("Pod selector").icon(globe()))
6868
* .addDescription(descriptionListDescription()
69-
* .add(button().iconAndText(plusCircle(), "app=MyApp", start)
69+
* .add(button().iconAndText(circlePlus(), "app=MyApp", start)
7070
* .inline().link())))
7171
* .addGroup(descriptionListGroup()
7272
* .addTerm(descriptionListTerm("Annotation").icon(flag()))

‎pom.xml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@
404404
</profile>
405405
<profile>
406406
<id>check</id>
407+
<modules>
408+
<module>snippet-tests</module>
409+
</modules>
407410
<build>
408411
<plugins>
409412
<plugin>

‎showcase/markdown/developer/building.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The project is organized into these modules:
5252
| **gwt** | GWT compilation target support |
5353
| **j2cl** | J2CL compilation target support |
5454
| **showcase** | Interactive demo website (activated via `-P showcase`) |
55+
| **snippet-tests** | Build-time validation of inline JavaDoc code snippets (activated via `-P check`, not deployed) |
5556
| **apidoc** | API documentation aggregation (activated via `-P apidoc`) |
5657

5758
The BOM lives in a separate Maven reactor and must be installed before building the main project. All build scripts and CI workflows handle this automatically.
@@ -63,7 +64,7 @@ The BOM lives in a separate Maven reactor and must be installed before building
6364
| Profile | Activation | Purpose |
6465
|---------|-----------|---------|
6566
| `format` | `-P format` | Auto-format sources: editorconfig, import sorting, license headers |
66-
| `check` | `-P check` | Validate sources: enforcer, checkstyle, editorconfig, import sorting, license headers |
67+
| `check` | `-P check` | Validate sources: enforcer, checkstyle, editorconfig, import sorting, license headers, snippet validation |
6768
| `showcase` | `-P showcase` | Include the showcase module in the build |
6869
| `quick-build` | `-Dquickly` | Skip tests, javadoc, and integration tests |
6970
| `skip-j2cl` | `-DskipJ2CL` | Disable J2CL compilation (showcase only) |
@@ -115,7 +116,7 @@ mvn clean package -P showcase,prod
115116
| Script | Purpose |
116117
|--------|---------|
117118
| `format.sh` | Shortcut for `mvn process-sources -P format,showcase` |
118-
| `check.sh` | Shortcut for `mvn process-sources -P check,showcase` |
119+
| `check.sh` | Shortcut for `mvn test -P check,showcase` |
119120
| `release.sh` | Orchestrate a release (see [Releasing](/releasing)) |
120121
| `unrelease.sh` | Roll back a failed release (see [Releasing](/releasing)) |
121122
| `versionBump.sh` | Bump version across all POMs and NPM packages |

‎snippet-tests/pom.xml‎

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright 2023 Red Hat
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
https://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<parent>
24+
<groupId>org.patternfly</groupId>
25+
<artifactId>patternfly-java-code-parent</artifactId>
26+
<version>0.9.1-SNAPSHOT</version>
27+
<relativePath>../code-parent/pom.xml</relativePath>
28+
</parent>
29+
30+
<artifactId>patternfly-java-snippet-tests</artifactId>
31+
<packaging>jar</packaging>
32+
<name>PatternFly Java Snippet Tests</name>
33+
<description>Build-time validation of inline JavaDoc code snippets. Not deployed.</description>
34+
35+
<dependencies>
36+
<dependency>
37+
<groupId>${project.groupId}</groupId>
38+
<artifactId>patternfly-java-core</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>${project.groupId}</groupId>
42+
<artifactId>patternfly-java-components</artifactId>
43+
</dependency>
44+
<dependency>
45+
<groupId>${project.groupId}</groupId>
46+
<artifactId>patternfly-java-layouts</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>${project.groupId}</groupId>
50+
<artifactId>patternfly-java-icons</artifactId>
51+
</dependency>
52+
<dependency>
53+
<groupId>${project.groupId}</groupId>
54+
<artifactId>patternfly-java-tokens</artifactId>
55+
</dependency>
56+
<dependency>
57+
<groupId>${project.groupId}</groupId>
58+
<artifactId>patternfly-java-charts</artifactId>
59+
</dependency>
60+
<dependency>
61+
<groupId>${project.groupId}</groupId>
62+
<artifactId>patternfly-java-codeeditor</artifactId>
63+
</dependency>
64+
<dependency>
65+
<groupId>${project.groupId}</groupId>
66+
<artifactId>patternfly-java-finder</artifactId>
67+
</dependency>
68+
<dependency>
69+
<groupId>org.junit.jupiter</groupId>
70+
<artifactId>junit-jupiter</artifactId>
71+
<scope>test</scope>
72+
</dependency>
73+
</dependencies>
74+
75+
<build>
76+
<plugins>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-surefire-plugin</artifactId>
80+
<configuration>
81+
<systemPropertyVariables>
82+
<project.root>${project.basedir}/..</project.root>
83+
</systemPropertyVariables>
84+
</configuration>
85+
</plugin>
86+
<plugin>
87+
<groupId>org.apache.maven.plugins</groupId>
88+
<artifactId>maven-install-plugin</artifactId>
89+
<configuration>
90+
<skip>true</skip>
91+
</configuration>
92+
</plugin>
93+
<plugin>
94+
<groupId>org.apache.maven.plugins</groupId>
95+
<artifactId>maven-deploy-plugin</artifactId>
96+
<configuration>
97+
<skip>true</skip>
98+
</configuration>
99+
</plugin>
100+
</plugins>
101+
</build>
102+
</project>

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL