Skip to content

Commit 92b5602

Browse files
authored
Add api documentation by using swifts docc (#94)
* Bump the minimum swift version to 5.6 * Add swifts docc to document the api * Remove the old instructions * Add articles to the documentation catalog * Add a manifest file for swiftpackageindex * Remove script files
1 parent 4167857 commit 92b5602

21 files changed

+100
-286
lines changed

.spi.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version: 1
2+
builder:
3+
configs:
4+
- documentation_targets: [HTMLKit]

Instructions/Example/Page/Contexts/CreateContext.swift

-4
This file was deleted.

Instructions/Example/Page/Contexts/IndexContext.swift

-4
This file was deleted.

Instructions/Example/Page/Controllers/SimpleController.swift

-24
This file was deleted.

Instructions/Example/Page/Views/Shared/SimplePage.swift

-24
This file was deleted.

Instructions/Example/Page/Views/SimpleTemplate.swift

-33
This file was deleted.

Instructions/Installation.md

-51
This file was deleted.

Instructions/Overview.md

-50
This file was deleted.

Package.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// swift-tools-version:5.4
2-
// The swift-tools-version declares the minimum version of Swift required to build this package.
1+
// swift-tools-version:5.6
32

43
import PackageDescription
54

@@ -17,6 +16,7 @@ let package = Package(
1716
dependencies: [
1817
.package(url: "https://github.com/miroslavkovac/Lingo.git", from: "3.1.0"),
1918
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.1"),
19+
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")
2020
],
2121
targets: [
2222
.target(

Scripts/DocCoverage/Instructions.md

-2
This file was deleted.

Scripts/DocCoverage/check-percentage.sh

-11
This file was deleted.

Scripts/circle.yml

-17
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Getting started
2+
3+
Learn how to use it.
4+
5+
### Requirements
6+
7+
HTMLKit requires Swift 5.6 or higher.
8+
9+
### Installation
10+
11+
To use HTMLKit in your project, you have to add the package as dependency to your package description first. Be sure to add it as your desired targets as well.
12+
13+
```swift
14+
let package = Package(
15+
...
16+
dependencies: [
17+
// 1. Add the package
18+
.package(url: "https://github.com/vapor-community/HTMLKit.git", from: "2.6.0"),
19+
],
20+
targets: [
21+
.target(
22+
...
23+
dependencies: [
24+
/// 2. Add the product
25+
.product(name: "HTMLKit", package: "HTMLKit"),
26+
]
27+
),
28+
...
29+
]
30+
)
31+
```
32+
33+
From time to time you want to update the package. You can do it, by changing the version tag manually and saving it. You find the current version tag in the [release history](https://github.com/vapor-community/HTMLKit/releases). We recommand to read the release description first, to understand the possible changes.
34+
35+
### Usage
36+
37+
Use the import keyword to load the module in your project files.
38+
39+
```swift
40+
import HTMLKit
41+
...
42+
```

Instructions/Essential/Context.md Sources/HTMLKit/Documentation.docc/Essentials/Parts/Context.md

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
# Context
22

3-
The context is
4-
5-
## Essential
6-
7-
### Definition
3+
## Overview
84

95
```swift
10-
/// [SimpleContext.swift]
11-
126
struct SimpleContext: Codable {
137

148
var headline: String
@@ -17,8 +11,6 @@ struct SimpleContext: Codable {
1711
```
1812

1913
```swift
20-
/// [SimpleView.swift]
21-
2214
struct SimpleView: View {
2315

2416
@TemplateValue(SimpleContext.self)

Instructions/Essential/Elements.md Sources/HTMLKit/Documentation.docc/Essentials/Parts/Elements.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Elements
22

3-
The elements in HTMLKit represent the official HTML elements. Elements with content use the curly brackets, while elements without content use the round brackets. To add attributes to the element use the offered functions.
3+
## Overview
44

5-
## Essential
5+
The elements in HTMLKit represent the official HTML elements. Elements with content use the curly brackets, while elements without content use the round brackets. To add attributes to the element use the offered functions.
66

77
### Definition
88

@@ -50,8 +50,6 @@ Body {
5050
To prevent invalid code, each element owns a element definition. For example the element `Heading1` is a type of `BodyElement`, so it is only allowed to be placed in the `Body` element. See the [wiki](https://github.com/vapor-community/HTMLKit/wiki) for more element definitions.
5151

5252
```swift
53-
/// [BodyElements.swift]
54-
5553
public struct Heading1: ContentNode, BodyElement {
5654
...
5755
}

Instructions/Essential/Layouts.md Sources/HTMLKit/Documentation.docc/Essentials/Parts/Layouts.md

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# Layouts
22

3+
## Overview
4+
35
Layouts allow to define a website template. It is used to provide a consistend look.
46

57
## Page
68

79
The page is the entry point of the site. It should be used to package the views.
810

9-
### Definition
10-
1111
```swift
12-
/// [SimplePage.swift]
13-
1412
struct SimplePage: Page {
1513

1614
var body: AnyContent {
@@ -32,11 +30,7 @@ struct SimplePage: Page {
3230

3331
The view is a partial view of the page. It should be used to display data using the context.
3432

35-
### Definition
36-
3733
```swift
38-
/// [SimpleView.swift]
39-
4034
struct SimpleView: View {
4135

4236
@TemplateValue(SimpleContext.self)
@@ -50,19 +44,13 @@ struct SimpleView: View {
5044
}
5145
```
5246

53-
### Context
54-
5547
The context as an object holds the information for the view. ... See [Context](https://github.com/vapor-community/HTMLKit/blob/master/Instructions/Essential/Context.md) to learn more about it.
5648

5749
## Component
5850

5951
The component is a reusable portion of a page. It should be used to break up large files into smaller components.
6052

61-
### Definition
62-
6353
```swift
64-
/// [SimpleComponent.swift]
65-
6654
struct SimpleComponent: Component {
6755

6856
var body: AnyContent {

0 commit comments

Comments
 (0)