Skip to content

Commit 044d31e

Browse files
committed
docs: standardize README and add CI/CD infrastructure
- Fix Color API usage in tests (remove incorrect .color() wrapper) - Standardize README with CI badge and structured sections - Add ReadmeVerificationTests for all README code examples - Add comprehensive CI/CD workflows (macOS 5.9/6.2, Linux, Windows) - Add swift-format configuration - Add dependabot configuration - All 690 tests passing including 5 new README verification tests
1 parent 09a6815 commit 044d31e

File tree

10 files changed

+404
-45
lines changed

10 files changed

+404
-45
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "swift"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "monthly"

.github/workflows/ci.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ci-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
macos-swift59:
15+
name: macOS (Swift 5.9)
16+
runs-on: macos-26
17+
strategy:
18+
matrix:
19+
xcode: ['26.0']
20+
config: ['debug', 'release']
21+
steps:
22+
- uses: actions/checkout@v5
23+
- name: Select Xcode ${{ matrix.xcode }}
24+
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
25+
- name: Print Swift version
26+
run: swift --version
27+
- name: Cache Swift packages
28+
uses: actions/cache@v4
29+
with:
30+
path: .build
31+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
32+
restore-keys: ${{ runner.os }}-spm-
33+
- name: Build
34+
run: swift build -c ${{ matrix.config }}
35+
- name: Run tests
36+
run: swift test -c ${{ matrix.config }}
37+
38+
macos-swift62:
39+
name: macOS (Swift 6.2)
40+
runs-on: macos-26
41+
strategy:
42+
matrix:
43+
xcode: ['26.0']
44+
config: ['debug', 'release']
45+
steps:
46+
- uses: actions/checkout@v5
47+
- name: Select Xcode ${{ matrix.xcode }}
48+
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
49+
- name: Print Swift version
50+
run: swift --version
51+
- name: Cache Swift packages
52+
uses: actions/cache@v4
53+
with:
54+
path: .build
55+
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }}
56+
restore-keys: ${{ runner.os }}-spm-
57+
- name: Build
58+
run: swift build -c ${{ matrix.config }}
59+
- name: Run tests
60+
run: swift test -c ${{ matrix.config }}
61+
62+
linux-swift62:
63+
name: Ubuntu (Swift 6.2)
64+
runs-on: ubuntu-latest
65+
container: swift:6.2
66+
steps:
67+
- uses: actions/checkout@v5
68+
- name: Build
69+
run: swift build
70+
- name: Run tests
71+
run: swift test
72+
73+
windows:
74+
name: Windows (Swift 6.2)
75+
runs-on: windows-latest
76+
steps:
77+
- uses: actions/checkout@v5
78+
- uses: SwiftyLab/setup-swift@latest
79+
with:
80+
swift-version: "6.2"
81+
- name: Build
82+
run: swift build
83+
- name: Run tests
84+
run: swift test
85+
86+
readme-validation:
87+
name: README Code Examples
88+
runs-on: macos-26
89+
steps:
90+
- uses: actions/checkout@v5
91+
- name: Select Xcode
92+
run: sudo xcode-select -s /Applications/Xcode_26.0.app
93+
- name: Run README verification tests
94+
run: swift test --filter ReadmeVerificationTests

.github/workflows/swift-format.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Swift Format
2+
on:
3+
push:
4+
branches: [main]
5+
6+
jobs:
7+
format:
8+
runs-on: macos-26
9+
steps:
10+
- uses: actions/checkout@v5
11+
- name: Format code
12+
run: swift-format format --recursive --in-place Sources Tests
13+
- name: Commit changes
14+
uses: stefanzweifel/git-auto-commit-action@v7
15+
with:
16+
commit_message: "Run swift-format"

.github/workflows/swiftlint.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: SwiftLint
2+
on:
3+
pull_request:
4+
branches: [main]
5+
6+
jobs:
7+
lint:
8+
runs-on: macos-26
9+
steps:
10+
- uses: actions/checkout@v5
11+
- name: SwiftLint
12+
run: swiftlint lint
13+
continue-on-error: true

.swift-format

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": 1,
3+
"lineLength": 100,
4+
"indentation": {
5+
"spaces": 2
6+
},
7+
"respectsExistingLineBreaks": true,
8+
"lineBreakBeforeControlFlowKeywords": false,
9+
"lineBreakBeforeEachArgument": true
10+
}

README.md

Lines changed: 139 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,182 @@
11
# swift-html-css-pointfree
22

