Files
rtabmap_ros/tools/set_doc_distro.sh
T
matlabbe 61edb4ee85 rtabmap_util tests and doc (#1450)
* Initial tests

* more tests

* More in-depth deskew() testing

* slightly less verbose clamping corruption warning

* added tf buffer related tests

* added remaining tests

* Added rosdoc2, improve tests when we require sync of odom stamp and sensor stamp

* cleanup doc

* fixing ci

* rtabmap_util tests and doc

* Added db_player tests

* Added MapsManager tests

* Added map_assembler tests

* Documenting node first draft

* relative links

* Fixed british->usa english style. Reviewed all md files.

* added link to install ros1

* updated badges

* added Iron

* added ubuntu

* added codecov

* updated coverage ci

* fixing rosdep

* updated ci cov job

* ci bump

* fixing cov ci

* small doc cleanup
2026-09-07 21:23:22 -07:00

53 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Rewrites the ROS distro in every docs.ros.org link of the documentation pages.
#
# The distro cannot be resolved at documentation build time: rosdoc2 has no notion of one
# and injects nothing a Markdown page could read, and docs.ros.org has no distro-agnostic
# URL for message types. So the distro is baked into the links, and this script is how it
# gets flipped on a per-distro branch.
#
# Usage:
# tools/set_doc_distro.sh jazzy [path ...]
#
# Rewrites every *.md under the given paths, defaulting to the whole repository. Note that
# it cannot tell a link meant to track the branch from one that deliberately names a
# distro -- the root README's "Humble minimum required" note, for instance -- so pass
# explicit paths when that matters.
#
# On a distro branch, treat the documentation as *derived* rather than hand-edited, and
# the merge from the development branch never conflicts:
#
# git merge ros2
# git checkout ros2 -- '*/doc' '*/README.md' # always take the upstream pages
# tools/set_doc_distro.sh humble # then re-stamp the distro
# git commit -a
#
set -euo pipefail
distro=${1:-}
if [ -z "$distro" ]; then
echo "usage: $(basename "$0") <distro> e.g. $(basename "$0") jazzy" >&2
exit 1
fi
# An explicit list rather than a wildcard: docs.ros.org also serves /en/api/, which is the
# legacy ROS 1 message documentation and must not be rewritten into a distro.
known='humble|iron|jazzy|kilted|lyrical|rolling'
root=$(cd "$(dirname "$0")/.." && pwd)
shift || true
paths=("$@")
[ ${#paths[@]} -eq 0 ] && paths=("$root")
mapfile -t files < <(grep -rlE "docs\.ros\.org/en/($known)/" --include='*.md' "${paths[@]}")
if [ ${#files[@]} -eq 0 ]; then
echo "no documentation pages with a distro link found" >&2
exit 0
fi
sed -i -E "s#docs\.ros\.org/en/($known)/#docs.ros.org/en/$distro/#g" "${files[@]}"
echo "set distro to '$distro' in ${#files[@]} file(s):"
printf ' %s\n' "${files[@]#$root/}"