Skip to content

Commit

Permalink
Make README elements suitable for mkdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
Atick committed Dec 30, 2024
1 parent a9de94b commit a10e427
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/Docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.11'

- name: Format README.md
run: |
chmod +x format_readme.sh
./format_readme.sh
- name: Generate Docs
run: |
pip install mkdocs mkdocs-material Pygments
./gradlew dokkaGfmMultiModule --no-configuration-cache
mv build/dokka/gfmMultiModule docs
cat README.md > docs/index.md
mkdocs gh-deploy
# https://github.com/softprops/action-gh-release/issues/236
Expand Down
25 changes: 25 additions & 0 deletions format_readme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# This script processes a README.md file and converts it to a docs/index.md file.
# It converts GitHub README admonitions to mkdocs admonitions.
# It also updates image paths from 'docs/assets/' to 'assets/'.

while read -r line; do
if [[ $line =~ ^\>.* ]]; then # Detect if line starts with '>'
if [[ $line =~ \[\!TIP\] ]]; then
echo "!!! tip"
elif [[ $line =~ \[\!NOTE\] ]]; then
echo "!!! note"
elif [[ $line =~ \[\!WARNING\] ]]; then
echo "!!! warning"
elif [[ $line =~ \[\!IMPORTANT\] ]]; then
echo "!!! danger"
else
echo " ${line:1}"
fi
else
# Pass through any line not part of a block
echo "${line}" | sed -e 's/docs\/assets\/\([a-zA-Z0-9_\-]\+\.\(png\|jpg\|gif\)\)/assets\/\1/g'
fi

done < README.md > docs/index.md

0 comments on commit a10e427

Please sign in to comment.