8000 Initial implementation of Makefile for docs based on PMM Makefile by nastena1606 · Pull Request #338 · percona/postgres · GitHub
[go: up one dir, main page]

Skip to content

Initial implementation of Makefile for docs based on PMM Makefile #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: TDE_REL_17_STABLE
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions contrib/pg_tde/documentation/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Documentation Makefile.

DOCDIR := documentation

ifeq ($(shell basename $(CURDIR)),$(DOCDIR))
DIR := $(CURDIR)
else
DIR := $(CURDIR)/$(DOCDIR)
endif

doc-check-images: ## Check if all images are used in documentation
@$(DIR)/_resources/bin/check-images.sh

doc-remove-images: ## Remove unused images from documentation
@ACTION=remove $(DIR)/_resources/bin/check-images.sh

doc-build: ## Build documentation (used in CI)
# This command is used to build and deploy a preview to onrender.com
# Preview URL: https://pmm-doc.onrender.com

mkdocs build -f $(DIR)/mkdocs.yml

doc-build-pdf: ## Build documentation in PDF format
docker run --rm --platform=linux/amd64 -v $(DIR):/docs -w /build perconalab/pmm-doc-md:latest \
bash -c " \
cp -r /docs/* /build/ && \
git init && \
git config user.email 'doc-team@percona.com' && \
git add --all && \
git commit -am 'Initial commit' > /dev/null && \
ENABLE_PDF_EXPORT=1 mkdocs build -f mkdocs-pdf.yml && \
cp /build/site/pdf/*.pdf /docs/ \
"

doc-build-image: ## Build perconalab/pmm-doc-md:latest image
# @docker buildx build --platform=linux/amd64 --progress=plain -t perconalab/pmm-doc-md:latest -f documentation/resources/Dockerfile.build .

doc-build-preview: ## Build documentation and preview at http://localhost:8000
docker run --rm -v $(DIR):/docs -e ENABLE_PDF_EXPORT=1 perconalab/pmm-doc-md:latest mkdocs serve -a 127.0.0.1:8001

doc-search-icons: ## Search for icons that can be used in documentation
@open https://squidfunk.github.io/mkdocs-material/reference/icons-emojis/#search
31 changes: 31 additions & 0 deletions contrib/pg_tde/documentation/_resource/bin/check-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -o errexit nounset

declare -r doc_dir=$(git rev-parse --show-toplevel)/documentation
declare -r img_dir="${doc_dir}/docs/images"
declare -r exceptions="^PMM.png"
declare -r action="${ACTION:-}"
declare file=""

if [ "$action" != "remove" ]; then
echo "Checking for unused images in documentation..."
echo
else
echo "Removing unused images from documentation..."
echo
fi

for file in $(ls -1 "${img_dir}"); do
if ! grep -r --include "*.md" --include "mkdocs*.yml" -m 1 -q $file "${doc_dir}"; then
if [[ "$file" =~ ${exceptions} ]]; then
continue
fi
if [ "$action" = "remove" ]; then
echo "Removing ${img_dir}/${file} ..."
rm -f "${img_dir}/${file}"
else
echo "${img_dir}/${file}"
fi
fi
done
0