Skip to content

Commit dd35c1b

Browse files
committed
Include domains in documentation generation
1 parent 7b8b37b commit dd35c1b

4 files changed

Lines changed: 37 additions & 11 deletions

File tree

.github/workflows/internal-environment-variables-reference-documentation.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ jobs:
2828
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
2929

3030
- name: Generate environment variables reference document
31-
working-directory: scripts
3231
run: |
33-
./documentation/generateEnvironmentVariableReference.sh
32+
./scripts/documentation/generateEnvironmentVariableReference.sh
3433
3534
- name: Use git to detect changes in the regenerated document and set generated_document_changed
3635
run: git diff --quiet || echo "generated_document_changed=true" >> $GITHUB_ENV

.github/workflows/internal-scripts-reference-documentation.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ jobs:
2828
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
2929

3030
- name: Generate scripts reference document
31-
working-directory: scripts
3231
run: |
33-
./documentation/generateScriptReference.sh
32+
./scripts/documentation/generateScriptReference.sh
3433
3534
- name: Use git to detect changes in the regenerated document and set generated_document_changed
3635
run: git diff --quiet || echo "generated_document_changed=true" >> $GITHUB_ENV

scripts/documentation/generateEnvironmentVariableReference.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
#!/usr/bin/env bash
22

3-
# Runs "appendEnvironmentVariable.sh" for every script file in the current directory and its sub directories.
3+
# Runs "appendEnvironmentVariable.sh" for every script file in the scripts directory and its sub directories.
4+
# Note: This script can be run from any directory (e.g. the repository root). It changes to the scripts directory internally.
45

56
# Requires appendEnvironmentVariable.sh
67

78
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
89
set -o errexit -o pipefail
910

10-
## Get this "scripts" directory if not already set
11+
## Get this "scripts/documentation" directory if not already set
1112
# Even if $BASH_SOURCE is made for Bourne-like shells it is also supported by others and therefore here the preferred solution.
1213
# CDPATH reduces the scope of the cd command to potentially prevent unintended directory changes.
1314
# This way non-standard tools like readlink aren't needed.
1415
DOCUMENTATION_SCRIPTS_DIR=${DOCUMENTATION_SCRIPTS_DIR:-$( CDPATH=. cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P )} # Repository directory containing the documentation generation scripts
1516
echo "generateEnvironmentVariablesReference: DOCUMENTATION_SCRIPTS_DIR=${DOCUMENTATION_SCRIPTS_DIR}"
1617

18+
# Change to the scripts directory so that the output file is written there and all relative paths work correctly
19+
cd "${DOCUMENTATION_SCRIPTS_DIR}/.."
20+
1721
echo "generateEnvironmentVariableReference: Generating ENVIRONMENT_VARIABLES.md..."
1822

1923
# Clear existing markdown document
2024
source "${DOCUMENTATION_SCRIPTS_DIR}/appendEnvironmentVariables.sh" "clear" || exit 1
2125

22-
# Loop through all script files in the current directory
23-
find . -type f -name "*.sh" | sort | while read -r scriptFile; do
26+
# Collect search roots: always the current scripts directory, plus ../domains if it exists
27+
search_roots="."
28+
if [ -d "../domains" ]; then
29+
search_roots=". ../domains"
30+
fi
31+
32+
# Loop through all script files in the current directory and domain directories
33+
# shellcheck disable=SC2086
34+
find ${search_roots} -type f -name "*.sh" | sort | while read -r scriptFile; do
2435
echo "generateEnvironmentVariablesReference: Searching for environment variables in ${scriptFile}"
2536
source "${DOCUMENTATION_SCRIPTS_DIR}/appendEnvironmentVariables.sh" "${scriptFile}" || exit 1
2637
done

scripts/documentation/generateScriptReference.sh

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
#!/usr/bin/env bash
22

3-
# Generates "SCRIPTS.md" containing a reference to all scripts in this directory and its subdirectories.
3+
# Generates "SCRIPTS.md" containing a reference to all scripts in the scripts directory and its subdirectories.
4+
# Note: This script can be run from any directory (e.g. the repository root). It changes to the scripts directory internally.
45
# This script was generated by Chat-GPT after some messages back and forth and then tuned manually.
56

67
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
78
set -o errexit -o pipefail
89

10+
## Get this "scripts/documentation" directory if not already set
11+
# Even if $BASH_SOURCE is made for Bourne-like shells it is also supported by others and therefore here the preferred solution.
12+
# CDPATH reduces the scope of the cd command to potentially prevent unintended directory changes.
13+
# This way non-standard tools like readlink aren't needed.
14+
DOCUMENTATION_SCRIPTS_DIR=${DOCUMENTATION_SCRIPTS_DIR:-$( CDPATH=. cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P )} # Repository directory containing the documentation generation scripts
15+
16+
# Change to the scripts directory so that the output file is written there and all relative paths work correctly
17+
cd "${DOCUMENTATION_SCRIPTS_DIR}/.."
18+
919
# Markdown file name
1020
markdown_file="SCRIPTS.md"
1121

@@ -22,8 +32,15 @@ echo "generateScriptReference: Generating ${markdown_file}..."
2232
echo "-------|-----------|------------"
2333
} > ${markdown_file}
2434

25-
# Loop through all script files in the current directory
26-
find . -type f -name "*.sh" | sort | while read -r script_file; do
35+
# Collect search roots: always the current scripts directory, plus ../domains if it exists
36+
search_roots="."
37+
if [ -d "../domains" ]; then
38+
search_roots=". ../domains"
39+
fi
40+
41+
# Loop through all script files in the current directory and domain directories
42+
# shellcheck disable=SC2086
43+
find ${search_roots} -type f -name "*.sh" | sort | while read -r script_file; do
2744
# Get the description of the script file
2845
description=$(awk 'NR>1 && /^ *#/{sub(/^ *# ?/,""); print; exit}' "$script_file")
2946

0 commit comments

Comments
 (0)