@@ -7,26 +7,26 @@
9struct TeXer {
9struct TeXer {
10− static func convert(objects: [Object]) -> String {
10+ static func convert(objects: [Object], with style: TexType = .laTeX(2)) -> String {
11 return """
11 return """
12− \\subsection{Описание классов и структур}
12+ \\\(style.section(for: 1)){Описание классов и структур}
14− \\begin{longtable}{|p{0.55\\textwidth} | p{0.4\\textwidth}|}
14+ \\begin{longtable}{| >{\\raggedright\\arraybackslash}p{0.55\\textwidth} | p{0.4\\textwidth}|}
16 \\textbf{Класс или стркура} & \\textbf{Описание} \\\\ \\hline
16 \\textbf{Класс или стркура} & \\textbf{Описание} \\\\ \\hline
17− \( objects.map {"\\texttt{\($0.declaration)} & \($0.documentation ?? "{\\color{red} TODO}") \\\\ \\hline"} .joined(separator: "\n") )
17+ \( objects.map {"\\texttt{\($0.declaration)} & {\\color{red} TODO} \\\\ \\hline"} .joined(separator: "\n") )
18 \\end{longtable}
18 \\end{longtable}
21− \\subsection{Описание полей классов и структур}
21+ \\\(style.section(for: 1)){Описание полей классов и структур}
24 objects.compactMap {
24 objects.compactMap {
25 if $0.fields.count > 0 {
25 if $0.fields.count > 0 {
26 return """
26 return """
27− \\subsubsection{\\texttt{\($0.declaration)}}
27+ \\\(style.section(for: 2))*{\\texttt{\($0.declaration)}}
29− \\begin{longtable}{|p{0.55\\textwidth} | p{0.4\\textwidth}|}
29+ \\begin{longtable}{| >{\\raggedright\\arraybackslash}p{0.55\\textwidth} | p{0.4\\textwidth}|}
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") )
@@ -38,19 +38,19 @@ struct TeXer {
39 } .joined(separator: "\n")
39 } .joined(separator: "\n")
42− \\subsection{Описание методов классов и структур}
42+ \\\(style.section(for: 1)){Описание методов классов и структур}
45 objects.compactMap {
45 objects.compactMap {
46 if $0.methods.count > 0 {
46 if $0.methods.count > 0 {
47 return """
47 return """
48− \\subsubsection{\\texttt{\($0.declaration)}}
48+ \\\(style.section(for: 2))*{\\texttt{\($0.declaration)}}
50− \\begin{longtable}{|p{0.55\\textwidth} | p{0.4\\textwidth}|}
50+ \\begin{longtable}{| >{\\raggedright\\arraybackslash}p{0.55\\textwidth} | p{0.4\\textwidth}|}
52 \\textbf{Метод} & \\textbf{Описание} \\\\ \\hline
52 \\textbf{Метод} & \\textbf{Описание} \\\\ \\hline
53− \( $0.methods.map {"\\texttt{\($0.declaration)} & \($0.documentation ?? "{\\color{red} TODO}") \\\\ \\hline"} .joined(separator: "\n") )
53+ \( $0.methods.map {"\\texttt{\($0.declaration)} & {\\color{red} TODO} \\\\ \\hline"} .joined(separator: "\n") )
54 \\end{longtable}
54 \\end{longtable}
@@ -61,4 +61,41 @@ struct TeXer {
69+ func section(`for` level: Int) -> String {
72+ return String(repeating: "sub", count: i+level-2).appending("section")
73+ case .techDoc(let i):
78+ return TexType.laTeX(i).section(for: level)
82+ var levelOffset: Int {
87+ case .techDoc(let i):
94+ self = .laTeX(newValue)
96+ self = .techDoc(newValue)