Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the repos_file_branch macro and multiversion wf #307

Merged
merged 4 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 "<html><head><meta http-equiv=\"refresh\" content=\"0; url=rolling/index.html\" /></head></html>" > "$(BUILDDIR)"/html/index.html
# legacy, renamed Rolling version from "master" to "rolling"
@cp -r "$(BUILDDIR)"/html/rolling/ "$(BUILDDIR)"/html/master
@echo "<html><head><meta http-equiv=\"refresh\" content=\"0; url=../rolling/index.html\" /></head></html>" > "$(BUILDDIR)"/html/master/index.html
./make_help_scripts/fix_index.py --builddir $(BUILDDIR)
christophfroehlich marked this conversation as resolved.
Show resolved Hide resolved

multiversion-with-errors: Makefile
@echo Building multi version documentation without API
Expand All @@ -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 "<html><head><meta http-equiv=\"refresh\" content=\"0; url=rolling/index.html\" /></head></html>" > "$(BUILDDIR)"/html/index.html
# legacy, renamed Rolling version from "master" to "rolling"
@cp -r "$(BUILDDIR)"/html/rolling/ "$(BUILDDIR)"/html/master
@echo "<html><head><meta http-equiv=\"refresh\" content=\"0; url=../rolling/index.html\" /></head></html>" > "$(BUILDDIR)"/html/master/index.html
./make_help_scripts/fix_index.py --builddir $(BUILDDIR)
christophfroehlich marked this conversation as resolved.
Show resolved Hide resolved

multiversion-with-api: Makefile
@echo Building multi version documentation with API
Expand All @@ -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 "<html><head><meta http-equiv=\"refresh\" content=\"0; url=rolling/index.html\" /></head></html>" > "$(BUILDDIR)"/html/index.html
# legacy, renamed Rolling version from "master" to "rolling"
@cp -r "$(BUILDDIR)"/html/rolling/ "$(BUILDDIR)"/html/master
@echo "<html><head><meta http-equiv=\"refresh\" content=\"0; url=../rolling/index.html\" /></head></html>" > "$(BUILDDIR)"/html/master/index.html
./make_help_scripts/fix_index.py --builddir $(BUILDDIR)
christophfroehlich marked this conversation as resolved.
Show resolved Hide resolved

.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

Expand Down
6 changes: 3 additions & 3 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
copyright = "{}, {}".format(time.strftime("%Y"), author)

# Adjust those to change ros distribution
# you might also need to white list branch
# you might also need to white list branch (see smv_branch_whitelist)
ros_distro = "rolling"
distro_title = "Rolling"
distro_title_full = "Rolling Ridley"
repos_file_branch = "rolling" # for single version only
repos_file_branch = "master" # sets macro REPOS_FILE_BRANCH (will be overridden with multiversion)

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -341,7 +341,7 @@ def smv_rewrite_configs(app, config):
# this map is used to match branches of control.ros.org to REPOS_FILE_BRANCH macro
subrepo_branch = {
base_branch: "master",
"jazzy": "jazzy",
"jazzy": "master",
"iron": "iron",
"humble": "humble",
"foxy": "foxy",
Expand Down
39 changes: 39 additions & 0 deletions make_help_scripts/fix_index.py
Original file line number Diff line number Diff line change
@@ -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'<html><head><meta http-equiv="refresh" content="0; url={base_branch}/index.html" /></head></html>')

# 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'<html><head><meta http-equiv="refresh" content="0; url=../{base_branch}/index.html" /></head></html>')

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Fix index.')
parser.add_argument('--builddir', required=True, help='Build directory.')
christophfroehlich marked this conversation as resolved.
Show resolved Hide resolved

args = parser.parse_args()
fix_index(deploy_defines.base_branch, args.builddir)
christophfroehlich marked this conversation as resolved.
Show resolved Hide resolved