@@ -87,12 +87,19 @@ def parse_articles(self):
87
87
article = utils .load_and_validate_yaml (file_path , self .schema_article )
88
88
article_content_path = article ['content' ]
89
89
article ["name" ] = os .path .basename (os .path .dirname (file_path ))
90
+ article ["parent_folder" ] = os .path .basename (os .path .dirname (os .path .dirname (file_path )))
90
91
91
92
content_real_path = self .resolve_relative_or_repo_absolute_path (
92
93
os .path .dirname (file_path ), article_content_path )
93
94
with open (content_real_path , 'r' ) as content_file :
94
95
article_content = content_file .read ()
95
96
article ['content_html' ] = utils .to_html (article_content )
97
+
98
+ if article ['name' ] == 'introduction' :
99
+ article ["path_html" ] = '/'
100
+ else :
101
+ article ["path_html" ] = f"/{ article ['name' ]} /"
102
+
96
103
self .articles .append (article )
97
104
except Exception as e :
98
105
self .logger .exception (e )
@@ -411,20 +418,14 @@ def create_article_page(self, article):
411
418
article ["content_html" ] = self .process_special_article_content (article ["content_html" ])
412
419
html_content = self .render_page (article ['title' ], article_template .render (article = article ))
413
420
414
- if article ['name' ] == 'introduction' :
415
- web_path = '/'
416
- else :
417
- web_path = f"/{ article ['name' ]} /"
418
- article_folder = OUTPUT_HTML_PATH + web_path
421
+ article_folder = OUTPUT_HTML_PATH + article ["path_html" ]
419
422
420
423
Path (article_folder ).mkdir (parents = True , exist_ok = True )
421
424
422
425
output_path = os .path .join (article_folder , 'index.html' )
423
426
with open (output_path , 'w' ) as html_file :
424
427
html_file .write (html_content )
425
428
426
- article ["path_html" ] = web_path
427
-
428
429
self .logger .info (f"Generated { output_path } for article { article ['name' ]} " )
429
430
430
431
def create_category (self , web_path , category_data ):
@@ -450,7 +451,28 @@ def create_category(self, web_path, category_data):
450
451
else :
451
452
category_folder = OUTPUT_HTML_PATH + web_path
452
453
453
- if 'subcategories' in category_data :
454
+ if 'articles' in category_data :
455
+ articles_folder = category_data ['articles' ]['path' ]
456
+ # List folders in articles/folder_name
457
+ articles_folder_path = os .path .join (DOCS_REPO_PATH , 'articles' , articles_folder )
458
+ for article in self .articles :
459
+ if article ['parent_folder' ] == articles_folder :
460
+ items .append ({
461
+ 'name' : article ['title' ],
462
+ 'path_html' : article ['path_html' ]
463
+ })
464
+ elif 'functions' in category_data :
465
+ functions_folder = category_data ['functions' ]['path' ]
466
+ functions_type = category_data ['functions' ]['type' ]
467
+ functions_folder_path = os .path .join (DOCS_REPO_PATH , 'functions' , functions_folder )
468
+ for function in self .functions :
469
+ if function ['type_name' ] == functions_type and function ['folder' ] == functions_folder :
470
+ function ["category" ] = category_name
471
+ items .append ({
472
+ 'name' : function ['name' ],
473
+ 'path_html' : function ['path_html' ]
474
+ })
475
+ elif 'subcategories' in category_data :
454
476
# List subcategories
455
477
for subcategory in category_data ['subcategories' ]:
456
478
subcat_name = subcategory ['name' ]
0 commit comments