diff --git a/Makefile b/Makefile index c1e4fc722e..642fd1fdf9 100644 --- a/Makefile +++ b/Makefile @@ -81,10 +81,7 @@ multiversion: Makefile @echo Step 3: Deleting temporary commits ./make_help_scripts/delete_tmp_commits.py @echo Step 4: Create correct index + legacy master version - @echo "
" > "$(BUILDDIR)"/html/index.html -# legacy, renamed Rolling version from "master" to "rolling" - @cp -r "$(BUILDDIR)"/html/rolling/ "$(BUILDDIR)"/html/master - @echo "" > "$(BUILDDIR)"/html/master/index.html + ./make_help_scripts/fix_index.py --builddir $(BUILDDIR) multiversion-with-errors: Makefile @echo Building multi version documentation without API @@ -95,10 +92,7 @@ multiversion-with-errors: Makefile @echo Step 3: Deleting temporary commits ./make_help_scripts/delete_tmp_commits.py @echo Step 4: Create correct index + legacy master version - @echo "" > "$(BUILDDIR)"/html/index.html -# legacy, renamed Rolling version from "master" to "rolling" - @cp -r "$(BUILDDIR)"/html/rolling/ "$(BUILDDIR)"/html/master - @echo "" > "$(BUILDDIR)"/html/master/index.html + ./make_help_scripts/fix_index.py --builddir $(BUILDDIR) multiversion-with-api: Makefile @echo Building multi version documentation with API @@ -113,10 +107,7 @@ multiversion-with-api: Makefile @echo Step 5: Building multiversion API ./make_help_scripts/create_api_multi_version.py @echo Step 6: Create correct index + legacy master version - @echo "" > "$(BUILDDIR)"/html/index.html -# legacy, renamed Rolling version from "master" to "rolling" - @cp -r "$(BUILDDIR)"/html/rolling/ "$(BUILDDIR)"/html/master - @echo "" > "$(BUILDDIR)"/html/master/index.html + ./make_help_scripts/fix_index.py --builddir $(BUILDDIR) .PHONY: help Makefile html-with-errors html-with-api multiversion multiversion-with-api multiversion-with-errors html-all-subrepos html-all-subrepos-with-api html-all-subrepos-with-errors linkcheck-all-subrepos-with-api diff --git a/make_help_scripts/fix_index.py b/make_help_scripts/fix_index.py new file mode 100755 index 0000000000..91e897b64c --- /dev/null +++ b/make_help_scripts/fix_index.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# Copyright (c) 2023 ros2_control maintainers +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import argparse +import os +import shutil +import deploy_defines + +def fix_index(base_branch, builddir): + + # Create the index.html file in the html directory + with open(os.path.join(builddir, 'html', 'index.html'), 'w') as f: + f.write(f'') + + # Copy the contents of the base_branch directory to the master directory + shutil.copytree(os.path.join(builddir, 'html', base_branch), os.path.join(builddir, 'html', 'master'), dirs_exist_ok=True) + + # Patch the index.html file in the master directory + with open(os.path.join(builddir, 'html', 'master', 'index.html'), 'w') as f: + f.write(f'') + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Fix index.') + parser.add_argument('--builddir', required=True, help='Build directory.') + + args = parser.parse_args() + fix_index(deploy_defines.base_branch, args.builddir)