aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2022-03-28 22:17:04 +0200
committern-peugnet <n.peugnet@free.fr>2022-03-28 22:17:04 +0200
commite4a912b6776a33d3092d70155a8a2a4a09542d7e (patch)
treeb39e9e49757d754b6a2d2302309343ba4832c713 /Makefile
parentf4800a5d80f9d654ebf3e41bb6b7c6f64bbae6bc (diff)
downloadclub1-docs-e4a912b6776a33d3092d70155a8a2a4a09542d7e.tar.gz
club1-docs-e4a912b6776a33d3092d70155a8a2a4a09542d7e.zip
fix: dirty locale files management -> use gettext
mainly get rid of sphinx intl and use genuine gettext utilities. - move back .pot file generation from sphinx to _build - copy .pot files from _build using xgettext (correct width and metadata) - enforce consitent width and metadata order with Weblate using msgmerge - Make now correctly tracks locales files dependencies - update README with new deps and descriptions - remove sphinx intl from deps and github action - Sphinx get basic metadata from ENVVARS set by Make
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile58
1 files changed, 25 insertions, 33 deletions
diff --git a/Makefile b/Makefile
index 204f593..3e2837f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,17 +1,14 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
-ifneq (,$(filter grouped-target,$(.FEATURES)))
-GROUPED_TARGET := 1
-else
-$(warning WARNING: This version of make does not support grouped-target, disabling parallel jobs.)
-.NOTPARALLEL:
-endif
LOCALES := en
-LOCALEFILES := $(LOCALES:%=locales/%/LC_MESSAGES/package.po)
-PONAMES := package sphinx
-POTS := $(PONAMES:%=locales/%.pot)
+LOCALEFILES := $(LOCALES:%=locales/%/LC_MESSAGES/package.po) $(LOCALES:%=locales/%/LC_MESSAGES/sphinx.po)
+
+export COPYRIGHT := Nicolas PEUGNET
+export PACKAGE := CLUB1
+export VERSION := main
+export EMAIL := nicolas@club1.fr
export LANGUAGES := fr $(LOCALES)
export LATEXMKOPTS := -quiet
@@ -22,12 +19,9 @@ SPHINXBUILD ?= sphinx-build
SPHINXBUILDERS := html dirhtml singlehtml epub latex text man texinfo
SPHINXLBUILDERS := $(foreach b,$(SPHINXBUILDERS),$(LANGUAGES:%=$b/%))
SPHINXHBUILDERS := $(SPHINXBUILDERS:%=_%)
-SPHINXCMDS := pickle json htmlhelp changes xml pseudoxml linkcheck doctest coverage
+SPHINXCMDS := gettext pickle json htmlhelp changes xml pseudoxml linkcheck doctest coverage
SOURCEDIR := .
BUILDDIR := _build
-MDFILES := index.md $(shell find . -type f -name '*.md')
-MDFILES := $(shell find . -type f -name '*.md' -not -name 'README.*')
-TEMPLATES := $(shell find _templates -type f -name '*.html')
PUBHOST ?= club1.fr
PUBDIR ?= /var/www/docs
@@ -36,25 +30,26 @@ PUBDIR ?= /var/www/docs
help:
$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $O
-.PHONY: help clean update-po gettext latexpdf info publish $(SPHINXBUILDERS) $(SPHINXLBUILDERS) $(SPHINXHBUILDERS) $(SPHINXCMDS)
+.PHONY: help clean update-po latexpdf info publish $(SPHINXBUILDERS) $(SPHINXLBUILDERS) $(SPHINXHBUILDERS) $(SPHINXCMDS)
-update-po: $(LOCALEFILES)
+update-po: $(LOCALEFILES);
-gettext: $(POTS)
+%.mo: %.po
+ msgfmt -o $@ $<
-$(LOCALEFILES): locales/%/LC_MESSAGES/package.po: $(POTS) .FORCE
- sphinx-intl update -p $(<D) -l $*
+.SECONDEXPANSION:
+$(LOCALEFILES): locales/%.po: locales/$$(*F).pot
+ msgmerge -q --update $@ $< --backup=none -w 77
@touch $@
-ifdef GROUPED_TARGET
-$(POTS)&: $(MDFILES) $(TEMPLATES)
-else
-$(POTS): $(MDFILES) $(TEMPLATES)
-endif
- $(SPHINXBUILD) -b gettext "$(SOURCEDIR)" locales $(SPHINXOPTS) $O
- @touch $(POTS)
+locales/package.pot locales/sphinx.pot: locales/%.pot: $(BUILDDIR)/gettext/%.pot
+ xgettext $< -o $@ -w 77 \
+ --copyright-holder='$(COPYRIGHT)' --package-name='$(PACKAGE)' \
+ --package-version='$(VERSION)' --msgid-bugs-address='$(EMAIL)'
+
+$(BUILDDIR)/gettext/%.pot: gettext;
-latexpdf info: %: $(LANGUAGES:%=\%/%)
+latexpdf info: %: $(LANGUAGES:%=\%/%);
$(LANGUAGES:%=latexpdf/%): latexpdf/%: latex/%
$(MAKE) -C $(BUILDDIR)/$<
@@ -66,15 +61,12 @@ publish:
rsync -av --del --exclude='.*' _build/html/ $(USER)@$(PUBHOST):$(PUBDIR)
# Shinx builders that builds localized versions.
-$(SPHINXBUILDERS): %: $(LANGUAGES:%=\%/%)
+$(SPHINXBUILDERS): %: $(LANGUAGES:%=\%/%);
# Localized Sphinx builders
-$(SPHINXLBUILDERS):
- $(MAKE) _$(@D) LOCALE=$(@F)
-
-# Hidden Sphinx builders that need the LOCALE variable
-$(SPHINXHBUILDERS): _%: $(if $(filter fr,$(LOCALE)),,$(PONAMES:%=locales/$(LOCALE)/LC_MESSAGES/%.po))
- $(SPHINXBUILD) -b $* "$(SOURCEDIR)" "$(BUILDDIR)/$*/$(LOCALE)" -D language=$(LOCALE) $(SPHINXOPTS) $O
+.SECONDEXPANSION:
+$(SPHINXLBUILDERS): $$(if $$(filter fr,$$(@F)),,locales/$$(@F)/LC_MESSAGES/package.mo locales/$$(@F)/LC_MESSAGES/sphinx.mo)
+ $(SPHINXBUILD) -b $(@D) "$(SOURCEDIR)" "$(BUILDDIR)/$(@D)/$(@F)" -D language=$(@F) $(SPHINXOPTS) $O
# Other Sphinx commands for autocompletion
$(SPHINXCMDS):