Skip to content

Commit

Permalink
Automate README.md modules generation
Browse files Browse the repository at this point in the history
  • Loading branch information
cytopia committed Nov 30, 2022
1 parent 60555c3 commit 6e15be1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
26 changes: 24 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,34 @@ test-integration:
.PHONY: gen-readme
gen-readme: check-version-is-set
gen-readme: check-stage-is-set
gen-readme:
gen-readme: _gen-readme-docs
gen-readme: _gen-readme-main

.PHONY: _gen-readme-docs
_gen-readme-docs:
@echo "################################################################################"
@echo "# Generate README.md for PHP $(VERSION) ($(IMAGE):$(DOCKER_TAG)) on $(ARCH)"
@echo "# Generate doc/php-modules.md for PHP $(VERSION) ($(IMAGE):$(DOCKER_TAG)) on $(ARCH)"
@echo "################################################################################"
./bin/gen-readme.sh $(IMAGE) $(ARCH) $(STAGE) $(VERSION) || bash -x ./bin/gen-readme.sh $(IMAGE) $(ARCH) $(STAGE) $(VERSION)
git diff --quiet || { echo "Build Changes"; git diff; git status; false; }
@echo

.PHONY: _gen-readme-main
_gen-readme-main:
@echo "################################################################################"
@echo "# Generate README.md"
@echo "################################################################################"
MODULES="$$( cat doc/php-modules.md \
| grep href \
| sed -e 's|</a.*||g' -e 's|.*">||g' \
| sort -fu \
| xargs -n1 sh -c 'echo "[\`$$1\`](php_modules/$$(echo "$${1}" | tr "[:upper:]" "[:lower:]")/)"' -- )"; \
cat "README.md" \
| perl -0 -pe "s#<!-- modules -->.*<!-- /modules -->#<!-- modules -->\n$${MODULES}\n<!-- /modules -->#s" \
> "README.md.tmp"
yes | mv -f "README.md.tmp" "README.md"
git diff --quiet || { echo "Build Changes"; git diff; git status; false; }
@echo

###
### Generate Modules
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,8 @@ The provided Docker images heavily rely on inheritance to guarantee smallest pos
<h2><img id="php-extensions" width="20" src="https://github.com/devilbox/artwork/raw/master/submissions_logo/cytopia/01/png/logo_64_trans.png"> Available PHP extensions</h2>

> Click below listed extensions for details:
<!--
Generate via:
cat doc/php_modules.md | grep href | sed 's|</a.*||g' | sed 's|.*">||g' | xargs -n1 sh -c 'echo "[\`$1\`](php_modules/$(echo "${1}" | tr "[:upper:]" "[:lower:]")/)"' -- | xclip
-->
<!-- modules -->
[`amqp`](php_modules/amqp/)
[`apc`](php_modules/apc/)
[`apcu`](php_modules/apcu/)
Expand Down Expand Up @@ -180,8 +177,8 @@ cat doc/php_modules.md | grep href | sed 's|</a.*||g' | sed 's|.*">||g' | xargs
[`tokenizer`](php_modules/tokenizer/)
[`uploadprogress`](php_modules/uploadprogress/)
[`uuid`](php_modules/uuid/)
[`wddx`](php_modules/wddx/)
[`vips`](php_modules/vips/)
[`wddx`](php_modules/wddx/)
[`Xdebug`](php_modules/xdebug/)
[`xlswriter`](php_modules/xlswriter/)
[`xml`](php_modules/xml/)
Expand All @@ -192,6 +189,7 @@ cat doc/php_modules.md | grep href | sed 's|</a.*||g' | sed 's|.*">||g' | xargs
[`yaml`](php_modules/yaml/)
[`zip`](php_modules/zip/)
[`zlib`](php_modules/zlib/)
<!-- /modules -->

:information_source: For details see **[Documentation: PHP Modules](doc/php-modules.md)**<br/>
:information_source: For details see **[Contributor Documentation: PHP Modules](php_modules/README.md)**
Expand Down

0 comments on commit 6e15be1

Please sign in to comment.