git.iko.soy/SourceDocsSwift
on master help sign in
Second column justification. Print error when writing file.
222f41bilyakooo0
SourceDocsSwift/TeXer.swift+3−3
unifiedsplit
@@ -11,7 +11,7 @@ struct TeXer {
11 return """
11 return """
12 \\\(style.section(for: 1)){Описание классов и структур}
12 \\\(style.section(for: 1)){Описание классов и структур}
13
13
14− \\begin{longtable}{| >{\\raggedright\\arraybackslash}p{0.55\\textwidth} | >{\\raggedright\\arraybackslash}p{0.4\\textwidth}|}
14+ \\begin{longtable}{| >{\\raggedright\\arraybackslash}p{0.55\\textwidth} | p{0.4\\textwidth}|}
15 \\hline
15 \\hline
16 \\textbf{Класс или стркура} & \\textbf{Описание} \\\\ \\hline
16 \\textbf{Класс или стркура} & \\textbf{Описание} \\\\ \\hline
17 \( objects.map {"\\texttt{\($0.declaration)} & {\\color{red} TODO} \\\\ \\hline"} .joined(separator: "\n") )
17 \( objects.map {"\\texttt{\($0.declaration)} & {\\color{red} TODO} \\\\ \\hline"} .joined(separator: "\n") )
@@ -26,7 +26,7 @@ struct TeXer {
26 return """
26 return """
27 \\\(style.section(for: 2))*{\\texttt{\($0.declaration)}}
27 \\\(style.section(for: 2))*{\\texttt{\($0.declaration)}}
28
28
29− \\begin{longtable}{| >{\\raggedright\\arraybackslash}p{0.55\\textwidth} | >{\\raggedright\\arraybackslash}p{0.4\\textwidth}|}
29+ \\begin{longtable}{| >{\\raggedright\\arraybackslash}p{0.55\\textwidth} | p{0.4\\textwidth}|}
30 \\hline
30 \\hline
31 \\textbf{Поле} & \\textbf{Описание} \\\\ \\hline
31 \\textbf{Поле} & \\textbf{Описание} \\\\ \\hline
32 \( $0.fields.map {"\\texttt{\($0.declaration.prefix {$0 != "="})} & {\\color{red} TODO} \\\\ \\hline"} .joined(separator: "\n") )
32 \( $0.fields.map {"\\texttt{\($0.declaration.prefix {$0 != "="})} & {\\color{red} TODO} \\\\ \\hline"} .joined(separator: "\n") )
@@ -47,7 +47,7 @@ struct TeXer {
47 return """
47 return """
48 \\\(style.section(for: 2))*{\\texttt{\($0.declaration)}}
48 \\\(style.section(for: 2))*{\\texttt{\($0.declaration)}}
49
49
50− \\begin{longtable}{| >{\\raggedright\\arraybackslash}p{0.55\\textwidth} | >{\\raggedright\\arraybackslash}p{0.4\\textwidth}|}
50+ \\begin{longtable}{| >{\\raggedright\\arraybackslash}p{0.55\\textwidth} | p{0.4\\textwidth}|}
51 \\hline
51 \\hline
52 \\textbf{Метод} & \\textbf{Описание} \\\\ \\hline
52 \\textbf{Метод} & \\textbf{Описание} \\\\ \\hline
53 \( $0.methods.map {"\\texttt{\($0.declaration)} & {\\color{red} TODO} \\\\ \\hline"} .joined(separator: "\n") )
53 \( $0.methods.map {"\\texttt{\($0.declaration)} & {\\color{red} TODO} \\\\ \\hline"} .joined(separator: "\n") )
SourceDocsSwift/main.swift+16−2
@@ -70,6 +70,14 @@ while i < args.count {
70 i += 1
70 i += 1
71}
71}
72
72
73+var outputIsDirectory: ObjCBool = false
74+
75+FileManager.default.fileExists(atPath: output, isDirectory: &outputIsDirectory)
76+
77+if outputIsDirectory.boolValue {
78+ output.append("/docs.tex")
79+}
80+
73let decoder = JSONDecoder()
81let decoder = JSONDecoder()
74
82
75guard let xcbTagetData = Shell.launch(executable: "/usr/bin/xcodebuild", arguments: ["-list", "-json"], launchDirectory: directory) else {
83guard let xcbTagetData = Shell.launch(executable: "/usr/bin/xcodebuild", arguments: ["-list", "-json"], launchDirectory: directory) else {
@@ -113,8 +121,14 @@ for target in targets {
113
121
114
122
115let tex = TeXer.convert(objects: files.flatMap {$0.value}, with: style)
123let tex = TeXer.convert(objects: files.flatMap {$0.value}, with: style)
116−
124+do {
117−try? tex.write(toFile: output, atomically: true, encoding: .utf8)
125+ try tex.write(toFile: output, atomically: true, encoding: .utf8)
126+} catch {
127+ print("""
128+ There was an error writing the outuput file.
129+ """)
130+ exit(1)
131+}
118
132
119print("""
133print("""
120+-------+
134+-------+