# Sane software manifesto helper tools
# Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
VERSION_PARAMS := $(shell hg log -r '.' --template '--stringparam versionTag {latesttag} --stringparam versionDistance {latesttagdistance} --stringparam versionHash {node|short}') "--stringparam" "versionChangedFiles" $(shell hg status | wc -l)
all: validate xhtml txt pdf logo-png statistics
validate:
xmllint --noout --schema schema/ssm.xsd text/ssm.en.xml
xhtml: templates/cmunrm.woff templates/cmunbx.woff
mkdir -p build
xsltproc $(VERSION_PARAMS) --output build/index.xhtml --nonet templates/ssm.xhtml.xsl text/ssm.en.xml
cp templates/*.css build
cp templates/*.woff build
templates/cmunrm.ttf:
cd templates/; ln -s /usr/share/fonts/truetype/cmu/cmunrm.ttf
templates/cmunbx.ttf:
cd templates/; ln -s /usr/share/fonts/truetype/cmu/cmunbx.ttf
templates/cmunrm.woff: templates/cmunrm.ttf
cd templates/; sfnt2woff cmunrm.ttf
templates/cmunbx.woff: templates/cmunbx.ttf
cd templates/; sfnt2woff cmunbx.ttf
pdf:
mkdir -p build
xsltproc $(VERSION_PARAMS) --output build/ssm.en.fodt --nonet templates/ssm.odt.xsl text/ssm.en.xml
libreoffice --convert-to pdf --outdir build build/ssm.en.fodt
# TODO: better line wrapping
txt:
mkdir -p build
xsltproc $(VERSION_PARAMS) --nonet templates/ssm.txt.xsl text/ssm.en.xml | fmt -w 74 -s | sed -E 's/( +)([^- ])/\1 \2/g' > build/ssm.en.txt
logo-png:
mkdir -p build
inkscape --export-filename=build/sane-software-logo-circle.png logo/sane-software-logo-circle.svg
inkscape --export-filename=build/sane-software-logo-rectangle.png logo/sane-software-logo-rectangle.svg
clean:
rm -rf build
publish:
scp build/* globalcode.info:/var/www/sane-software.globalcode.info/v_0/
scp license/* globalcode.info:/var/www/sane-software.globalcode.info/license/
# Described at: https://relational-pipes.globalcode.info/v_0/examples-in-xmltable-ssm-gui.xhtml
build/statistics.rp: text/ssm.en.xml
mkdir -p build
cat text/ssm.en.xml \
| relpipe-in-xmltable \
--namespace "m" "tag:globalcode.info,2019:sane-software/manifesto" \
--relation "chapter" \
--records "//m:chapter" \
--attribute "name" string "m:name" \
--attribute "requirements" integer "count(descendant::m:item[m:type='requirement'])" \
--attribute "recommendations" integer "count(descendant::m:item[m:type='recommendation'])" \
--attribute "informations" integer "count(descendant::m:item[m:type='information'])" \
--attribute "items_total" integer "count(descendant::m:item)" \
> build/statistics.rp
# Prints a table with number of items in particular chapters:
statistics: build/statistics.rp
cat build/statistics.rp | relpipe-out-tabular
statistics-chart: build/statistics.rp
cat build/statistics.rp | relpipe-tr-cut --relation ".*" --attribute "(name|.*s)" | relpipe-out-gui -title "Sane software manifesto – chart of rule types"