You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.3 KiB

  1. #!/usr/bin/env bash
  2. # Generate documentation
  3. # This script generates a list of all the markdown files in the docs folder
  4. # and prints them in a markdown list format.
  5. # The script will print the name of the folder and the files inside it.
  6. # The script will also convert the folder and file names to a more human-readable format.
  7. # The script will ignore any files that are not markdown files.
  8. # Usage: bash scripts/gen_docs_sidebar.sh > docs/_sidebar.md
  9. echo "* [Readme](/)"
  10. for folder in $(find docs/*/ | sort -f); do
  11. # Check if it is a directory
  12. if [ -d "$folder" ]; then
  13. subdir=$(basename "$folder")
  14. subdir=${subdir//_/ } # Replace "_" with empty string
  15. 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
  16. if [ -n "$(find "$folder" -name '*.md' -type f)" ]; then
  17. echo "* $subdir"
  18. fi
  19. for file in $(find docs/"$(basename "$folder")"/*.md | sort -f); do
  20. if [ -f "$file" ]; then
  21. FILE=$(basename "$file" .md)
  22. FILE=${FILE//_/ } # Replace "_" with empty string
  23. 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
  24. echo " * [$FILE](/$file)"
  25. fi
  26. done
  27. fi
  28. done