mirror of
https://github.com/kubernetes-sigs/kubespray.git
synced 2026-05-19 19:44:11 +03:00
96bb0a3e12
If we don't, find output can change depending on system locale, which will produce inconsistent results.
35 lines
1.3 KiB
Bash
Executable File
35 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Generate documentation
|
|
# This script generates a list of all the markdown files in the docs folder
|
|
# and prints them in a markdown list format.
|
|
# The script will print the name of the folder and the files inside it.
|
|
# The script will also convert the folder and file names to a more human-readable format.
|
|
# The script will ignore any files that are not markdown files.
|
|
# Usage: bash scripts/gen_docs_sidebar.sh > docs/_sidebar.md
|
|
|
|
export LANG=C
|
|
{
|
|
echo "* [Readme](/)"
|
|
|
|
for folder in $(find docs/*/ | sort -f); do
|
|
# Check if it is a directory
|
|
if [ -d "$folder" ]; then
|
|
subdir=$(basename "$folder")
|
|
subdir=${subdir//_/ } # Replace "_" with empty string
|
|
subdir=$(echo "$subdir" | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1') # Convert first letter of each word to uppercase
|
|
if [ -n "$(find "$folder" -name '*.md' -type f)" ]; then
|
|
echo "* $subdir"
|
|
fi
|
|
for file in $(find docs/"$(basename "$folder")"/*.md | sort -f); do
|
|
if [ -f "$file" ]; then
|
|
FILE=$(basename "$file" .md)
|
|
FILE=${FILE//_/ } # Replace "_" with empty string
|
|
FILE=$(echo "$FILE" | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1') # Convert first letter of each word to uppercase
|
|
echo " * [$FILE](/$file)"
|
|
fi
|
|
done
|
|
fi
|
|
done
|
|
} > docs/_sidebar.md
|