Skip to content

Commit aa32e26

Browse files
authored
Merge pull request #2 from multi-py/toc
Generate a TOC for the readme
2 parents 3005a76 + f18ce58 commit aa32e26

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/scripts/gh-md-toc
2+
test_readme.md

action.yml

+6
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ runs:
8888
shell: bash
8989
run: "python -m pip install jinja2 pyyaml"
9090

91+
- name: "Install github-markdown-toc"
92+
shell: bash
93+
run: |
94+
curl https://raw.githubusercontent.com/ekalinin/github-markdown-toc/master/gh-md-toc -o ${{ github.action_path }}/scripts/gh-md-toc
95+
chmod a+x ${{ github.action_path }}/scripts/gh-md-toc
96+
9197
- name: "Update README.md"
9298
shell: bash
9399
run: "bash ${{ github.action_path }}/scripts/update_readme.sh \"${{ inputs.readme_path }}\""

scripts/update_readme.sh

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
set -e
4+
35
if [[ $SKIP_README == "true" ]]; then
46
echo "Generation of README.md is disabled."
57
exit 0
@@ -19,3 +21,8 @@ else
1921
fi
2022

2123
python $SCRIPT_DIR/../readme_builder.py > $1
24+
25+
# If TOC tag is in the readme generate and add the TOC.
26+
if grep -q "<\!\-\-ts\-\->" "$1"; then
27+
$SCRIPT_DIR/gh-md-toc --insert --no-backup --hide-footer $1
28+
fi

templates/README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{% set short_repository = repository.split("/")[1] -%}
22
# {{ short_repository }}
33

4-
54
{{ description }}
65

6+
<!--ts-->
7+
<!--te-->
8+
79
## Benefits
810

911
### Multi Architecture Builds
@@ -38,6 +40,8 @@ Containers are rebuilt weekly in order to take on the security patches from upst
3840

3941
{{ quick_start }}
4042

43+
{{ documentation }}
44+
4145
## Python Versions
4246

4347
This project actively supports these Python versions:
@@ -81,4 +85,3 @@ Every tag in this repository supports these architectures:
8185

8286
{{ tags }}
8387

84-
{{ documentation }}

test.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ export PACKAGE_VERSIONS="0.13.3 0.13.4 0.14.0 0.15.0"
77
export PYTHON_VERSIONS="3.6 3.7 3.8 3.9 3.10"
88
export ORGANIZATION="TestOrganization"
99
export REPOSITORY="TestOrganization/TestRepository"
10+
export REPOSITORY_SHORT="TestRepository"
1011

11-
./scripts/update_readme.sh -
12+
./scripts/update_readme.sh ./test_readme.md

0 commit comments

Comments
 (0)