acrn-hypervisor/doc/scripts/fix-git-modified-date.sh
David B. Kinder 8fb3ca83a6 doc: update last updated information on page footers
The "Last Updated" footer shows the date the page was published, not
when the content was last updated. This has caused readers some
confusion.  Update the footer with the date of the git commit that last
updated the document, and clarify with both the last modified and
published dates in the footer, something like this:

   Last modified: Aug 19, 2021. Published: Nov 03, 2021.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2021-11-03 19:10:56 -07:00

23 lines
934 B
Bash
Executable File

#!/bin/bash
# Copyright (C) 2021 Intel Corporation.
# SPDX-License-Identifier: BSD-3-Clause
#
# Run this script in the _build/html folder after generating the HTML content.
#
# Scan through HTML files look for the corresponding .rst file (in doc or misc
# for ACRN project). Replace the "Last updated" date in the footer with the last
# commit date for the corresponding .rst file (if we can find it). Tweak
# wording to mention Last modified and published dates.
cd _build/html
find -type f -name "*.html" | \
while read filename;
do
f=${filename%.*}.rst
[[ -f "../../$f" ]] && prefix="../.."
[[ -f "../../../$f" ]] && prefix="../../.."
d="$(git log -1 --format="%ad" --date=format:"%b %d, %Y" -- "$prefix/$f")";
[[ ! -z "$d" ]] && sed -i "s/\(^ *<span class=\"lastupdated\">\)Last updated on \(.*\)\.$/\1Last modified: $d. Published: \2./" $filename;
done