Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Use SwiftPM Resources rather than downloading CSS files. #267

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ swift-doc: $(BUILDDIR)/release/swift-doc
install: $(BUILDDIR)/release/swift-doc
@install -d "$(bindir)"
@install "$(BUILDDIR)/release/swift-doc" "$(bindir)"
@cp -R "$(BUILDDIR)/release/swift-doc_swift-doc.bundle" "$(bindir)"

.PHONY: uninstall
uninstall:
@rm -rf "$(bindir)/swift-doc"
@rm -rf "$(bindir)/swift-doc_swift-doc.bundle"

.PHONY: clean
distclean:
Expand Down
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ let package = Package(
.product(name: "SwiftSyntaxHighlighter", package: "SwiftSyntaxHighlighter"),
.product(name: "Logging", package: "swift-log"),
.product(name: "LoggingGitHubActions", package: "LoggingGitHubActions")
]
],
resources: [.copy("Resources")]
),
.target(
name: "DCOV",
Expand Down
16 changes: 4 additions & 12 deletions Sources/swift-doc/Subcommands/Generate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import SwiftMarkup
import SwiftSemantics
import struct SwiftSemantics.Protocol

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

extension SwiftDoc {
struct Generate: ParsableCommand {
enum Format: String, ExpressibleByArgument {
Expand Down Expand Up @@ -147,9 +143,10 @@ extension SwiftDoc {
}

if case .html = format {
let cssData = try fetchRemoteCSS()
let cssURL = outputDirectoryURL.appendingPathComponent("all.css")
try writeFile(cssData, to: cssURL)
let cssSrcFile = Bundle.module.url(forResource: "Resources/all", withExtension: "min.css")!
let cssDst = outputDirectoryURL.appendingPathComponent("all.css")
try? FileManager.default.removeItem(at: cssDst)
try FileManager.default.copyItem(at: cssSrcFile, to: cssDst)
}

} catch {
Expand All @@ -158,8 +155,3 @@ extension SwiftDoc {
}
}
}

func fetchRemoteCSS() throws -> Data {
let url = URL(string: "https://raw.githubusercontent.com/SwiftDocOrg/swift-doc/master/Resources/all.min.css")!
return try Data(contentsOf: url)
}