Skip to content

Commit

Permalink
Merge pull request #2 from john-mueller/documentation
Browse files Browse the repository at this point in the history
Added documentation comments
  • Loading branch information
john-mueller authored Feb 14, 2020
2 parents 83e9118 + 51963b2 commit 35621b3
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 52 deletions.
2 changes: 0 additions & 2 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
disabled_rules:
- trailing_comma
- orphaned_doc_comment

excluded:
- .build
- Tests/TidyHTMLPublishStepTests/Helpers/XCTestManifests.swift
- Tests/LinuxMain.swift
8 changes: 3 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// swift-tools-version:5.1

/**
* TidyHTMLPublishStep
* © 2020 John Mueller
* MIT license, see LICENSE.md for details
*/
// TidyHTMLPublishStep
// © 2020 John Mueller
// MIT license, see LICENSE.md for details

import PackageDescription

Expand Down
20 changes: 12 additions & 8 deletions Sources/TidyHTMLPublishStep/TidyHTMLPublishStep.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
/**
* TidyHTMLPublishStep
* © 2020 John Mueller
* MIT license, see LICENSE.md for details
*/
// TidyHTMLPublishStep
// © 2020 John Mueller
// MIT license, see LICENSE.md for details

import Plot
import Publish
import SwiftSoup

extension PublishingStep {
public static func tidyHTML(indentedBy indent: Indentation.Kind? = nil) -> Self {
/// Tidy and indent all generated HTML files.
///
/// - Important: This step must be run *after* HTML generation.
///
/// - Parameters:
/// - indentation: How each HTML file should be indented. Defaults to one space if not specified.
public static func tidyHTML(indentedBy indentation: Indentation.Kind? = nil) -> Self {
.step(named: "Tidy HTML") { context in
do {
let root = try context.folder(at: "")
Expand All @@ -20,7 +24,7 @@ extension PublishingStep {
let html = try file.readAsString()

let outputSettings = OutputSettings()
switch indent {
switch indentation {
case let .spaces(num), let .tabs(num):
outputSettings.indentAmount(indentAmount: UInt(num))
default:
Expand All @@ -32,7 +36,7 @@ extension PublishingStep {

var tidyHTML = try doc.html()

if case .tabs = indent {
if case .tabs = indentation {
var isPreCode = false
tidyHTML = tidyHTML.components(separatedBy: .newlines).map { line in
if isPreCode {
Expand Down
12 changes: 5 additions & 7 deletions Sources/TidyHTMLPublishStep/Website+PostGenerationSteps.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/**
* TidyHTMLPublishStep
* © 2019 John Sundell, 2020 John Mueller
* MIT license, see LICENSE.md for details
*
* This file was adapted from the Publish API
*/
// TidyHTMLPublishStep
// © 2019 John Sundell, 2020 John Mueller
// MIT license, see LICENSE.md for details
//
// This file was adapted from the Publish API

import Plot
import Publish
Expand Down
8 changes: 3 additions & 5 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* TidyHTMLPublishStep
* © 2020 John Mueller
* MIT license, see LICENSE.md for details
*/
// TidyHTMLPublishStep
// © 2020 John Mueller
// MIT license, see LICENSE.md for details

import Foundation

Expand Down
12 changes: 5 additions & 7 deletions Tests/TidyHTMLPublishStepTests/Helpers/HTMLFactoryMock.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/**
* TidyHTMLPublishStep
* © 2019 John Sundell, 2020 John Mueller
* MIT license, see LICENSE.md for details
*
* This file was copied as-is from the Publish test target
*/
// TidyHTMLPublishStep
// © 2019 John Sundell, 2020 John Mueller
// MIT license, see LICENSE.md for details
//
// This file was copied as-is from the Publish test target

import Plot
import Publish
Expand Down
12 changes: 5 additions & 7 deletions Tests/TidyHTMLPublishStepTests/Helpers/TidyHTMLTestCase.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/**
* TidyHTMLPublishStep
* © 2019 John Sundell, 2020 John Mueller
* MIT license, see LICENSE.md for details
*
* This file was adapted from the Publish test target
*/
// TidyHTMLPublishStep
// © 2019 John Sundell, 2020 John Mueller
// MIT license, see LICENSE.md for details
//
// This file was adapted from the Publish test target

import Files
import Plot
Expand Down
8 changes: 3 additions & 5 deletions Tests/TidyHTMLPublishStepTests/Helpers/TidyHTMLWebsite.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* TidyHTMLPublishStep
* © 2020 John Mueller
* MIT license, see LICENSE.md for details
*/
// TidyHTMLPublishStep
// © 2020 John Mueller
// MIT license, see LICENSE.md for details

import Foundation
import Plot
Expand Down
10 changes: 4 additions & 6 deletions Tests/TidyHTMLPublishStepTests/TidyHTMLPublishStepTests.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* TidyHTMLPublishStep
* © 2020 John Mueller
* MIT license, see LICENSE.md for details
*/
// TidyHTMLPublishStep
// © 2020 John Mueller
// MIT license, see LICENSE.md for details

import Plot
import Publish
Expand All @@ -21,7 +19,7 @@ final class TidyHTMLPublishStepTests: TidyHTMLTestCase {
htmlFactory.makePageHTML = { page, _ in
HTML(.body(.p(.text(page.title))))
}

try publishWebsite(
using: Theme(htmlFactory: htmlFactory),
content: [
Expand Down

0 comments on commit 35621b3

Please sign in to comment.