From 8ca14503b7cecc90a499d13bf3cbcab4fd7e48d7 Mon Sep 17 00:00:00 2001 From: Andrei Belov Date: Thu, 19 Oct 2017 17:48:58 +0300 Subject: Added changelogs generation tools. --- docs/Makefile | 50 ++++++++++ docs/change_log_conf.dtd | 26 +++++ docs/change_log_conf.xml | 56 +++++++++++ docs/changes.dtd | 25 +++++ docs/changes.xml | 21 ++++ docs/changes.xsls | 249 +++++++++++++++++++++++++++++++++++++++++++++++ docs/changes.xslt | 242 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 669 insertions(+) create mode 100644 docs/Makefile create mode 100644 docs/change_log_conf.dtd create mode 100644 docs/change_log_conf.xml create mode 100644 docs/changes.dtd create mode 100644 docs/changes.xml create mode 100644 docs/changes.xsls create mode 100644 docs/changes.xslt (limited to 'docs') diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 00000000..c53ae895 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,50 @@ + +VER= $(shell grep 'define NXT_VERSION' src/nxt_main.h \ + | sed -e 's/^.*"\(.*\)".*/\1/') +UNIT= unit-$(VER) +DEST= ../build +XSLS?= xslscript.pl + +PACKAGES= unit + +all: changes changelogs + +changes: $(DEST)/CHANGES + +changelogs: $(addsuffix .rpm-changelog, $(addprefix $(DEST)/, $(PACKAGES))) \ + $(addsuffix .deb-changelog, $(addprefix $(DEST)/, $(PACKAGES))) + +$(DEST)/CHANGES: changes.dtd \ + changes.xml \ + change_log_conf.xml \ + changes.xslt + + mkdir -p $(DEST) + + xmllint --noout --valid changes.xml + xsltproc --stringparam format generic \ + -o $@ changes.xslt changes.xml + +$(DEST)/%.rpm-changelog: changes.dtd \ + changes.xml \ + change_log_conf.xml \ + changes.xslt + mkdir -p $(DEST) + xmllint --noout --valid changes.xml + xsltproc --stringparam pkgname $* --stringparam format rpm \ + -o $@ changes.xslt changes.xml + +$(DEST)/%.deb-changelog: changes.dtd \ + changes.xml \ + change_log_conf.xml \ + changes.xslt + mkdir -p $(DEST) + xmllint --noout --valid changes.xml + xsltproc --stringparam pkgname $* --stringparam format deb \ + -o $@ changes.xslt changes.xml + +changes.xslt: changes.xsls + $(XSLS) -o $@ $< + +clean: + rm -rf $(DEST) diff --git a/docs/change_log_conf.dtd b/docs/change_log_conf.dtd new file mode 100644 index 00000000..d8e90e35 --- /dev/null +++ b/docs/change_log_conf.dtd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/change_log_conf.xml b/docs/change_log_conf.xml new file mode 100644 index 00000000..1b99da95 --- /dev/null +++ b/docs/change_log_conf.xml @@ -0,0 +1,56 @@ + + + + + + +76 + *) + + + + +76 +- + + + + +76 + * + + + + + Changes with + 65 + + Bugfix + Feature + Change + Security + Workaround + + Jan + Feb + Mar + Apr + May + Jun + Jul + Aug + Sep + Oct + Nov + Dec + + Sun + Mon + Tue + Wed + Thu + Fri + Sat + + + diff --git a/docs/changes.dtd b/docs/changes.dtd new file mode 100644 index 00000000..9a15ed1e --- /dev/null +++ b/docs/changes.dtd @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/docs/changes.xml b/docs/changes.xml new file mode 100644 index 00000000..1607d632 --- /dev/null +++ b/docs/changes.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + +First public release. + + + + + + + diff --git a/docs/changes.xsls b/docs/changes.xsls new file mode 100644 index 00000000..eba762ed --- /dev/null +++ b/docs/changes.xsls @@ -0,0 +1,249 @@ +X:stylesheet { + +X:output method="text"; + +X:param format="'generic'"; +X:param pkgname="'unit'"; +X:param configuration="'change_log_conf.xml'"; + +X:var conf = "document($configuration)/configuration"; + +X:var start = { + X:choose { + X:when "$format='rpm'" { + !{$conf/rpm/start} + } + X:when "$format='deb'" { + !{$conf/deb/start} + } + X:when "$format='generic'" { + !{$conf/generic/start} + } + } +} + +X:var indent = { + X:choose { + X:when "$format='rpm'" { + !{$conf/rpm/indent} + } + X:when "$format='deb'" { + !{$conf/deb/indent} + } + X:when "$format='generic'" { + !{$conf/generic/indent} + } + } +} + +X:var max = { + X:choose { + X:when "$format='rpm'" { + !{$conf/rpm/length} + } + X:when "$format='deb'" { + !{$conf/deb/length} + } + X:when "$format='generic'" { + !{$conf/generic/length} + } + } +} + +X:var br = {<br>} + + +X:template = "/" { !! "change_log"; } +X:template = "change_log" { !! "changes"; } + + +X:template = "changes" { + X:var pday = { !padded_day(date="@date") } + X:var dow = { !day_of_week(date="@date") } + X:var apply = { !string_in_list(list="@apply", string="$pkgname") } + X:var pkgname_ = { !beautify(pkgname="$pkgname") } + + X:if "$apply=$pkgname" { + + X:if "$format='generic'" { + X:text { } + + !{substring(concat($conf/changes/title, + $pkgname_, + ' ', @ver, + ' '), + 1, $conf/changes/length)} + + !{substring(@date, 9, 2)} + !{$conf/changes/month[number(substring(current()/@date, + 6, 2))]} + !{substring(@date, 1, 4)} + } + + X:if "$format='rpm'" { + !{concat('* ', $conf/changes/day[number($dow)], + $conf/changes/month[number(substring(current()/@date, 6, 2))], + $pday, ' ', + substring(@date, 1, 4), ' ', @packager, ' - ', + @ver, '-', @rev, '%{?dist}.ngx')} + } + + X:if "$format='deb'" { + !{concat($pkgname, ' (', @ver, '-', @rev, + '~%%CODENAME%%) %%CODENAME%%; urgency=low')} + + X:text { } + } + + X:text { } + + !! "change"; + + X:text { } + + X:if "$format='deb'" { + !{concat(' -- ', @packager, ' ', + $conf/changes/day[number($dow)], ', ', + $pday, + $conf/changes/month[number(substring(current()/@date, 6, 2))], + substring(@date, 1, 4), ' ', @time)} + + X:text { } + X:text { } + } + } +} + + +X:template = "change" { + X:var prefix = "$conf/changes/*[local-name(.)=current()/@type]" + + X:var postfix = { X:if "$prefix" { X:text {: } } } + + !! "para" (prefix = "concat($start, $prefix, $postfix)"); +} + + +X:template para(prefix) = "para" { + X:var text = { !!; } + + X:if "$format='generic'" { + X:text { } + } + + !wrap(text = "normalize-space($text)", + prefix = { X:if "position() = 1" { !{$prefix} } else { !{$indent} } }) +} + + +X:template wrap(text, prefix) { + X:if "$text" { + X:var offset = { + X:choose { + X:when "starts-with($text, concat($br, ' '))" { + !{string-length($br) + 2} + } + X:when "starts-with($text, $br)" { + !{string-length($br) + 1} + } + X:otherwise { + 1 + } + } + } + + X:var length = { + !length(text = "substring($text, $offset)", + prefix = "string-length($prefix)", + length = "$max") + } + + !{$prefix} + + !{normalize-space(translate(substring($text, $offset, $length), + ' ', ' '))} + + X:text { } + + !wrap(text = "substring($text, $length + $offset)", prefix = "$indent") + } +} + + +X:template length(text, prefix, length) { + X:var break = "substring-before(substring($text, 1, + $length - $prefix + string-length($br)), + $br)" + + X:choose { + X:when "$break" { !{string-length($break)} } + + X:when "$length = 0" { !{$max - $prefix} } + + X:when "string-length($text) + $prefix <= $length" { + !{$length - $prefix} + } + + X:when "substring($text, $length - $prefix + 1, 1) = ' '" { + !{$length - $prefix + 1} + } + + X:otherwise { + !length(text = "$text", prefix = "$prefix", length = "$length - 1") + } + } +} + + +X:template day_of_week(date) { + X:param year = "substring-before($date, '-')"; + X:param month = "substring-before(substring-after($date, '-'), '-')"; + X:param day = "substring-after(substring-after($date, '-'), '-')"; + + X:var a = "floor((14 - $month) div 12)"; + + X:var y = "$year - $a"; + + X:var m = "$month + 12 * $a - 2"; + + !{($day + $y + floor($y div 4) - floor($y div 100) + + floor($y div 400) + floor((31 * $m) div 12)) mod 7 + 1} +} + + +X:template padded_day(date) { + !{substring(concat(' ', format-number(substring($date, 9, 2), '##')), + 1 + string-length(format-number(substring($date, 9, 2), '##')))} +} + + +X:template string_in_list(list, string) { + X:choose { + X:when "contains($list, ',')" { + X:var str = "substring-before($list, ',')"; + !string_in_list(list="substring-after($list, ',')", string="$string") + } + X:otherwise { + X:if "$list=$string" { !{$string} } + X:if "$list='*'" { !{$string} } + } + } +} + + +X:template beautify(pkgname) { + X:choose { + X:when "$pkgname='unit'" {Unit} + X:otherwise { + !{$pkgname} + } + } +} + + +X:template = "at" {@} +X:template = "br" { !{$br} } +X:template = "nobr" { !{translate(., ' ', ' ')} } + + +} diff --git a/docs/changes.xslt b/docs/changes.xslt new file mode 100644 index 00000000..d5a00f4b --- /dev/null +++ b/docs/changes.xslt @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<br> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Unit + + + + + + + +@ + + + + + -- cgit