From 3b1107a34f2f2db787157f11ab68d7b468f603ec Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Sat, 11 May 2024 17:56:58 +0200 Subject: Override model styles with local styles automaticaly --- .gitignore | 3 +++ Makefile | 2 +- common/Makefile.common | 31 +++++++++++++++++++++++++------ readme.rst | 6 +++++- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index b784400..67b0c89 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ *.pdf *.swp +*/example.png +*/tmp +readme.html diff --git a/Makefile b/Makefile index f1523c7..c0fab78 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ SUBDIRS := $(wildcard model*/. example*/.) all: $(SUBDIRS) $(SUBDIRS): - $(MAKE) -C $@ + $(MAKE) -j -C $@ pngs: $(SUBDIRS) for dir in $(SUBDIRS); do \ diff --git a/common/Makefile.common b/common/Makefile.common index 311db70..730a994 100644 --- a/common/Makefile.common +++ b/common/Makefile.common @@ -13,11 +13,31 @@ all: $(PDFS) BIBS =$(wildcard *.bib) DIR = $(sort $(shell find $(SOURCE) -name '*.rst' -print)) -SOURCES = $(sort $(filter-out $(FILTERS), $(wildcard $(MODEL)/resources/*.tex) )) -# Sources comming from extra styles. -# Used in the target regeneration. -EXT_SOURCES = $(filter %.tex, $(EXTRA_STYLES) ) +# Pick the first file for the given name, either in the path from the model, or +# in the local path from the source. +select_file = \ + $(firstword $(wildcard ./resources/$(1)) $(wildcard $(MODEL)/resources/$1)) + + +# Select the files to use in the styles. +ifeq ($(MODEL),.) + $(info Modèle de base) + + SOURCES = $(sort $(filter-out $(FILTERS), $(wildcard $(MODEL)/resources/*.tex) )) + +else + $(info Modèle surchargé) + + # Remove from the list the elements given in the variable FILTERS + NEW_STYLES = $(wildcard resources/*.tex) + MODEL_STYLES = $(wildcard $(MODEL)/resources/*.tex) + # For each file, extract the name, and sort the list by order. + STYLE_NAME = $(sort $(foreach fic,$(NEW_STYLES) $(filter-out $(FILTERS),$(MODEL_STYLES)),$(notdir $(fic)))) + # Pick the file either in the current directory, or in the model path + SOURCES = $(foreach fic,$(STYLE_NAME),$(call select_file,$(fic))) + +endif null := space := $(null) # @@ -31,7 +51,6 @@ EXTRA_RST_OPTIONS ?= EXTRA_STYLES ?= - # Remove the comments and the empty lines from the module list file PACK = $(shell sed -e 's/\#.*$$//' -e '/^\s$$/d' $(MODEL)/resources/modules) PACKAGES = $(subst $(space),$(comma),$(strip $(PACK))) @@ -44,7 +63,7 @@ tmp/model.tex: | tmp $(file >$@,\def\commonPath{$(MODEL)/../common/}) # Generate the latex file from rst -tmp/%.tex: %.rst $(INCLUDED_PDF) $(SOURCES) $(EXT_SOURCES) | tmp +tmp/%.tex: %.rst $(INCLUDED_PDF) $(SOURCES) | tmp $$(command -v rst2latex rst2latex.py | head -n 1) \ --no-section-subtitles \ --table-style=borderless \ diff --git a/readme.rst b/readme.rst index 44f98e0..d07a07e 100755 --- a/readme.rst +++ b/readme.rst @@ -40,7 +40,11 @@ Pour réutiliser un modèle, il suffit de créer ces lignes dans un fichier Personalisation --------------- -Les règles de basent peuvent être personalisée en fonction des besoins. +Les règles de basent peuvent être personalisées en fonction des besoins. + +Chaque fichier de style présent dans le répertoire du modèle peut être +surchargé par un fichier de style de même nom présent dans le répertoire +courant du modèle. :`EXTRA_RST_OPTIONS`: -- cgit v1.2.3