From 29ecb3077b7ad04ce0065cbfe31390750d8a587a Mon Sep 17 00:00:00 2001
From: david-swift
Date: Sun, 9 Jun 2024 12:01:23 +0200
Subject: [PATCH] Modernize repo
---
.github/workflows/docs.yml | 45 +++++++++++
Contributors.md | 3 -
Documentation/Reference/README.md | 18 -----
.../Reference/enums/EditOperation.md | 23 ------
.../enums/LevenshteinTransformations.md | 32 --------
.../Reference/enums/Transformation.md | 46 ------------
Documentation/Reference/extensions/Array.md | 42 -----------
Documentation/Reference/extensions/String.md | 23 ------
Documentation/Reference/structs/Functions.md | 27 -------
Makefile | 5 --
README.md | 65 ++--------------
.../GettingStarted.md | 74 +++++++++++++++++++
.../LevenshteinTransformations.md | 9 +++
.../theme-settings.json | 31 ++++++++
14 files changed, 164 insertions(+), 279 deletions(-)
create mode 100644 .github/workflows/docs.yml
delete mode 100644 Contributors.md
delete mode 100644 Documentation/Reference/README.md
delete mode 100644 Documentation/Reference/enums/EditOperation.md
delete mode 100644 Documentation/Reference/enums/LevenshteinTransformations.md
delete mode 100644 Documentation/Reference/enums/Transformation.md
delete mode 100644 Documentation/Reference/extensions/Array.md
delete mode 100644 Documentation/Reference/extensions/String.md
delete mode 100644 Documentation/Reference/structs/Functions.md
delete mode 100644 Makefile
create mode 100644 Sources/LevenshteinTransformations/LevenshteinTransformations.docc/GettingStarted.md
create mode 100644 Sources/LevenshteinTransformations/LevenshteinTransformations.docc/LevenshteinTransformations.md
create mode 100644 Sources/LevenshteinTransformations/LevenshteinTransformations.docc/theme-settings.json
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
new file mode 100644
index 0000000..2e76983
--- /dev/null
+++ b/.github/workflows/docs.yml
@@ -0,0 +1,45 @@
+name: Deploy Docs
+
+on:
+ push:
+ branches: ["main"]
+
+permissions:
+ contents: read
+ pages: write
+ id-token: write
+
+concurrency:
+ group: "pages"
+ cancel-in-progress: true
+
+jobs:
+ Deploy:
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ runs-on: macos-14
+ steps:
+ - uses: actions/checkout@v4
+ - name: Build Docs
+ run: |
+ xcrun xcodebuild docbuild \
+ -scheme LevenshteinTransformations \
+ -destination 'generic/platform=macOS' \
+ -derivedDataPath "$PWD/.derivedData" \
+ -skipPackagePluginValidation
+ xcrun docc process-archive transform-for-static-hosting \
+ "$PWD/.derivedData/Build/Products/Debug/LevenshteinTransformations.doccarchive" \
+ --output-path "docs" \
+ --hosting-base-path "LevenshteinTransformations"
+ - name: Modify Docs
+ run: |
+ echo "" > docs/index.html;
+ sed -i '' 's/,2px/,10px/g' docs/css/index.038e887c.css
+ - name: Upload Artifact
+ uses: actions/upload-pages-artifact@v3
+ with:
+ path: 'docs'
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v4
diff --git a/Contributors.md b/Contributors.md
deleted file mode 100644
index 3cf3f03..0000000
--- a/Contributors.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Contributors
-
-- [david-swift](https://github.com/david-swift)
diff --git a/Documentation/Reference/README.md b/Documentation/Reference/README.md
deleted file mode 100644
index 3bb36d5..0000000
--- a/Documentation/Reference/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# Reference Documentation
-
-## Structs
-
-- [Functions](structs/Functions.md)
-
-## Enums
-
-- [EditOperation](enums/EditOperation.md)
-- [LevenshteinTransformations](enums/LevenshteinTransformations.md)
-- [Transformation](enums/Transformation.md)
-
-## Extensions
-
-- [Array](extensions/Array.md)
-- [String](extensions/String.md)
-
-This file was generated by [SourceDocs](https://github.com/eneko/SourceDocs)
\ No newline at end of file
diff --git a/Documentation/Reference/enums/EditOperation.md b/Documentation/Reference/enums/EditOperation.md
deleted file mode 100644
index 5693115..0000000
--- a/Documentation/Reference/enums/EditOperation.md
+++ /dev/null
@@ -1,23 +0,0 @@
-**ENUM**
-
-# `EditOperation`
-
-An edit operation is a transformation without parameters.
-Additionally, it has the case `noChange`.
-
-## Cases
-### `noChange`
-
-No operation.
-
-### `replace`
-
-A replace operation.
-
-### `delete`
-
-A delete operation.
-
-### `insert`
-
-An insert operation.
diff --git a/Documentation/Reference/enums/LevenshteinTransformations.md b/Documentation/Reference/enums/LevenshteinTransformations.md
deleted file mode 100644
index 411f6de..0000000
--- a/Documentation/Reference/enums/LevenshteinTransformations.md
+++ /dev/null
@@ -1,32 +0,0 @@
-**ENUM**
-
-# `LevenshteinTransformations`
-
-The enumeration holding the transformation functions.
-
-## Methods
-### `levenshteinTransformations(from:to:)`
-
-The transformation function for arrays with equatable elements.
-- Parameters:
- - source: The original array.
- - target: The target array.
-- Returns: The required transformations.
-
-### `setOperations(_:editDistances:source:target:)`
-
-Set the operations and edit distances according to the source and target array.
-- Parameters:
- - operations: The operations.
- - editDistances: The edit distances.
- - source: The original array.
- - target: The target array.
-- Returns: The required transformations.
-
-### `levenshteinTransformations(from:to:)`
-
-The transformation function for arrays with identifiable elements.
-- Parameters:
- - source: The original array.
- - target: The target array.
-- Returns: The required transformations.
diff --git a/Documentation/Reference/enums/Transformation.md b/Documentation/Reference/enums/Transformation.md
deleted file mode 100644
index 3fee017..0000000
--- a/Documentation/Reference/enums/Transformation.md
+++ /dev/null
@@ -1,46 +0,0 @@
-**ENUM**
-
-# `Transformation`
-
-A transformation (replace, delete or insert).
-
-## Cases
-### `replace(at:with:)`
-
-Replace the element at a certain index with a certain element.
-
-### `delete(at:)`
-
-Delete the element at a certain index.
-
-### `insert(at:element:)`
-
-Insert a certain element at a certain index.
-
-## Properties
-### `index`
-
-The index at which is directly affected by the transformation.
-
-### `element`
-
-The element which is directly affected by the transformation.
-
-## Methods
-### `description(source:)`
-
-A description of the transformation.
-- Parameter source: The initial array.
-- Returns: The description.
-
-### `log(source:)`
-
-Print a description of the transformation.
-- Parameter source: The initial array.
-
-### `transform(functions:nextTransformations:)`
-
-Apply the transformation using a functions value.
-- Parameters:
- - functions: The functions value.
- - nextTransformations: All the following transformations for modifying the indices.
diff --git a/Documentation/Reference/extensions/Array.md b/Documentation/Reference/extensions/Array.md
deleted file mode 100644
index e2828c6..0000000
--- a/Documentation/Reference/extensions/Array.md
+++ /dev/null
@@ -1,42 +0,0 @@
-**EXTENSION**
-
-# `Array`
-
-## Methods
-### `levenshteinDistance(to:)`
-
-Calculate the Levenshtein distance to another array.
-- Parameter target: The target array.
-- Returns: The Levenshtein distance.
-
-### `getTransformations(to:)`
-
-Get the transformations needed to transform the array into the target array.
-- Parameter target: The target array.
-- Returns: The transformations.
-
-### `transform(to:functions:)`
-
-Call every transformation step needed to transform the array into the target array.
-- Parameters:
- - target: The target array.
- - functions: The transformation functions.
-
-### `identifiableLevenshteinDistance(to:)`
-
-Calculate the Levenshtein distance to another array.
-- Parameter target: The target array.
-- Returns: The Levenshtein distance.
-
-### `identifiableGetTransformations(to:)`
-
-Get the transformations needed to transform the array into the target array.
-- Parameter target: The target array.
-- Returns: The transformations.
-
-### `identifiableTransform(to:functions:)`
-
-Call every transformation step needed to transform the array into the target array.
-- Parameters:
- - target: The target array.
- - functions: The transformation functions.
diff --git a/Documentation/Reference/extensions/String.md b/Documentation/Reference/extensions/String.md
deleted file mode 100644
index 9359b98..0000000
--- a/Documentation/Reference/extensions/String.md
+++ /dev/null
@@ -1,23 +0,0 @@
-**EXTENSION**
-
-# `String`
-
-## Methods
-### `levenshteinDistance(to:)`
-
-Calculate the Levenshtein distance to another string.
-- Parameter target: The target string.
-- Returns: The Levenshtein distance.
-
-### `getTransformations(to:)`
-
-Get the transformations needed to transform the string into the target string.
-- Parameter target: The target string.
-- Returns: The transformations.
-
-### `transform(to:functions:)`
-
-Call every transformation step needed to transform the string into the target string.
-- Parameters:
- - target: The target string.
- - functions: The transformation functions.
diff --git a/Documentation/Reference/structs/Functions.md b/Documentation/Reference/structs/Functions.md
deleted file mode 100644
index badac35..0000000
--- a/Documentation/Reference/structs/Functions.md
+++ /dev/null
@@ -1,27 +0,0 @@
-**STRUCT**
-
-# `Functions`
-
-The replace, delete and insert functions type.
-
-## Properties
-### `replace`
-
-The replace function.
-
-### `delete`
-
-The delete function.
-
-### `insert`
-
-The insert function.
-
-## Methods
-### `init(replace:delete:insert:)`
-
-Initialize a functions value.
-- Parameters:
- - replace: Replace the element at a certain index with a certain element.
- - delete: Delete the element at a certain index.
- - insert: Insert a certain element at a certain index.
diff --git a/Makefile b/Makefile
deleted file mode 100644
index e6d4dd2..0000000
--- a/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-docs:
- @sourcedocs generate --min-acl private -r --spm-module LevenshteinTransformations
-
-swiftlint:
- @swiftlint --autocorrect
diff --git a/README.md b/README.md
index f14b739..451da39 100644
--- a/README.md
+++ b/README.md
@@ -4,12 +4,12 @@
-
- GitHub
+
+ Documentation
·
-
- Contributor Docs
+
+ GitHub
@@ -32,65 +32,10 @@ Transform an array into any other array of the same type, or a string into any o
## Usage
-```swift
-let source = [1, 2, 5, 6]
-let target = [0, 1, 5, 6, 10]
-```
-
-There are three functions available for arrays containing elements conforming to `Equatable` and strings.
-
-### Arrays with `Equatable` Elements and Strings
-
-#### Levenshtein Distance
-Get the Levenshtein distance with `levenshteinDistance(to:)`:
-```swift
-print(source.levenshteinDistance(to: target))
-```
-This example outputs `3`.
-
-#### Transformation Steps
-Get the individual transformation steps with `getTransformations(to:)`.
-```swift
-print(source.getTransformations(to: target).map { $0.description(source: source) }.joined(separator: "\n"))
-```
-This example prints the descriptions of the transformations:
-```
-Replace '1' at position 0 with '0'
-Replace '2' at position 1 with '1'
-Insert '10' at position 4
-```
-
-#### Run Functions for the Steps
-Directly run functions for the `replace`, `delete` and `insert` transformations using the `transform(to:functions:)` function.
-```swift
-var modified = source
-
-source.transform(
- to: target,
- functions: .init { index, element in
- modified[index] = element
- } delete: { index in
- modified.remove(at: index)
- } insert: { index, element in
- modified.insert(element, at: index)
- }
-)
-
-print(modified == target)
-```
-This example outputs `true`.
-
-### Arrays with `Identifiable` Elements
-
-The same functions are available for arrays with identifiable elements, but they are named differently to avoid conflicts:
-- `identifiableLevenshteinDistance(to:)`
-- `identifiableGetTransformations(to:)`
-- `identifiableTransform(to:functions:)`
+Read the [Getting Started](https://david-swift.github.io/LevenshteinTransformations/documentation/levenshteintransformations/gettingstarted) article to learn how to use this package.
## Thanks
-- The [contributors](Contributors.md)
- [SwiftLint](https://github.com/realm/SwiftLint) for checking whether code style conventions are violated
- The programming language [Swift](https://github.com/apple/swift)
-- [SourceDocs](https://github.com/SourceDocs/SourceDocs) used for generating the [docs](Documentation/Reference/README.md)
diff --git a/Sources/LevenshteinTransformations/LevenshteinTransformations.docc/GettingStarted.md b/Sources/LevenshteinTransformations/LevenshteinTransformations.docc/GettingStarted.md
new file mode 100644
index 0000000..9616e8b
--- /dev/null
+++ b/Sources/LevenshteinTransformations/LevenshteinTransformations.docc/GettingStarted.md
@@ -0,0 +1,74 @@
+# Getting started
+
+Learn how to use _Levenshtein Transformations_.
+
+## Installation
+
+1. Open your Swift package in GNOME Builder, Xcode, or any other IDE.
+2. Open the `Package.swift` file.
+3. Into the `Package` initializer, under `dependencies`, paste:
+```swift
+.package(url: "https://github.com/david-swift/LevenshteinTransformations", from: "0.1.0")
+```
+
+## Usage
+
+```swift
+let source = [1, 2, 5, 6]
+let target = [0, 1, 5, 6, 10]
+```
+
+There are three functions available for arrays containing elements conforming to `Equatable` and strings.
+
+### Arrays with Equatable Elements and Strings
+
+#### Levenshtein Distance
+Get the Levenshtein distance with ``Swift/Array/levenshteinDistance(to:)`` (for strings: ``Swift/String/levenshteinDistance(to:)``).
+```swift
+print(source.levenshteinDistance(to: target))
+```
+This example outputs `3`.
+
+#### Transformation Steps
+Get the individual transformation steps with ``Swift/Array/getTransformations(to:)`` (for strings: ``Swift/String/getTransformations(to:)``).
+```swift
+print(source.getTransformations(to: target).map { $0.description(source: source) }.joined(separator: "\n"))
+```
+This example prints the descriptions of the transformations:
+```
+Replace '1' at position 0 with '0'
+Replace '2' at position 1 with '1'
+Insert '10' at position 4
+```
+
+#### Run Functions for the Steps
+Directly run functions for the `replace`, `delete` and `insert` transformations using the ``Swift/Array/transform(to:functions:)`` (for strings: ``Swift/String/transform(to:functions:)``) function.
+```swift
+var modified = source
+
+source.transform(
+ to: target,
+ functions: .init { index, element in
+ modified[index] = element
+ } delete: { index in
+ modified.remove(at: index)
+ } insert: { index, element in
+ modified.insert(element, at: index)
+ }
+)
+
+print(modified == target)
+```
+This example outputs `true`.
+
+### Arrays with Identifiable Elements
+
+The same functions are available for arrays with identifiable elements, but they are named differently to avoid conflicts:
+- ``Swift/Array/identifiableLevenshteinDistance(to:)``
+- ``Swift/Array/identifiableGetTransformations(to:)``
+- ``Swift/Array/identifiableTransform(to:functions:)``
+
+## Development
+_Levenshtein Transformations_ is an open source project. Visit the [GitHub repository][1] for bug reports, feature requests, pull requests and more information.
+
+[1]: https://github.com/david-swift/LevenshteinTransformations
diff --git a/Sources/LevenshteinTransformations/LevenshteinTransformations.docc/LevenshteinTransformations.md b/Sources/LevenshteinTransformations/LevenshteinTransformations.docc/LevenshteinTransformations.md
new file mode 100644
index 0000000..4ea6b0b
--- /dev/null
+++ b/Sources/LevenshteinTransformations/LevenshteinTransformations.docc/LevenshteinTransformations.md
@@ -0,0 +1,9 @@
+# ``LevenshteinTransformations``
+
+_Levenshtein Transformations_ allows transforming one array into another array, or a string into another string, using only the three transformations `replace`, `delete`, and `insert`.
+
+## Topics
+
+### Articles
+
+-
diff --git a/Sources/LevenshteinTransformations/LevenshteinTransformations.docc/theme-settings.json b/Sources/LevenshteinTransformations/LevenshteinTransformations.docc/theme-settings.json
new file mode 100644
index 0000000..a297694
--- /dev/null
+++ b/Sources/LevenshteinTransformations/LevenshteinTransformations.docc/theme-settings.json
@@ -0,0 +1,31 @@
+{
+ "theme": {
+ "border-radius": "10px",
+ "button": {
+ "border-radius": "20px"
+ },
+ "color": {
+ "button-background": "#3490EC",
+ "button-background-active": "#3490EC",
+ "button-background-hover": "#5688FD",
+ "button-text": "#ffffff",
+ "header": "#323F80",
+ "documentation-intro-accent": "var(--color-header)",
+ "documentation-intro-fill": "radial-gradient(circle at top, var(--color-header) 30%, #000 100%)",
+ "link": "#3490EC",
+ "nav-link-color": "#3490EC",
+ "nav-dark-link-color": "#3490EC",
+ "tabnav-item-border-color": "#3490EC",
+ "fill-light-blue-secondary": "#3490EC",
+ "fill-blue": "#3490EC",
+ "figure-blue": "#3490EC",
+ "standard-blue-documentation-intro-fill": "#3490EC",
+ "figure-blue": "#3490EC",
+ "navigator-item-hover": {
+ "light": "#3490EC15",
+ "dark": "#2B466F"
+ }
+ },
+ "additionalProperties": "#3490EC"
+ }
+}