Skip to content

Commit 5b9d7b5

Browse files
committed
Added
1 parent 2604409 commit 5b9d7b5

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
ph-css is a Java-based CSS 3 parser and builder library (v8.1.2-SNAPSHOT). It parses CSS into a Java object model, supports traversal/modification via the visitor pattern, and can serialize back to CSS. The companion module `ph-csscompress-maven-plugin` provides build-time CSS compression.
8+
9+
## Build Commands
10+
11+
```bash
12+
# Full build (requires Java 17+, Maven 3.x)
13+
mvn clean install
14+
15+
# Run all tests
16+
mvn test
17+
18+
# Run a single test class
19+
mvn -pl ph-css test -Dtest=CSSReaderFuncTest
20+
21+
# Run a single test method
22+
mvn -pl ph-css test -Dtest=CSSReaderFuncTest#testReadBadButSucceeding
23+
24+
# Build only the main library
25+
mvn -pl ph-css clean install
26+
27+
# Build only the Maven plugin
28+
mvn -pl ph-csscompress-maven-plugin clean install
29+
30+
# Check license headers
31+
mvn license:check
32+
```
33+
34+
## Module Structure
35+
36+
- **`ph-css/`** - Core library: CSS parsing, object model, and serialization
37+
- **`ph-csscompress-maven-plugin/`** - Maven Mojo for CSS compression at build time
38+
39+
## Architecture
40+
41+
### Parser (JavaCC-generated)
42+
43+
Grammar files in `ph-css/src/main/jjtree/`:
44+
- `ParserCSS30.jjt` - Main CSS 3.0 grammar
45+
- `ParserCSSCharsetDetector.jjt` - Charset detection
46+
47+
JavaCC generates parser sources into `target/generated-sources/jjtree` and `target/generated-sources/javacc`. Do not edit generated parser files directly; modify the `.jjt` grammars instead.
48+
49+
### Core Package Layout (`com.helger.css`)
50+
51+
| Package | Purpose |
52+
|---------|---------|
53+
| `decl` | CSS object model: `CascadingStyleSheet`, style/media/font-face/keyframes rules, declarations |
54+
| `decl.visit` | Visitor pattern interfaces and implementations for CSS traversal |
55+
| `decl.shorthand` | Shorthand CSS property expansion |
56+
| `reader` | `CSSReader` (full stylesheets), `CSSReaderDeclarationList` (inline styles) |
57+
| `reader.errorhandler` | Parse error handlers (logging, collecting, throwing) |
58+
| `writer` | `CSSWriter` for serializing the object model back to CSS text |
59+
| `parser` | JavaCC-generated parser classes (do not edit manually) |
60+
| `property` | CSS property definitions and metadata (`ECSSProperty`, `CCSSProperties`) |
61+
| `propertyvalue` | Typed CSS values (colors, functions, URIs, etc.) |
62+
| `media` | Media query model and `ECSSMedium` enum |
63+
| `tools` | Utilities like `MediaQueryTools` |
64+
| `utils` | Helpers for colors, numbers, URLs, rectangles |
65+
| `annotation` | Custom annotations (`@DeprecatedInCSS`) |
66+
| `handler` | Exception handlers for the parser |
67+
68+
### Read/Write Flow
69+
70+
1. **Reading**: `CSSReader.readFromString/File/Stream()` -> JavaCC parser -> `CascadingStyleSheet` object model
71+
2. **Manipulation**: Visitor pattern via `ICSSVisitor` / `DefaultCSSVisitor` on the object model
72+
3. **Writing**: `CSSWriter.getCSSAsString(CascadingStyleSheet)` -> CSS text output, controlled by `CSSWriterSettings` (minified/formatted, version)
73+
74+
### Key Dependencies
75+
76+
- `ph-commons` (12.1.5) - Collection types (`ICommonsList`, `CommonsArrayList`), I/O utilities, type conversion
77+
- `ph-javacc-maven-plugin` (5.0.1) - Parser generation from `.jjt` grammars
78+
- JUnit 4 for tests
79+
80+
## Test Resources
81+
82+
CSS test files live in `ph-css/src/test/resources/testfiles/css30/`:
83+
- `good/` - Valid CSS files (used to verify successful parsing)
84+
- `bad/` - Invalid CSS files (expected to fail parsing)
85+
- `bad_but_succeeding/` - Invalid CSS that the parser recovers from
86+
- `bad_but_browsercompliant/` - Invalid CSS that browsers accept
87+
88+
## Coding Conventions
89+
90+
See the global rules in `~/.claude/rules/naming.md` for Hungarian notation, formatting, and naming. Key project-specific points:
91+
- OSGi bundle packaging (`<packaging>bundle</packaging>`) via `maven-bundle-plugin`
92+
- Apache 2.0 license header required on all Java files (enforced by `license-maven-plugin`)
93+
- Forbidden APIs plugin blocks unsafe/deprecated JDK usage

0 commit comments

Comments
 (0)