Skip to content

Commit e2f45b7

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

5 files changed

Lines changed: 31 additions & 19 deletions

.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/appendEnvironmentVariables.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
# Fail on any error ("-e" = exit on first error, "-o pipefail" exist on errors within piped commands)
99
set -o errexit -o pipefail
1010

11-
# Markdown file name
12-
markdownFile="ENVIRONMENT_VARIABLES.md"
11+
# Markdown file name (can be overridden by second argument)
12+
markdownFile="${2:-ENVIRONMENT_VARIABLES.md}"
1313

1414
# If the first command line option is "clear" (instead of a filename) then delete the markdown file.
1515
if [[ "$1" == "clear" ]] ; then
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
#!/usr/bin/env bash
22

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

5-
# Requires appendEnvironmentVariable.sh
6+
# Requires appendEnvironmentVariables.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
15-
echo "generateEnvironmentVariablesReference: DOCUMENTATION_SCRIPTS_DIR=${DOCUMENTATION_SCRIPTS_DIR}"
16+
echo "generateEnvironmentVariableReference: DOCUMENTATION_SCRIPTS_DIR=${DOCUMENTATION_SCRIPTS_DIR}"
1617

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

1923
# Clear existing markdown document
20-
source "${DOCUMENTATION_SCRIPTS_DIR}/appendEnvironmentVariables.sh" "clear" || exit 1
24+
source "${DOCUMENTATION_SCRIPTS_DIR}/appendEnvironmentVariables.sh" "clear" "scripts/ENVIRONMENT_VARIABLES.md" || exit 1
2125

22-
# Loop through all script files in the current directory
26+
# Loop through all script files in all directories from the repository root
2327
find . -type f -name "*.sh" | sort | while read -r scriptFile; do
24-
echo "generateEnvironmentVariablesReference: Searching for environment variables in ${scriptFile}"
25-
source "${DOCUMENTATION_SCRIPTS_DIR}/appendEnvironmentVariables.sh" "${scriptFile}" || exit 1
28+
echo "generateEnvironmentVariableReference: Searching for environment variables in ${scriptFile}"
29+
source "${DOCUMENTATION_SCRIPTS_DIR}/appendEnvironmentVariables.sh" "${scriptFile}" "scripts/ENVIRONMENT_VARIABLES.md" || exit 1
2630
done
2731

2832
echo "generateEnvironmentVariableReference: Successfully generated ENVIRONMENT_VARIABLES.md."

scripts/documentation/generateScriptReference.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
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 all directories and subdirectories.
4+
# Note: This script can be run from any directory (e.g. the repository root). It changes to the repository root 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

9-
# Markdown file name
10-
markdown_file="SCRIPTS.md"
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 repository root so that the output file is written there and all relative paths work correctly
17+
cd "${DOCUMENTATION_SCRIPTS_DIR}/../.."
18+
19+
# Markdown file name (written to scripts directory)
20+
markdown_file="scripts/SCRIPTS.md"
1121

1222
echo "generateScriptReference: Generating ${markdown_file}..."
1323

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

25-
# Loop through all script files in the current directory
35+
# Loop through all script files in all directories from the repository root
2636
find . -type f -name "*.sh" | sort | while read -r script_file; do
2737
# Get the description of the script file
2838
description=$(awk 'NR>1 && /^ *#/{sub(/^ *# ?/,""); print; exit}' "$script_file")

0 commit comments

Comments
 (0)