3+
[![CI](https://github.com/coenttb/swift-html-css-pointfree/workflows/CI/badge.svg)](https://github.com/coenttb/swift-html-css-pointfree/actions/workflows/ci.yml)
4+
![Development Status](https://img.shields.io/badge/status-active--development-blue.svg)
5+
6+
Integration layer combining HTML types, CSS types, and PointFree HTML rendering for type-safe web development.
7+
38
⚠️ **This is an integration package. For end-user development, please use [coenttb/swift-html](https://github.com/coenttb/swift-html) instead.**
49

510
## Overview
611

7-
This package serves as an integration layer that combines:
12+
This package provides the integration layer that bridges:
813
- [swift-html-types](https://github.com/coenttb/swift-html-types) - Type definitions for HTML elements and attributes
9-
- [swift-css-types](https://github.com/coenttb/swift-css-types) - Type definitions for CSS properties and values
14+
- [swift-css-types](https://github.com/coenttb/swift-css-types) - Type definitions for CSS properties and values
1015
- [pointfree-html](https://github.com/coenttb/pointfree-html) - HTML rendering engine
1116

12-
It provides the foundational PointFree HTML integration that powers the higher-level [swift-html](https://github.com/coenttb/swift-html) package.
17+
It serves as the foundational PointFree HTML integration layer for the [swift-html](https://github.com/coenttb/swift-html) package.
18+
19+
## Features
20+
21+
- PointFree HTML extensions for HTML elements (HTMLElements+PointFreeHTML)
22+
- PointFree HTML extensions for HTML attributes (HTMLAttributes+PointFreeHTML)
23+
- PointFree HTML extensions for CSS properties (CSS+PointFreeHTML)
24+
- Combined HTML and CSS functionality (HTML+CSS+PointFreeHTML)
25+
- Type-safe CSS property application on HTML elements
26+
- Media query support for responsive design
27+
- Pseudo-class support for interactive styling
28+
29+
## Installation
30+
31+
### For End Users
1332

14-
## For Developers
33+
**Use [coenttb/swift-html](https://github.com/coenttb/swift-html) instead.** The swift-html package provides a complete, developer-friendly API for building type-safe HTML and CSS in Swift.
1534

16-
**👉 Use [coenttb/swift-html](https://github.com/coenttb/swift-html) for your projects.**
35+
### For Package Developers
1736

18-
The `swift-html` package provides a complete, developer-friendly API for building type-safe HTML and CSS in Swift with a SwiftUI-like syntax:
37+
If you need to use this integration layer directly:
1938

2039
```swift
21-
import HTML
40+
dependencies: [
41+
.package(url: "https://github.com/coenttb/swift-html-css-pointfree", from: "0.0.1")
42+
]
43+
```
44+
45+
Then add the appropriate module to your target dependencies:
46+
47+
```swift
48+
.target(
49+
name: "YourTarget",
50+
dependencies: [
51+
.product(name: "HTMLCSSPointFreeHTML", package: "swift-html-css-pointfree"),
52+
// Or specific modules:
53+
// .product(name: "CSSPointFreeHTML", package: "swift-html-css-pointfree"),
54+
// .product(name: "HTMLElementsPointFreeHTML", package: "swift-html-css-pointfree"),
55+
// .product(name: "HTMLAttributesPointFreeHTML", package: "swift-html-css-pointfree"),
56+
]
57+
)
58+
```
59+
60+
## Quick Start
61+
62+
```swift
63+
import HTMLCSSPointFreeHTML
64+
import PointFreeHTML
2265

2366
let document = HTMLDocument {
24-
div {
25-
h1 { "Type-safe HTML" }
26-
.color(light: .blue, dark: .red)
27-
.fontSize(.px(24))
28-
p { "With type-safe CSS!" }
29-
.marginTop(.px(10))
30-
}
67+
ContentDivision {
68+
"Hello World"
69+
}
70+
.color(.red)
71+
.backgroundColor(.hex("F0F0F0"))
3172
}
73+
74+
let html = String(bytes: document.render(), encoding: .utf8)!
3275
```
3376

34-
## Package Architecture
77+
## Usage Examples
3578

36-
This integration package consists of several modules:
79+
### Applying CSS Properties
3780

38-
- **HTMLElements+PointFreeHTML** - PointFree HTML extensions for HTML elements
39-
- **HTMLAttributes+PointFreeHTML** - PointFree HTML extensions for HTML attributes
40-
- **CSS+PointFreeHTML** - PointFree HTML extensions for CSS properties
41-
- **HTML+CSS+PointFreeHTML** - Combined HTML and CSS functionality
81+
```swift
82+
import HTMLCSSPointFreeHTML
4283

43-
## Installation (Internal Use Only)
84+
// Apply color with type safety
85+
let styledDiv = ContentDivision {
86+
"Styled content"
87+
}
88+
.color(.blue)
89+
.fontSize(.px(16))
90+
.padding(.rem(1))
91+
```
4492

45-
This package is typically used as a dependency by other packages in the ecosystem. If you need to use it directly:
93+
### Media Queries
4694

4795
```swift
48-
dependencies: [
49-
.package(url: "https://github.com/coenttb/swift-html-css-pointfree", from: "0.0.1")
50-
]
96+
// Responsive styling
97+
let responsiveDiv = ContentDivision {
98+
"Responsive content"
99+
}
100+
.padding(.rem(1), media: .mobile)
101+
.padding(.rem(2), media: .tablet)
102+
.padding(.rem(3), media: .desktop)
103+
```
104+
105+
### Pseudo-Classes
106+
107+
```swift
108+
// Interactive styling
109+
let interactiveLink = Anchor(href: "/path") {
110+
"Hover me"
111+
}
112+
.color(.blue)
113+
.color(.red, pseudo: .hover)
114+
```
115+
116+
### Multiple Properties
117+
118+
```swift
119+
let complexElement = ContentDivision {
120+
Paragraph {
121+
"Complex styling"
122+
}
123+
.color(.named(.darkblue))
124+
.fontSize(.px(18))
125+
}
126+
.backgroundColor(.hex("FFFFFF"))
127+
.padding(.rem(2))
128+
.margin(.px(10))
129+
```
130+
131+
## Package Architecture
132+
133+
### Modules
134+
135+
- **CSSPointFreeHTML** - CSS property extensions for PointFree HTML elements
136+
- **HTMLElementsPointFreeHTML** - HTML element definitions with PointFree HTML support
137+
- **HTMLAttributesPointFreeHTML** - HTML attribute extensions for PointFree HTML
138+
- **HTMLCSSPointFreeHTML** - Combined HTML+CSS functionality (umbrella module)
139+
140+
### Module Dependencies
141+
142+
```
143+
HTMLCSSPointFreeHTML
144+
├── CSSPointFreeHTML
145+
│ ├── swift-css-types (CSSTypes)
146+
│ └── pointfree-html (PointFreeHTML)
147+
├── HTMLElementsPointFreeHTML
148+
│ ├── swift-html-types (HTMLElementTypes)
149+
│ ├── HTMLAttributesPointFreeHTML
150+
│ └── pointfree-html (PointFreeHTML)
151+
└── HTMLAttributesPointFreeHTML
152+
├── swift-html-types (HTMLAttributeTypes)
153+
└── pointfree-html (PointFreeHTML)
51154
```
52155

53156
## Related Packages
54157

55158
### For End Users
56-
* **[swift-html](https://www.github.com/coenttb/swift-html)** - **👈 Start here!** Complete Swift DSL for HTML and CSS
159+
* [swift-html](https://www.github.com/coenttb/swift-html) - Complete Swift DSL for type-safe HTML and CSS
57160

58161
### Foundation Packages
59-
* [swift-html-types](https://www.github.com/coenttb/swift-html-types) - HTML type definitions
60-
* [swift-css-types](https://www.github.com/coenttb/swift-css-types) - CSS type definitions
61-
* [pointfree-html](https://www.github.com/coenttb/pointfree-html) - HTML rendering engine
162+
* [swift-html-types](https://www.github.com/coenttb/swift-html-types) - Type definitions for HTML elements and attributes
163+
* [swift-css-types](https://www.github.com/coenttb/swift-css-types) - Type definitions for CSS properties and values
164+
* [pointfree-html](https://www.github.com/coenttb/pointfree-html) - Efficient HTML rendering engine
62165

63-
## Contribution
166+
## License
167+
168+
This project is licensed under the Apache 2.0 License. See [LICENSE](LICENSE) for details.
169+
170+
## Contributing
64171

65172
Contributions are welcome! Please feel free to submit a Pull Request.
66173

67174
## Feedback
68175

69-
If you have suggestions or find issues, please open a GitHub issue. Your feedback helps make this project better for everyone.
176+
If you have suggestions or find issues, please open a GitHub issue.
70177

71178
> [Subscribe to my newsletter](http://coenttb.com/en/newsletter/subscribe)
72179
>
73180
> [Follow me on X](http://x.com/coenttb)
74-
>
181+
>
75182
> [Connect on LinkedIn](https://www.linkedin.com/in/tenthijeboonkkamp)
76-
77-
## License
78-
79-
This project is licensed under the Apache 2.0 License. See [LICENSE](LICENSE) for details.

Tests/CSSPointFreeHTML Tests/AccentColor Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct AccentColorTests {
2222
func htmlElementWithAccentColorRendersCorrectly() {
2323
assertInlineSnapshot(
2424
of: HTMLDocument {
25-
div.accentColor(.color(.red))
25+
div.accentColor(.red)
2626
},
2727
as: .html
2828
) {

0 commit comments

Comments
 (0)