feat: add documentation for scripts

Signed-off-by: K.B.Dharun Krishna <kbdharunkrishna@gmail.com>
This commit is contained in:
K.B.Dharun Krishna
2023-12-21 19:47:18 +05:30
parent ab46f0494f
commit b2dc1a28d1
4 changed files with 108 additions and 10 deletions

View File

@@ -1,15 +1,28 @@
#!/bin/sh
# SPDX-License-Identifier: MIT
# This script checks consistency between the filenames and the page title.
# Usage: ./scripts/wrong-filename.sh
# Output file for recording inconsistencies
OUTPUT_FILE="filename-consistency-check-output.txt"
# Remove existing output file (if any)
rm -f "$OUTPUT_FILE"
set -e
for path in $(find . -name '*.md' -type f); do
# Iterate through all Markdown files in the 'pages' directories
for path in $(find pages* -name '*.md' -type f); do
# Extract the expected command name from the filename
COMMAND_NAME_FILE=$(basename "$path" | head -c-4 | tr '-' ' ' | tr '[:upper:]' '[:lower:]')
# Extract the command name from the first line of the Markdown file
COMMAND_NAME_PAGE=$(head -n1 "$path" | tail -c+3 | tr '-' ' ' | tr '[:upper:]' '[:lower:]')
# Check if there is a mismatch between filename and content command names
if [ "$COMMAND_NAME_FILE" != "$COMMAND_NAME_PAGE" ]; then
echo "$path"
echo "$COMMAND_NAME_FILE"
echo "$COMMAND_NAME_PAGE"
echo "\n\n"
echo "Inconsistency found in file: $path: $COMMAND_NAME_PAGE should be $COMMAND_NAME_FILE" >> "$OUTPUT_FILE"
fi
done
echo "Filename consistency check completed. Output written to: $OUTPUT_FILE"