@@ -374,8 +374,8 @@ def generate_operator_doc(
374374 file .write (output )
375375
376376
377- def generate_toc_tree (docs_path : Path ):
378- """Write the global toc.yml file for the DPF documentation based on the operators found.
377+ def update_toc_tree (docs_path : Path ):
378+ """Update the global toc.yml file for the DPF documentation based on the operators found.
379379
380380 Parameters
381381 ----------
@@ -391,7 +391,7 @@ def generate_toc_tree(docs_path: Path):
391391 operators = [] # Reset operators for each category
392392 for file in folder .iterdir ():
393393 if (
394- file .is_file () and file .suffix == ".md"
394+ file .is_file () and file .suffix == ".md" and not file . name . endswith ( "_upd.md" )
395395 ): # Ensure 'file' is a file with .md extension
396396 file_name = file .name
397397 file_path = f"{ category } /{ file_name } "
@@ -405,10 +405,18 @@ def generate_toc_tree(docs_path: Path):
405405 template = jinja2 .Template (template_file .read ())
406406 output = template .render (data = data ) # Pass 'data' as a named argument
407407
408- # Write the rendered output to toc.yml at the operators_doc level
408+ # Update the original toc.yml file with the rendered output for operator_specifications
409409 toc_path = docs_path / Path ("toc.yml" )
410+ with toc_path .open (mode = "r" ) as file :
411+ original_toc = file .read ()
412+ new_toc = re .sub (
413+ pattern = r"- name: Operator specifications\s*.*?(?=- name: Changelog|\Z)" ,
414+ repl = output ,
415+ string = original_toc ,
416+ flags = re .DOTALL ,
417+ )
410418 with toc_path .open (mode = "w" ) as file :
411- file .write (output )
419+ file .write (new_toc )
412420
413421
414422def generate_operators_doc (
@@ -452,7 +460,7 @@ def generate_operators_doc(
452460 for operator_name in operators :
453461 generate_operator_doc (server , operator_name , include_private , output_path )
454462 # Generate the toc tree
455- generate_toc_tree (output_path )
463+ update_toc_tree (output_path )
456464 # Use update files in output_path
457465 update_operator_descriptions (output_path )
458466
0 commit comments