@@ -350,14 +350,6 @@ def _copy_files_needed_for_post_processing(output: str, input: str, library_id:
350350 f"{ output } /{ path_to_library } /.repo-metadata.json" ,
351351 )
352352
353- source_readme_path = Path (output ) / path_to_library / "README.rst"
354- if source_readme_path .exists ():
355- destination_docs_dir = Path (output ) / path_to_library / "docs"
356- destination_readme_path = destination_docs_dir / "README.rst"
357-
358- os .makedirs (destination_docs_dir , exist_ok = True )
359- shutil .copy (source_readme_path , destination_readme_path )
360-
361353 # copy post-procesing files
362354 for post_processing_file in glob .glob (
363355 f"{ input } /client-post-processing/*.yaml"
@@ -509,6 +501,24 @@ def _generate_repo_metadata_file(
509501 _write_json_file (output_repo_metadata , metadata_content )
510502
511503
504+ def _copy_readme_to_docs (output : str , library_id : str ):
505+ """Copies the generated README.rst to the docs directory.
506+
507+ Args:
508+ output(str): Path to the directory in the container where code
509+ should be generated.
510+ library_id(str): The library id.
511+ """
512+ path_to_library = f"packages/{ library_id } "
513+ source_readme_path = Path (output ) / path_to_library / "README.rst"
514+ if source_readme_path .exists ():
515+ destination_docs_dir = Path (output ) / path_to_library / "docs"
516+ destination_readme_path = destination_docs_dir / "README.rst"
517+
518+ os .makedirs (destination_docs_dir , exist_ok = True )
519+ shutil .copy (source_readme_path , destination_readme_path )
520+
521+
512522def handle_generate (
513523 librarian : str = LIBRARIAN_DIR ,
514524 source : str = SOURCE_DIR ,
@@ -550,6 +560,7 @@ def handle_generate(
550560 _copy_files_needed_for_post_processing (output , input , library_id )
551561 _generate_repo_metadata_file (output , library_id , source , apis_to_generate )
552562 _run_post_processor (output , library_id )
563+ _copy_readme_to_docs (output , library_id )
553564 _clean_up_files_after_post_processing (output , library_id )
554565 except Exception as e :
555566 raise ValueError ("Generation failed." ) from e
0 commit comments