This repository was archived by the owner on Jun 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Expand file tree Collapse file tree 3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -110,9 +110,22 @@ extension SwiftDoc {
110
110
try $0. value. write ( to: url, format: format, baseURL: options. baseURL)
111
111
}
112
112
}
113
+
114
+ if case . html = format {
115
+ let cssData = try fetchRemoteCSS ( )
116
+ let cssURL = outputDirectoryURL. appendingPathComponent ( " all.css " )
117
+ try writeFile ( cssData, to: cssURL)
118
+ }
119
+
120
+
113
121
} catch {
114
122
logger. error ( " \( error) " )
115
123
}
116
124
}
117
125
}
118
126
}
127
+
128
+ func fetchRemoteCSS( ) throws -> Data {
129
+ let url = URL ( string: " https://raw.githubusercontent.com/kaishin/swift-doc/reda/css-build/Resources/all.css " ) !
130
+ return try Data ( contentsOf: url)
131
+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ func layout(_ page: Page, baseURL: String) -> HTML {
12
12
<meta name="viewport" content="width=device-width, initial-scale=1.0">
13
13
<title> \#( page. module. name) - \#( page. title) </title>
14
14
<base href=" \#( baseURL) "/>
15
- <link rel="stylesheet" href="index .css" media="all" />
15
+ <link rel="stylesheet" type="text/css" href="all .css" media="all" />
16
16
</head>
17
17
<body>
18
18
<header>
Original file line number Diff line number Diff line change @@ -28,11 +28,9 @@ extension Page {
28
28
data = layout ( self , baseURL: baseURL) . description. data ( using: . utf8)
29
29
}
30
30
31
- let fileManager = FileManager . default
32
- try fileManager. createDirectory ( at: url. deletingLastPathComponent ( ) , withIntermediateDirectories: true , attributes: [ . posixPermissions: 0o744 ] )
31
+ guard let filedata = data else { return }
33
32
34
- try data? . write ( to: url)
35
- try fileManager. setAttributes ( [ . posixPermissions: 0o744 ] , ofItemAtPath: url. path)
33
+ try writeFile ( filedata, to: url)
36
34
}
37
35
}
38
36
@@ -43,3 +41,11 @@ func path(for symbol: Symbol) -> String {
43
41
func path( for identifier: CustomStringConvertible ) -> String {
44
42
return " \( identifier) " . replacingOccurrences ( of: " . " , with: " _ " )
45
43
}
44
+
45
+ func writeFile( _ data: Data , to url: URL ) throws {
46
+ let fileManager = FileManager . default
47
+ try fileManager. createDirectory ( at: url. deletingLastPathComponent ( ) , withIntermediateDirectories: true , attributes: [ . posixPermissions: 0o744 ] )
48
+
49
+ try data. write ( to: url)
50
+ try fileManager. setAttributes ( [ . posixPermissions: 0o744 ] , ofItemAtPath: url. path)
51
+ }
You can’t perform that action at this time.
0 commit comments