@@ -7,24 +7,24 @@
77//
88
99struct TeXer {
10− static func convert(objects: [Object]) -> String {
10+ static func convert(objects: [Object], with style: TexType = .laTeX(2)) -> String {
1111 return """
12− \\subsection{Описание классов и структур}
12+ \\\(style.section(for: 1)){Описание классов и структур}
1313
1414 \\begin{longtable}{|p{0.55\\textwidth} | p{0.4\\textwidth}|}
1515 \\hline
1616 \\textbf{Класс или стркура} & \\textbf{Описание} \\\\ \\hline
1717 \( objects.map {"\\texttt{\($0.declaration)} & \($0.documentation ?? "{\\color{red} TODO}") \\\\ \\hline"} .joined(separator: "\n") )
1818 \\end{longtable}
19−
2019
21− \\subsection{Описание полей классов и структур}
20+
21+ \\\(style.section(for: 1)){Описание полей классов и структур}
2222
2323 \(
2424 objects.compactMap {
2525 if $0.fields.count > 0 {
2626 return """
27− \\subsubsection{\\texttt{\($0.declaration)}}
27+ \\\(style.section(for: 2))*{\\texttt{\($0.declaration)}}
2828
2929 \\begin{longtable}{|p{0.55\\textwidth} | p{0.4\\textwidth}|}
3030 \\hline
@@ -38,14 +38,14 @@ struct TeXer {
3838 }
3939 } .joined(separator: "\n")
4040 )
41−
42− \\subsection{Описание методов классов и структур}
41+
42+ \\\(style.section(for: 1)){Описание методов классов и структур}
4343
4444 \(
4545 objects.compactMap {
4646 if $0.methods.count > 0 {
4747 return """
48− \\subsubsection{\\texttt{\($0.declaration)}}
48+ \\\(style.section(for: 2))*{\\texttt{\($0.declaration)}}
4949
5050 \\begin{longtable}{|p{0.55\\textwidth} | p{0.4\\textwidth}|}
5151 \\hline
@@ -61,4 +61,41 @@ struct TeXer {
6161 )
6262 """
6363 }
64+
65+ enum TexType {
66+ case techDoc(Int)
67+ case laTeX(Int)
68+
69+ func section(`for` level: Int) -> String {
70+ switch self {
71+ case .laTeX(let i):
72+ return String(repeating: "sub", count: i+level-2).appending("section")
73+ case .techDoc(let i):
74+ switch i+level-2 {
75+ case 0:
76+ return "addition"
77+ default:
78+ return TexType.laTeX(i).section(for: level)
79+ }
80+ }
81+ }
82+ var levelOffset: Int {
83+ get {
84+ switch self {
85+ case .laTeX(let i):
86+ return i
87+ case .techDoc(let i):
88+ return i
89+ }
90+ }
91+ set {
92+ switch self {
93+ case .laTeX(_):
94+ self = .laTeX(newValue)
95+ case .techDoc(_):
96+ self = .techDoc(newValue)
97+ }
98+ }
99+ }
100+ }
64101}