ophinode 0.0.1a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ophinode/__init__.py +490 -0
- ophinode/__main__.py +94 -0
- ophinode/constants.py +13 -0
- ophinode/exceptions.py +17 -0
- ophinode/nodes/__init__.py +0 -0
- ophinode/nodes/base.py +45 -0
- ophinode/nodes/html.py +826 -0
- ophinode/rendering.py +179 -0
- ophinode/site.py +426 -0
- ophinode-0.0.1a1.dist-info/METADATA +102 -0
- ophinode-0.0.1a1.dist-info/RECORD +13 -0
- ophinode-0.0.1a1.dist-info/WHEEL +4 -0
- ophinode-0.0.1a1.dist-info/licenses/LICENSE +21 -0
ophinode/__init__.py
ADDED
@@ -0,0 +1,490 @@
|
|
1
|
+
"A static-site and page generator for Python."
|
2
|
+
|
3
|
+
__author__ = "deflatedlatte"
|
4
|
+
__all__ = [
|
5
|
+
"Site",
|
6
|
+
"render_page",
|
7
|
+
"ClosedRenderable",
|
8
|
+
"OpenRenderable",
|
9
|
+
"Expandable",
|
10
|
+
"Preparable",
|
11
|
+
"Page",
|
12
|
+
"Layout",
|
13
|
+
"HTML5Page",
|
14
|
+
"HTML5Layout",
|
15
|
+
"Node",
|
16
|
+
"TextNode",
|
17
|
+
"HTML5Doctype",
|
18
|
+
"CDATASection",
|
19
|
+
"Comment",
|
20
|
+
"Element",
|
21
|
+
"OpenElement",
|
22
|
+
"ClosedElement",
|
23
|
+
"HtmlElement",
|
24
|
+
"HeadElement",
|
25
|
+
"TitleElement",
|
26
|
+
"BaseElement",
|
27
|
+
"LinkElement",
|
28
|
+
"MetaElement",
|
29
|
+
"StyleElement",
|
30
|
+
"BodyElement",
|
31
|
+
"ArticleElement",
|
32
|
+
"SectionElement",
|
33
|
+
"NavigationElement",
|
34
|
+
"AsideElement",
|
35
|
+
"HeadingLevel1Element",
|
36
|
+
"HeadingLevel2Element",
|
37
|
+
"HeadingLevel3Element",
|
38
|
+
"HeadingLevel4Element",
|
39
|
+
"HeadingLevel5Element",
|
40
|
+
"HeadingLevel6Element",
|
41
|
+
"HeadingGroupElement",
|
42
|
+
"HeaderElement",
|
43
|
+
"FooterElement",
|
44
|
+
"AddressElement",
|
45
|
+
"ParagraphElement",
|
46
|
+
"HorizontalRuleElement",
|
47
|
+
"PreformattedTextElement",
|
48
|
+
"BlockQuotationElement",
|
49
|
+
"OrderedListElement",
|
50
|
+
"UnorderedListElement",
|
51
|
+
"MenuElement",
|
52
|
+
"ListItemElement",
|
53
|
+
"DescriptionListElement",
|
54
|
+
"DescriptionTermElement",
|
55
|
+
"DescriptionDetailsElement",
|
56
|
+
"FigureElement",
|
57
|
+
"FigureCaptionElement",
|
58
|
+
"MainElement",
|
59
|
+
"SearchElement",
|
60
|
+
"DivisionElement",
|
61
|
+
"AnchorElement",
|
62
|
+
"EmphasisElement",
|
63
|
+
"StrongImportanceElement",
|
64
|
+
"SmallPrintElement",
|
65
|
+
"StrikethroughElement",
|
66
|
+
"CitationElement",
|
67
|
+
"QuotationElement",
|
68
|
+
"DefinitionElement",
|
69
|
+
"AbbreviationElement",
|
70
|
+
"RubyAnnotationElement",
|
71
|
+
"RubyTextElement",
|
72
|
+
"RubyParenthesesElement",
|
73
|
+
"DataElement",
|
74
|
+
"TimeElement",
|
75
|
+
"CodeElement",
|
76
|
+
"VariableElement",
|
77
|
+
"SampleElement",
|
78
|
+
"KeyboardInputElement",
|
79
|
+
"SubscriptElement",
|
80
|
+
"SuperscriptElement",
|
81
|
+
"ItalicTextElement",
|
82
|
+
"BoldTextElement",
|
83
|
+
"UnarticulatedAnnotationElement",
|
84
|
+
"MarkedTextElement",
|
85
|
+
"BidirectionalIsolateElement",
|
86
|
+
"BidirectionalOverrideElement",
|
87
|
+
"SpanElement",
|
88
|
+
"LineBreakElement",
|
89
|
+
"LineBreakOpportunityElement",
|
90
|
+
"InsertionElement",
|
91
|
+
"DeletionElement",
|
92
|
+
"PictureElement",
|
93
|
+
"SourceElement",
|
94
|
+
"ImageElement",
|
95
|
+
"InlineFrameElement",
|
96
|
+
"EmbeddedContentElement",
|
97
|
+
"ExternalObjectElement",
|
98
|
+
"VideoElement",
|
99
|
+
"AudioElement",
|
100
|
+
"TextTrackElement",
|
101
|
+
"ImageMapElement",
|
102
|
+
"ImageMapAreaElement",
|
103
|
+
"TableElement",
|
104
|
+
"TableCaptionElement",
|
105
|
+
"TableColumnGroupElement",
|
106
|
+
"TableColumnElement",
|
107
|
+
"TableBodyElement",
|
108
|
+
"TableHeadElement",
|
109
|
+
"TableFootElement",
|
110
|
+
"TableRowElement",
|
111
|
+
"TableDataCellElement",
|
112
|
+
"TableHeaderCellElement",
|
113
|
+
"FormElement",
|
114
|
+
"LabelElement",
|
115
|
+
"InputElement",
|
116
|
+
"ButtonElement",
|
117
|
+
"SelectElement",
|
118
|
+
"DataListElement",
|
119
|
+
"OptionGroupElement",
|
120
|
+
"OptionElement",
|
121
|
+
"TextAreaElement",
|
122
|
+
"OutputElement",
|
123
|
+
"ProgressElement",
|
124
|
+
"MeterElement",
|
125
|
+
"FieldSetElement",
|
126
|
+
"FieldSetLegendElement",
|
127
|
+
"DetailsElement",
|
128
|
+
"SummaryElement",
|
129
|
+
"DialogElement",
|
130
|
+
"ScriptElement",
|
131
|
+
"NoScriptElement",
|
132
|
+
"TemplateElement",
|
133
|
+
"SlotElement",
|
134
|
+
"CanvasElement",
|
135
|
+
"Html",
|
136
|
+
"Head",
|
137
|
+
"Title",
|
138
|
+
"Base",
|
139
|
+
"Link",
|
140
|
+
"Meta",
|
141
|
+
"Style",
|
142
|
+
"Body",
|
143
|
+
"Article",
|
144
|
+
"Section",
|
145
|
+
"Nav",
|
146
|
+
"Aside",
|
147
|
+
"H1",
|
148
|
+
"H2",
|
149
|
+
"H3",
|
150
|
+
"H4",
|
151
|
+
"H5",
|
152
|
+
"H6",
|
153
|
+
"HGroup",
|
154
|
+
"Header",
|
155
|
+
"Footer",
|
156
|
+
"Address",
|
157
|
+
"P",
|
158
|
+
"HR",
|
159
|
+
"Pre",
|
160
|
+
"BlockQuote",
|
161
|
+
"OL",
|
162
|
+
"UL",
|
163
|
+
"Menu",
|
164
|
+
"LI",
|
165
|
+
"DL",
|
166
|
+
"DT",
|
167
|
+
"DD",
|
168
|
+
"Figure",
|
169
|
+
"FigCaption",
|
170
|
+
"Main",
|
171
|
+
"Search",
|
172
|
+
"Div",
|
173
|
+
"A",
|
174
|
+
"EM",
|
175
|
+
"Strong",
|
176
|
+
"Small",
|
177
|
+
"S",
|
178
|
+
"Cite",
|
179
|
+
"Q",
|
180
|
+
"Dfn",
|
181
|
+
"Abbr",
|
182
|
+
"Ruby",
|
183
|
+
"RT",
|
184
|
+
"RP",
|
185
|
+
"Data",
|
186
|
+
"Time",
|
187
|
+
"Code",
|
188
|
+
"Var",
|
189
|
+
"Samp",
|
190
|
+
"Kbd",
|
191
|
+
"Sub",
|
192
|
+
"Sup",
|
193
|
+
"I",
|
194
|
+
"B",
|
195
|
+
"U",
|
196
|
+
"Mark",
|
197
|
+
"BDI",
|
198
|
+
"BDO",
|
199
|
+
"Span",
|
200
|
+
"BR",
|
201
|
+
"WBR",
|
202
|
+
"Ins",
|
203
|
+
"Del",
|
204
|
+
"Picture",
|
205
|
+
"Source",
|
206
|
+
"Image",
|
207
|
+
"IFrame",
|
208
|
+
"Embed",
|
209
|
+
"Object",
|
210
|
+
"Video",
|
211
|
+
"Audio",
|
212
|
+
"Track",
|
213
|
+
"Map",
|
214
|
+
"Area",
|
215
|
+
"Table",
|
216
|
+
"Caption",
|
217
|
+
"ColGroup",
|
218
|
+
"Column",
|
219
|
+
"TBody",
|
220
|
+
"THead",
|
221
|
+
"TFoot",
|
222
|
+
"TR",
|
223
|
+
"TD",
|
224
|
+
"TH",
|
225
|
+
"Form",
|
226
|
+
"Label",
|
227
|
+
"Input",
|
228
|
+
"Button",
|
229
|
+
"Select",
|
230
|
+
"DataList",
|
231
|
+
"OptGroup",
|
232
|
+
"Option",
|
233
|
+
"Progress",
|
234
|
+
"Meter",
|
235
|
+
"FieldSet",
|
236
|
+
"Legend",
|
237
|
+
"Details",
|
238
|
+
"Summary",
|
239
|
+
"Dialog",
|
240
|
+
"Script",
|
241
|
+
"NoScript",
|
242
|
+
"Template",
|
243
|
+
"Slot",
|
244
|
+
"Canvas",
|
245
|
+
]
|
246
|
+
|
247
|
+
from .site import Site, render_page
|
248
|
+
from .nodes.base import (
|
249
|
+
ClosedRenderable,
|
250
|
+
OpenRenderable,
|
251
|
+
Expandable,
|
252
|
+
Preparable,
|
253
|
+
Page,
|
254
|
+
Layout,
|
255
|
+
)
|
256
|
+
from .nodes.html import (
|
257
|
+
HTML5Page,
|
258
|
+
HTML5Layout,
|
259
|
+
Node,
|
260
|
+
TextNode,
|
261
|
+
HTML5Doctype,
|
262
|
+
CDATASection,
|
263
|
+
Comment,
|
264
|
+
Element,
|
265
|
+
OpenElement,
|
266
|
+
ClosedElement,
|
267
|
+
HtmlElement,
|
268
|
+
HeadElement,
|
269
|
+
TitleElement,
|
270
|
+
BaseElement,
|
271
|
+
LinkElement,
|
272
|
+
MetaElement,
|
273
|
+
StyleElement,
|
274
|
+
BodyElement,
|
275
|
+
ArticleElement,
|
276
|
+
SectionElement,
|
277
|
+
NavigationElement,
|
278
|
+
AsideElement,
|
279
|
+
HeadingLevel1Element,
|
280
|
+
HeadingLevel2Element,
|
281
|
+
HeadingLevel3Element,
|
282
|
+
HeadingLevel4Element,
|
283
|
+
HeadingLevel5Element,
|
284
|
+
HeadingLevel6Element,
|
285
|
+
HeadingGroupElement,
|
286
|
+
HeaderElement,
|
287
|
+
FooterElement,
|
288
|
+
AddressElement,
|
289
|
+
ParagraphElement,
|
290
|
+
HorizontalRuleElement,
|
291
|
+
PreformattedTextElement,
|
292
|
+
BlockQuotationElement,
|
293
|
+
OrderedListElement,
|
294
|
+
UnorderedListElement,
|
295
|
+
MenuElement,
|
296
|
+
ListItemElement,
|
297
|
+
DescriptionListElement,
|
298
|
+
DescriptionTermElement,
|
299
|
+
DescriptionDetailsElement,
|
300
|
+
FigureElement,
|
301
|
+
FigureCaptionElement,
|
302
|
+
MainElement,
|
303
|
+
SearchElement,
|
304
|
+
DivisionElement,
|
305
|
+
AnchorElement,
|
306
|
+
EmphasisElement,
|
307
|
+
StrongImportanceElement,
|
308
|
+
SmallPrintElement,
|
309
|
+
StrikethroughElement,
|
310
|
+
CitationElement,
|
311
|
+
QuotationElement,
|
312
|
+
DefinitionElement,
|
313
|
+
AbbreviationElement,
|
314
|
+
RubyAnnotationElement,
|
315
|
+
RubyTextElement,
|
316
|
+
RubyParenthesesElement,
|
317
|
+
DataElement,
|
318
|
+
TimeElement,
|
319
|
+
CodeElement,
|
320
|
+
VariableElement,
|
321
|
+
SampleElement,
|
322
|
+
KeyboardInputElement,
|
323
|
+
SubscriptElement,
|
324
|
+
SuperscriptElement,
|
325
|
+
ItalicTextElement,
|
326
|
+
BoldTextElement,
|
327
|
+
UnarticulatedAnnotationElement,
|
328
|
+
MarkedTextElement,
|
329
|
+
BidirectionalIsolateElement,
|
330
|
+
BidirectionalOverrideElement,
|
331
|
+
SpanElement,
|
332
|
+
LineBreakElement,
|
333
|
+
LineBreakOpportunityElement,
|
334
|
+
InsertionElement,
|
335
|
+
DeletionElement,
|
336
|
+
PictureElement,
|
337
|
+
SourceElement,
|
338
|
+
ImageElement,
|
339
|
+
InlineFrameElement,
|
340
|
+
EmbeddedContentElement,
|
341
|
+
ExternalObjectElement,
|
342
|
+
VideoElement,
|
343
|
+
AudioElement,
|
344
|
+
TextTrackElement,
|
345
|
+
ImageMapElement,
|
346
|
+
ImageMapAreaElement,
|
347
|
+
TableElement,
|
348
|
+
TableCaptionElement,
|
349
|
+
TableColumnGroupElement,
|
350
|
+
TableColumnElement,
|
351
|
+
TableBodyElement,
|
352
|
+
TableHeadElement,
|
353
|
+
TableFootElement,
|
354
|
+
TableRowElement,
|
355
|
+
TableDataCellElement,
|
356
|
+
TableHeaderCellElement,
|
357
|
+
FormElement,
|
358
|
+
LabelElement,
|
359
|
+
InputElement,
|
360
|
+
ButtonElement,
|
361
|
+
SelectElement,
|
362
|
+
DataListElement,
|
363
|
+
OptionGroupElement,
|
364
|
+
OptionElement,
|
365
|
+
TextAreaElement,
|
366
|
+
OutputElement,
|
367
|
+
ProgressElement,
|
368
|
+
MeterElement,
|
369
|
+
FieldSetElement,
|
370
|
+
FieldSetLegendElement,
|
371
|
+
DetailsElement,
|
372
|
+
SummaryElement,
|
373
|
+
DialogElement,
|
374
|
+
ScriptElement,
|
375
|
+
NoScriptElement,
|
376
|
+
TemplateElement,
|
377
|
+
SlotElement,
|
378
|
+
CanvasElement,
|
379
|
+
Html,
|
380
|
+
Head,
|
381
|
+
Title,
|
382
|
+
Base,
|
383
|
+
Link,
|
384
|
+
Meta,
|
385
|
+
Style,
|
386
|
+
Body,
|
387
|
+
Article,
|
388
|
+
Section,
|
389
|
+
Nav,
|
390
|
+
Aside,
|
391
|
+
H1,
|
392
|
+
H2,
|
393
|
+
H3,
|
394
|
+
H4,
|
395
|
+
H5,
|
396
|
+
H6,
|
397
|
+
HGroup,
|
398
|
+
Header,
|
399
|
+
Footer,
|
400
|
+
Address,
|
401
|
+
P,
|
402
|
+
HR,
|
403
|
+
Pre,
|
404
|
+
BlockQuote,
|
405
|
+
OL,
|
406
|
+
UL,
|
407
|
+
Menu,
|
408
|
+
LI,
|
409
|
+
DL,
|
410
|
+
DT,
|
411
|
+
DD,
|
412
|
+
Figure,
|
413
|
+
FigCaption,
|
414
|
+
Main,
|
415
|
+
Search,
|
416
|
+
Div,
|
417
|
+
A,
|
418
|
+
EM,
|
419
|
+
Strong,
|
420
|
+
Small,
|
421
|
+
S,
|
422
|
+
Cite,
|
423
|
+
Q,
|
424
|
+
Dfn,
|
425
|
+
Abbr,
|
426
|
+
Ruby,
|
427
|
+
RT,
|
428
|
+
RP,
|
429
|
+
Data,
|
430
|
+
Time,
|
431
|
+
Code,
|
432
|
+
Var,
|
433
|
+
Samp,
|
434
|
+
Kbd,
|
435
|
+
Sub,
|
436
|
+
Sup,
|
437
|
+
I,
|
438
|
+
B,
|
439
|
+
U,
|
440
|
+
Mark,
|
441
|
+
BDI,
|
442
|
+
BDO,
|
443
|
+
Span,
|
444
|
+
BR,
|
445
|
+
WBR,
|
446
|
+
Ins,
|
447
|
+
Del,
|
448
|
+
Picture,
|
449
|
+
Source,
|
450
|
+
Image,
|
451
|
+
IFrame,
|
452
|
+
Embed,
|
453
|
+
Object,
|
454
|
+
Video,
|
455
|
+
Audio,
|
456
|
+
Track,
|
457
|
+
Map,
|
458
|
+
Area,
|
459
|
+
Table,
|
460
|
+
Caption,
|
461
|
+
ColGroup,
|
462
|
+
Column,
|
463
|
+
TBody,
|
464
|
+
THead,
|
465
|
+
TFoot,
|
466
|
+
TR,
|
467
|
+
TD,
|
468
|
+
TH,
|
469
|
+
Form,
|
470
|
+
Label,
|
471
|
+
Input,
|
472
|
+
Button,
|
473
|
+
Select,
|
474
|
+
DataList,
|
475
|
+
OptGroup,
|
476
|
+
Option,
|
477
|
+
Progress,
|
478
|
+
Meter,
|
479
|
+
FieldSet,
|
480
|
+
Legend,
|
481
|
+
Details,
|
482
|
+
Summary,
|
483
|
+
Dialog,
|
484
|
+
Script,
|
485
|
+
NoScript,
|
486
|
+
Template,
|
487
|
+
Slot,
|
488
|
+
Canvas,
|
489
|
+
)
|
490
|
+
|
ophinode/__main__.py
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
import argparse
|
2
|
+
|
3
|
+
EXAMPLE1 = """# Example program: render a page without defining a site.
|
4
|
+
#
|
5
|
+
# Running this program prints a HTML document to standard output.
|
6
|
+
#
|
7
|
+
from ophinode import *
|
8
|
+
|
9
|
+
class MainPage:
|
10
|
+
def body(self):
|
11
|
+
return Div(
|
12
|
+
H1("Main Page"),
|
13
|
+
P("Welcome to ophinode!")
|
14
|
+
)
|
15
|
+
|
16
|
+
def head(self):
|
17
|
+
return [
|
18
|
+
Meta(charset="utf-8"),
|
19
|
+
Title("Main Page")
|
20
|
+
]
|
21
|
+
|
22
|
+
print(render_page(MainPage(), HTML5Layout()))
|
23
|
+
"""
|
24
|
+
|
25
|
+
EXAMPLE2 = """# Example program: create a page in a directory.
|
26
|
+
#
|
27
|
+
# Running this program creates "index.html" in "./out" directory.
|
28
|
+
#
|
29
|
+
from ophinode import *
|
30
|
+
|
31
|
+
class DefaultLayout(Layout):
|
32
|
+
def build(self, page, context):
|
33
|
+
return [
|
34
|
+
HTML5Doctype(),
|
35
|
+
Html(
|
36
|
+
Head(
|
37
|
+
Meta(charset="utf-8"),
|
38
|
+
Title(page.title()),
|
39
|
+
page.head()
|
40
|
+
),
|
41
|
+
Body(
|
42
|
+
page.body()
|
43
|
+
),
|
44
|
+
)
|
45
|
+
]
|
46
|
+
|
47
|
+
class MainPage:
|
48
|
+
@property
|
49
|
+
def layout(self):
|
50
|
+
return DefaultLayout()
|
51
|
+
|
52
|
+
def body(self):
|
53
|
+
return Div(
|
54
|
+
H1("Main Page"),
|
55
|
+
P("Welcome to ophinode!")
|
56
|
+
)
|
57
|
+
|
58
|
+
def head(self):
|
59
|
+
return []
|
60
|
+
|
61
|
+
def title(self):
|
62
|
+
return "Main Page"
|
63
|
+
|
64
|
+
if __name__ == "__main__":
|
65
|
+
site = Site({
|
66
|
+
"default_layout": DefaultLayout(),
|
67
|
+
"export_root_path": "./out",
|
68
|
+
"default_page_output_filename": "index.html",
|
69
|
+
}, [
|
70
|
+
("/", MainPage()),
|
71
|
+
])
|
72
|
+
|
73
|
+
site.build_site()
|
74
|
+
"""
|
75
|
+
|
76
|
+
def main():
|
77
|
+
parser = argparse.ArgumentParser(prog="ophinode")
|
78
|
+
parser.add_argument("subcommand", choices=["examples"])
|
79
|
+
parser.add_argument("arguments", nargs="*")
|
80
|
+
args = parser.parse_args()
|
81
|
+
if args.subcommand == "examples":
|
82
|
+
if not args.arguments:
|
83
|
+
print("available examples: render_page, basic_site")
|
84
|
+
elif args.arguments[0] == "render_page":
|
85
|
+
print(EXAMPLE1)
|
86
|
+
elif args.arguments[0] == "basic_site":
|
87
|
+
print(EXAMPLE2)
|
88
|
+
else:
|
89
|
+
print("available examples: render_page, basic_site")
|
90
|
+
else:
|
91
|
+
parser.print_help()
|
92
|
+
|
93
|
+
if __name__ == "__main__":
|
94
|
+
main()
|
ophinode/constants.py
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
"Collection of various constants."
|
2
|
+
|
3
|
+
# Site options
|
4
|
+
EXPORT_ROOT_PATH_OPTION_KEY = "export_root_path"
|
5
|
+
EXPORT_ROOT_PATH_OPTION_DEFAULT_VALUE = ""
|
6
|
+
DEFAULT_LAYOUT_OPTION_KEY = "default_layout"
|
7
|
+
DEFAULT_LAYOUT_OPTION_DEFAULT_VALUE = None
|
8
|
+
DEFAULT_PAGE_OUTPUT_FILENAME_OPTION_KEY = "default_page_output_filename"
|
9
|
+
DEFAULT_PAGE_OUTPUT_FILENAME_OPTION_DEFAULT_VALUE = "index.html"
|
10
|
+
PAGE_OUTPUT_FILE_EXTENSION_OPTION_KEY = "page_output_file_extension"
|
11
|
+
PAGE_OUTPUT_FILE_EXTENSION_OPTION_DEFAULT_VALUE = "html"
|
12
|
+
AUTO_EXPORT_FILES_OPTION_KEY = "auto_export_files"
|
13
|
+
AUTO_EXPORT_FILES_OPTION_DEFAULT_VALUE = True
|
ophinode/exceptions.py
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class InvalidConfigurationError(Exception):
|
2
|
+
pass
|
3
|
+
|
4
|
+
class RootPathUndefinedError(InvalidConfigurationError):
|
5
|
+
pass
|
6
|
+
|
7
|
+
class RootPathIsNotADirectoryError(InvalidConfigurationError):
|
8
|
+
pass
|
9
|
+
|
10
|
+
class NonRenderableNodeError(Exception):
|
11
|
+
pass
|
12
|
+
|
13
|
+
class ExportPathCollisionError(Exception):
|
14
|
+
pass
|
15
|
+
|
16
|
+
class InvalidAttributeNameError(Exception):
|
17
|
+
pass
|
File without changes
|
ophinode/nodes/base.py
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
from typing import Any
|
2
|
+
from abc import ABC, abstractmethod
|
3
|
+
|
4
|
+
class ClosedRenderable(ABC):
|
5
|
+
@abstractmethod
|
6
|
+
def render(self, context: "ophinode.rendering.RenderContext"):
|
7
|
+
pass
|
8
|
+
|
9
|
+
class OpenRenderable(ABC):
|
10
|
+
@abstractmethod
|
11
|
+
def render_start(self, context: "ophinode.rendering.RenderContext"):
|
12
|
+
pass
|
13
|
+
|
14
|
+
@abstractmethod
|
15
|
+
def render_end(self, context: "ophinode.rendering.RenderContext"):
|
16
|
+
pass
|
17
|
+
|
18
|
+
@property
|
19
|
+
def auto_newline(self):
|
20
|
+
return False
|
21
|
+
|
22
|
+
@property
|
23
|
+
def auto_indent(self):
|
24
|
+
return False
|
25
|
+
|
26
|
+
class Expandable(ABC):
|
27
|
+
@abstractmethod
|
28
|
+
def expand(self, context: "ophinode.rendering.RenderContext"):
|
29
|
+
pass
|
30
|
+
|
31
|
+
class Preparable(ABC):
|
32
|
+
@abstractmethod
|
33
|
+
def prepare(self, context: "ophinode.rendering.RenderContext"):
|
34
|
+
pass
|
35
|
+
|
36
|
+
class Page:
|
37
|
+
@property
|
38
|
+
def layout(self):
|
39
|
+
return None
|
40
|
+
|
41
|
+
class Layout(ABC):
|
42
|
+
@abstractmethod
|
43
|
+
def build(self, page: Any, context: "ophinode.rendering.RenderContext"):
|
44
|
+
pass
|
45
|
+
|