-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b31de5
commit 03c562d
Showing
7 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
examples/lib/tour/0* | ||
docs/reference | ||
docs/pluginreference | ||
hack/collapse/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test_example_collapsible.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/bin/bash | ||
|
||
# Auto Collapse | ||
#This is a script that takes in | ||
# - a markdown file | ||
# - a designated output file | ||
# - the number of lines as a threshold on when to collapse a section. | ||
# | ||
# Sample | ||
# ./auto_collapse.sh test_example.md test_example_collapsible.md 10 | ||
|
||
# Input and output files | ||
INPUT_FILE=${1:-"README.md"} | ||
OUTPUT_FILE=${2:-"README_collapsible.md"} | ||
THRESHOLD=${3:-10} | ||
|
||
# Ensure output file is empty initially | ||
rm -f "$OUTPUT_FILE" | ||
|
||
# Variables to track sections | ||
inside_section=false | ||
section_lines=() | ||
section_header="" | ||
|
||
# Function to process and write a section | ||
write_section() { | ||
local header="$1" | ||
local lines=("${@:2}") | ||
# Remove ## or other Markdown header prefixes for the summary | ||
local clean_header | ||
clean_header=$(echo "$header" | sed -E 's/^#+[[:space:]]//') | ||
|
||
if [[ ${#lines[@]} -gt $THRESHOLD ]]; then | ||
{ | ||
echo "<details>" | ||
echo "<summary>${clean_header}</summary>" | ||
echo | ||
printf "%s\n" "${lines[@]}" | ||
echo "</details>" | ||
} >> "$OUTPUT_FILE" | ||
else | ||
echo "$header" >> "$OUTPUT_FILE" | ||
printf "%s\n" "${lines[@]}" >> "$OUTPUT_FILE" | ||
fi | ||
} | ||
|
||
# Read the Markdown file line by line | ||
while IFS= read -r line || [[ -n $line ]]; do | ||
# Preserve comment blocks | ||
if [[ $line =~ ^\<!-- ]] || [[ $line =~ ^--\> ]]; then | ||
# Finalize the current section if inside one | ||
if [[ $inside_section == true ]]; then | ||
write_section "$section_header" "${section_lines[@]:1}" # Exclude the header | ||
inside_section=false | ||
fi | ||
# Write the comment directly | ||
echo "$line" >> "$OUTPUT_FILE" | ||
continue | ||
fi | ||
|
||
if [[ $line =~ ^#+\ ]]; then # New section starts | ||
if [[ $inside_section == true ]]; then | ||
# Write the previous section | ||
write_section "$section_header" "${section_lines[@]:1}" # Exclude the header | ||
fi | ||
# Start a new section | ||
section_header="$line" | ||
section_lines=("$line") # Initialize section with the header | ||
inside_section=true | ||
else | ||
# Collect lines of the current section | ||
section_lines+=("$line") | ||
fi | ||
done < "$INPUT_FILE" | ||
|
||
# Process the last section | ||
if [[ $inside_section == true ]]; then | ||
write_section "$section_header" "${section_lines[@]:1}" # Exclude the header | ||
fi | ||
|
||
echo "Collapsible Markdown written to $OUTPUT_FILE" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
# Paths to files | ||
export INPUT_FILE="$SCRIPT_DIR/test_example.md" | ||
export OUTPUT_FILE="$SCRIPT_DIR/test_example_collapsible.md" | ||
export EXPECTED_FILE="$SCRIPT_DIR/test_example_expected_collapsible.md" | ||
export SCRIPT="$SCRIPT_DIR/auto_collapse.sh" | ||
|
||
# Run the script | ||
bash "$SCRIPT" "$INPUT_FILE" "$OUTPUT_FILE" 5 | ||
|
||
if [ ! -f "$OUTPUT_FILE" ]; then | ||
echo "Test failed: Output file not found." | ||
exit 1 | ||
fi | ||
|
||
# Compare output with expected file | ||
if diff -q "$OUTPUT_FILE" "$EXPECTED_FILE" > /dev/null; then | ||
echo "Test passed: Output matches expected result." | ||
else | ||
echo "Test failed: Output does not match expected result." | ||
echo "Differences:" | ||
diff "$OUTPUT_FILE" "$EXPECTED_FILE" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- Release notes generated using configuration in .github/config/release.yml at refs/heads/releases/v0.19 --> | ||
<!-- markdown-link-check-disable --> | ||
## What's Changed | ||
### 🚀 Features | ||
* feat(log): log http requests for OCI and docker based on trace level by injecting a logger by @author in https://github.com/open-component-model/ocm/pull/1118 | ||
### 🧰 Maintenance | ||
* chore: change guide for 0.18.0 by @author in https://github.com/open-component-model/ocm/pull/1066 | ||
* chore: allow publishing to Brew via custom script by @author in https://github.com/open-component-model/ocm/pull/1059 | ||
* chore: remove ocm inception during build CTF aggregation by @author in https://github.com/open-component-model/ocm/pull/1065 | ||
* chore: release branches as `releases/vX.Y` instead of `releases/vX.Y.Z` by @author in https://github.com/open-component-model/ocm/pull/1071 | ||
* chore: cleanup release action by @author in https://github.com/open-component-model/ocm/pull/1076 | ||
* chore: bump version to 0.19.0-dev by @author in https://github.com/open-component-model/ocm/pull/1084 | ||
* chore: disable mandatory period comments by @author in https://github.com/open-component-model/ocm/pull/1079 | ||
|
||
**Full Changelog**: https://github.com/open-component-model/ocm/compare/v0.18...v0.19.0 | ||
<!-- markdown-link-check-enable --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!-- Release notes generated using configuration in .github/config/release.yml at refs/heads/releases/v0.19 --> | ||
<!-- markdown-link-check-disable --> | ||
## What's Changed | ||
|
||
### 🚀 Features | ||
* feat(log): log http requests for OCI and docker based on trace level by injecting a logger by @author in https://github.com/open-component-model/ocm/pull/1118 | ||
<details> | ||
<summary>🧰 Maintenance</summary> | ||
|
||
* chore: change guide for 0.18.0 by @author in https://github.com/open-component-model/ocm/pull/1066 | ||
* chore: allow publishing to Brew via custom script by @author in https://github.com/open-component-model/ocm/pull/1059 | ||
* chore: remove ocm inception during build CTF aggregation by @author in https://github.com/open-component-model/ocm/pull/1065 | ||
* chore: release branches as `releases/vX.Y` instead of `releases/vX.Y.Z` by @author in https://github.com/open-component-model/ocm/pull/1071 | ||
* chore: cleanup release action by @author in https://github.com/open-component-model/ocm/pull/1076 | ||
* chore: bump version to 0.19.0-dev by @author in https://github.com/open-component-model/ocm/pull/1084 | ||
* chore: disable mandatory period comments by @author in https://github.com/open-component-model/ocm/pull/1079 | ||
|
||
**Full Changelog**: https://github.com/open-component-model/ocm/compare/v0.18...v0.19.0 | ||
</details> | ||
<!-- markdown-link-check-enable --> |