-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: misc core migration cleanup (#419)
* ci: add script to handle dip processing * fix: correct path * chore: add markdown lint config
- Loading branch information
Showing
3 changed files
with
90 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"default": true, | ||
"MD004": { "style": "asterisk"}, | ||
"MD013": false, | ||
"MD033": false, | ||
"MD036": false, | ||
"MD040": true, | ||
"MD041": false, | ||
"MD049": true | ||
} |
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,69 @@ | ||
#!/bin/bash | ||
|
||
# Directory containing the files | ||
dir='_dips' | ||
|
||
echo "Starting to process files in $dir..." | ||
|
||
# Add start of toctree | ||
content=$(cat <<EOL | ||
\`\`\`{toctree} | ||
:maxdepth: 2 | ||
:titlesonly: | ||
:caption: DIPs | ||
:hidden: | ||
EOL | ||
) | ||
|
||
echo "$content" >> "$dir"/README.md | ||
|
||
for filename in "$dir"/*.md; do | ||
if [ $(basename "$filename") = "README.md" ] | ||
then | ||
echo "Skipping README.md" | ||
continue | ||
fi | ||
|
||
echo "Processing $filename..." | ||
|
||
# Extract DIP number | ||
full_dip_num=$(grep '^\s*DIP:' "$filename" | awk -F: '{print $2}' | sed 's/^ *//' | tr -d '\r') | ||
dip="${full_dip_num#"${full_dip_num%%[!0]*}"}" | ||
|
||
# Extract title | ||
title=$(grep '^\s*Title:' "$filename" | awk -F: '{print $2}' | sed 's/^ *//' | tr -d '\r') | ||
|
||
# Combine to make heading | ||
heading="# $dip - $title" | ||
echo "Heading $heading..." | ||
|
||
# Create temp file | ||
tempfile=$(mktemp) | ||
|
||
# Write heading to temp file | ||
echo -e "$heading\n" > "$tempfile" | ||
|
||
# Append original file contents to temp file | ||
cat "$filename" >> "$tempfile" | ||
|
||
# Move temp file to original file | ||
mv "$tempfile" "$filename" | ||
|
||
# Write the filename to the toctree | ||
echo "dip-$full_dip_num" >> "$dir"/README.md | ||
done | ||
|
||
# Close out the toctree | ||
closing_content=$(cat <<EOL | ||
\`\`\` | ||
EOL | ||
) | ||
|
||
echo "$closing_content" >> "$dir"/README.md | ||
|
||
# Output the updated readme | ||
cat "$dir"/README.md | ||
|
||
echo "Finished processing files." |