Skip to content

Commit

Permalink
Add api documentation by using swifts docc (#94)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mattesmohr authored Sep 9, 2022
1 parent 4167857 commit 92b5602
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 286 deletions.
4 changes: 4 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [HTMLKit]
4 changes: 0 additions & 4 deletions Instructions/Example/Page/Contexts/CreateContext.swift

This file was deleted.

4 changes: 0 additions & 4 deletions Instructions/Example/Page/Contexts/IndexContext.swift

This file was deleted.

24 changes: 0 additions & 24 deletions Instructions/Example/Page/Controllers/SimpleController.swift

This file was deleted.

24 changes: 0 additions & 24 deletions Instructions/Example/Page/Views/Shared/SimplePage.swift

This file was deleted.

33 changes: 0 additions & 33 deletions Instructions/Example/Page/Views/SimpleTemplate.swift

This file was deleted.

51 changes: 0 additions & 51 deletions Instructions/Installation.md

This file was deleted.

50 changes: 0 additions & 50 deletions Instructions/Overview.md

This file was deleted.

4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// swift-tools-version:5.4
// The swift-tools-version declares the minimum version of Swift required to build this package.
// swift-tools-version:5.6

import PackageDescription

Expand All @@ -17,6 +16,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/miroslavkovac/Lingo.git", from: "3.1.0"),
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.1"),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0")
],
targets: [
.target(
Expand Down
2 changes: 0 additions & 2 deletions Scripts/DocCoverage/Instructions.md

This file was deleted.

11 changes: 0 additions & 11 deletions Scripts/DocCoverage/check-percentage.sh

This file was deleted.

17 changes: 0 additions & 17 deletions Scripts/circle.yml

This file was deleted.

42 changes: 42 additions & 0 deletions Sources/HTMLKit/Documentation.docc/Essentials/Getting_started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Getting started

Learn how to use it.

### Requirements

HTMLKit requires Swift 5.6 or higher.

### Installation

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.

```swift
let package = Package(
...
dependencies: [
// 1. Add the package
.package(url: "https://github.com/vapor-community/HTMLKit.git", from: "2.6.0"),
],
targets: [
.target(
...
dependencies: [
/// 2. Add the product
.product(name: "HTMLKit", package: "HTMLKit"),
]
),
...
]
)
```

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.

### Usage

Use the import keyword to load the module in your project files.

```swift
import HTMLKit
...
```
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# Context

The context is

## Essential

### Definition
## Overview

```swift
/// [SimpleContext.swift]

struct SimpleContext: Codable {

var headline: String
Expand All @@ -17,8 +11,6 @@ struct SimpleContext: Codable {
```

```swift
/// [SimpleView.swift]

struct SimpleView: View {

@TemplateValue(SimpleContext.self)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Elements

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.
## Overview

## Essential
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.

### Definition

Expand Down Expand Up @@ -50,8 +50,6 @@ Body {
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.

```swift
/// [BodyElements.swift]

public struct Heading1: ContentNode, BodyElement {
...
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Layouts

## Overview

Layouts allow to define a website template. It is used to provide a consistend look.

## Page

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

### Definition

```swift
/// [SimplePage.swift]

struct SimplePage: Page {

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

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

### Definition

```swift
/// [SimpleView.swift]

struct SimpleView: View {

@TemplateValue(SimpleContext.self)
Expand All @@ -50,19 +44,13 @@ struct SimpleView: View {
}
```

### Context

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.

## Component

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

### Definition

```swift
/// [SimpleComponent.swift]

struct SimpleComponent: Component {

var body: AnyContent {
Expand Down
Loading

0 comments on commit 92b5602

Please sign in to comment.