@@ -55,11 +55,31 @@ def load_schemas(self):
55
55
except Exception as e :
56
56
raise WikiBuilderError (f'Error loading schemas: { e } ' )
57
57
58
+ def parse_elements (self ):
59
+ self .elements = []
60
+
61
+ for root , _ , files in os .walk (os .path .join (DOCS_REPO_PATH , 'elements' )):
62
+ for filename in files :
63
+ if filename .endswith ('.yaml' ):
64
+ file_path = os .path .join (root , filename )
65
+ try :
66
+ element = utils .load_yaml (file_path )
67
+
68
+ element ['real_path' ] = file_path
69
+ element ['description_html' ] = utils .to_html (element ['description' ])
70
+
71
+ self .elements .append (element )
72
+ except Exception as e :
73
+ self .logger .exception (e )
74
+ raise WikiBuilderError (f'Error loading element { file_path } ' )
75
+
76
+ def parse_events (self ):
77
+ pass
78
+
58
79
def parse_functions (self ):
59
- doc_folder = os .path .join (DOCS_REPO_PATH , 'functions' )
60
80
self .functions = []
61
81
62
- for root , _ , files in os .walk (doc_folder ):
82
+ for root , _ , files in os .walk (os . path . join ( DOCS_REPO_PATH , 'functions' ) ):
63
83
for filename in files :
64
84
if filename .endswith ('.yaml' ):
65
85
file_path = os .path .join (root , filename )
@@ -320,6 +340,23 @@ def render_page(self, title, content):
320
340
navigation = self .navigation ,
321
341
content = content
322
342
)
343
+
344
+ def create_element_page (self , element ):
345
+ element_template = self .input_env .get_template ('element.html' )
346
+ html_content = self .render_page (element ['name' ], element_template .render (element = element ))
347
+
348
+ web_path = f"/{ element ['name' ]} /"
349
+ element_folder = OUTPUT_HTML_PATH + web_path
350
+
351
+ Path (element_folder ).mkdir (parents = True , exist_ok = True )
352
+
353
+ output_path = os .path .join (element_folder , 'index.html' )
354
+ with open (output_path , 'w' ) as html_file :
355
+ html_file .write (html_content )
356
+
357
+ element ["path_html" ] = web_path
358
+
359
+ self .logger .info (f"Generated { output_path } for element { element ['name' ]} " )
323
360
324
361
def create_function_page (self , function ):
325
362
function_template = self .input_env .get_template ('function.html' )
@@ -507,11 +544,21 @@ def create_item(item):
507
544
create_item (subitem )
508
545
else :
509
546
create_item (item )
547
+
548
+ # Populate see_also for functions
549
+ self .generate_function_relations ()
550
+
551
+ # Populate see_also for elements
552
+ # self.generate_element_relations()
510
553
511
554
# Create function pages
512
555
for function in self .functions :
513
556
self .create_function_page (function )
514
557
558
+ # Create element pages
559
+ for element in self .elements :
560
+ self .create_element_page (element )
561
+
515
562
# Other articles
516
563
self .create_article ('privacy' )
517
564
@@ -541,6 +588,8 @@ def generate_wiki(self):
541
588
self .load_schemas ()
542
589
543
590
self .parse_functions ()
591
+ self .parse_events ()
592
+ self .parse_elements ()
544
593
self .parse_version ()
545
594
546
595
self .create_pages ()
0 commit comments