@@ -19,7 +19,7 @@ def plural(name: str, qu: int) -> str:
19
19
20
20
@staticmethod
21
21
def nav_link (name : str , path : str ) -> str :
22
- return f" <a href=\ "{ path } \ " class=\ " btn btn-link\ " >{ name } </a>"
22
+ return f' <a href="{ path } " class="btn btn-link">{ name } </a>'
23
23
24
24
@staticmethod
25
25
def anchorize (name : str ) -> str :
@@ -33,7 +33,7 @@ def nav_item(name: str, anchor: str) -> str:
33
33
34
34
@staticmethod
35
35
def a (name : str , path : str ) -> str :
36
- return f" <a href=\ "{ path } \ " >{ name } </a>"
36
+ return f' <a href="{ path } ">{ name } </a>'
37
37
38
38
@staticmethod
39
39
def b (content : str ) -> str :
@@ -52,7 +52,7 @@ def code(content: str) -> str:
52
52
</pre>"""
53
53
54
54
@staticmethod
55
- def section (title : str , content : str , anchor : str = "" ) -> str :
55
+ def section (title : str , content : str , anchor : str = "" ) -> str :
56
56
return f"""<section { f'id="{ anchor } "' if anchor else '' } >
57
57
<h2>{ title } </h2>
58
58
@@ -91,7 +91,9 @@ def h4(name: str) -> str:
91
91
92
92
class HTMLGenerator (Generator ):
93
93
def __init__ (self , parsers : List [Parser ], output : str , ark_version : str ):
94
- super ().__init__ (parsers , spec .HTML_TEMPLATE_FOLDER , "*.html" , output , ark_version )
94
+ super ().__init__ (
95
+ parsers , spec .HTML_TEMPLATE_FOLDER , "*.html" , output , ark_version
96
+ )
95
97
96
98
self .footer = f"<i>Last generation at { datetime .now ()} </i>"
97
99
@@ -100,12 +102,19 @@ def create_dir(self, name: str):
100
102
101
103
def generate_index (self ):
102
104
if not (self .output_path / "assets" ).exists ():
103
- shutil .copytree (str (self .template_folder / "assets" ), str (self .output_path / "assets" ))
105
+ shutil .copytree (
106
+ str (self .template_folder / "assets" ), str (self .output_path / "assets" )
107
+ )
104
108
105
109
sections = html .section (
106
110
f"ArkScript { self .version } documentation" ,
107
- f"Welcome! This is the official documentation for ArkScript { self .version } " +
108
- html .ul ([html .a (file .path , f"/{ self .version } /{ file .path } .html" ) for file in self .list .files ])
111
+ f"Welcome! This is the official documentation for ArkScript { self .version } "
112
+ + html .ul (
113
+ [
114
+ html .a (file .path , f"/{ self .version } /{ file .path } .html" )
115
+ for file in self .list .files
116
+ ]
117
+ ),
109
118
)
110
119
111
120
content = self .templates ["index.html" ]
@@ -117,7 +126,7 @@ def generate_index(self):
117
126
table_of_content = "" ,
118
127
navigation_links = "" ,
119
128
sections = sections ,
120
- footer = self .footer
129
+ footer = self .footer ,
121
130
)
122
131
123
132
(self .output_path_ver / "index.html" ).write_text (content )
@@ -131,31 +140,31 @@ def generate_one(self, path: str, functions: List[spec.Function]):
131
140
for func in functions :
132
141
links += html .nav_item (func .name , html .anchorize (func .name ))
133
142
content = html .div (
134
- html .inline_code (func .signature ), "<br>" ,
143
+ html .inline_code (func .signature ),
144
+ "<br>" ,
135
145
html .div (func .desc .brief ),
136
- html .div (
137
- html .b ("Note" ), ": " ,
138
- func .desc .details
139
- ),
146
+ html .div (html .b ("Note" ), ": " , func .desc .details ),
140
147
html .div (
141
148
html .h4 (html .plural ("Parameter" , len (func .desc .params ))),
142
- html .ul ([
143
- f"{ html .inline_code (p .name )} : { p .desc } " for p in func .desc .params
144
- ])
149
+ html .ul (
150
+ [
151
+ f"{ html .inline_code (p .name )} : { p .desc } "
152
+ for p in func .desc .params
153
+ ]
154
+ ),
145
155
),
146
156
html .div (
147
157
html .h4 (html .plural ("Author" , len (func .desc .authors ))),
148
- ", " .join ([
149
- html .a (f"@{ a .split ('/' )[- 1 ]} " , a ) for a in func .desc .authors
150
- ])
151
- )
158
+ ", " .join (
159
+ [ html .a (f"@{ a .split ('/' )[- 1 ]} " , a ) for a in func .desc .authors ]
160
+ ),
161
+ ),
152
162
)
153
163
if func .desc .code :
154
- content += html .div (
155
- html .h4 ("Example" ),
156
- html .code (func .desc .code )
157
- )
158
- sections += html .section (func .name , content , anchor = html .anchorize (func .name ))
164
+ content += html .div (html .h4 ("Example" ), html .code (func .desc .code ))
165
+ sections += html .section (
166
+ func .name , content , anchor = html .anchorize (func .name )
167
+ )
159
168
160
169
table_of_content = table_of_content .format (table_of_content_links = links )
161
170
@@ -168,7 +177,7 @@ def generate_one(self, path: str, functions: List[spec.Function]):
168
177
table_of_content = table_of_content ,
169
178
navigation_links = "" ,
170
179
sections = sections ,
171
- footer = self .footer
180
+ footer = self .footer ,
172
181
)
173
182
174
183
(self .output_path_ver / f"{ path } .html" ).write_text (content )
0 commit comments