diff options
Diffstat (limited to '')
-rw-r--r-- | docs/Makefile | 50 | ||||
-rw-r--r-- | docs/change_log_conf.dtd | 26 | ||||
-rw-r--r-- | docs/change_log_conf.xml | 56 | ||||
-rw-r--r-- | docs/changes.dtd | 25 | ||||
-rw-r--r-- | docs/changes.xml | 21 | ||||
-rw-r--r-- | docs/changes.xsls | 249 | ||||
-rw-r--r-- | docs/changes.xslt | 242 |
7 files changed, 669 insertions, 0 deletions
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 @@ +<!ELEMENT configuration (generic, rpm, deb, changes+) > + +<!ELEMENT generic (length, start, indent?) > +<!ELEMENT rpm (length, start, indent?) > +<!ELEMENT deb (length, start, indent?) > + +<!ELEMENT length (#PCDATA) > +<!ELEMENT start (#PCDATA) > +<!ELEMENT indent (#PCDATA) > + +<!ELEMENT changes (title, length, + bugfix, feature, change, security, workaround, + (month, month, month, month, month, month, + month, month, month, month, month, month), + (day, day, day, day, day, day, day)?) > + +<!ELEMENT title (#PCDATA) > + +<!ELEMENT bugfix (#PCDATA) > +<!ELEMENT feature (#PCDATA) > +<!ELEMENT change (#PCDATA) > +<!ELEMENT security (#PCDATA) > +<!ELEMENT workaround (#PCDATA) > + +<!ELEMENT month (#PCDATA) > +<!ELEMENT day (#PCDATA) > 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 @@ +<?xml version="1.0" ?> +<!DOCTYPE configuration SYSTEM "change_log_conf.dtd" > + +<configuration> + +<generic> +<length>76</length> +<start> *) </start> +<indent> </indent> +</generic> + +<rpm> +<length>76</length> +<start>- </start> +<indent> </indent> +</rpm> + +<deb> +<length>76</length> +<start> * </start> +<indent> </indent> +</deb> + +<changes> + <title>Changes with </title> + <length>65</length> + + <bugfix>Bugfix</bugfix> + <feature>Feature</feature> + <change>Change</change> + <security>Security</security> + <workaround>Workaround</workaround> + + <month> Jan </month> + <month> Feb </month> + <month> Mar </month> + <month> Apr </month> + <month> May </month> + <month> Jun </month> + <month> Jul </month> + <month> Aug </month> + <month> Sep </month> + <month> Oct </month> + <month> Nov </month> + <month> Dec </month> + + <day>Sun</day> + <day>Mon</day> + <day>Tue</day> + <day>Wed</day> + <day>Thu</day> + <day>Fri</day> + <day>Sat</day> +</changes> + +</configuration> 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 @@ + +<!ENTITY nbsp " " > +<!ENTITY mdash " - " > + + +<!ELEMENT change_log (changes)* > +<!ATTLIST change_log title CDATA #REQUIRED > + +<!ELEMENT changes (change)* > +<!ATTLIST changes ver CDATA #REQUIRED + rev CDATA #REQUIRED + date CDATA #REQUIRED + time CDATA #REQUIRED + packager CDATA #REQUIRED + apply CDATA #REQUIRED +> + +<!ELEMENT change (para)* > +<!ATTLIST change type (bugfix | feature | change | security | workaround) #IMPLIED > + +<!ELEMENT para (#PCDATA | at | br | nobr)* > + +<!ELEMENT at EMPTY > +<!ELEMENT br EMPTY > +<!ELEMENT nobr (#PCDATA) > 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 @@ +<?xml version="1.0" ?> +<!DOCTYPE change_log SYSTEM "changes.dtd" > + + +<change_log title="unit"> + + +<changes apply="unit" ver="0.1" rev="1" + date="2017-09-06" time="19:14:28 +0300" + packager="Andrei Belov <defan@nginx.com>"> + +<change> +<para> +First public release. +</para> +</change> + +</changes> + + +</change_log> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + +<xsl:output method="text"/> + +<xsl:param select="'generic'" name="format"/> +<xsl:param select="'unit'" name="pkgname"/> +<xsl:param select="'change_log_conf.xml'" name="configuration"/> + +<xsl:variable select="document($configuration)/configuration" name="conf"/> + +<xsl:variable name="start"> + <xsl:choose> + <xsl:when test="$format='rpm'"> + <xsl:value-of select="$conf/rpm/start"/> + </xsl:when> + <xsl:when test="$format='deb'"> + <xsl:value-of select="$conf/deb/start"/> + </xsl:when> + <xsl:when test="$format='generic'"> + <xsl:value-of select="$conf/generic/start"/> + </xsl:when> + </xsl:choose> +</xsl:variable> + +<xsl:variable name="indent"> + <xsl:choose> + <xsl:when test="$format='rpm'"> + <xsl:value-of select="$conf/rpm/indent"/> + </xsl:when> + <xsl:when test="$format='deb'"> + <xsl:value-of select="$conf/deb/indent"/> + </xsl:when> + <xsl:when test="$format='generic'"> + <xsl:value-of select="$conf/generic/indent"/> + </xsl:when> + </xsl:choose> +</xsl:variable> + +<xsl:variable name="max"> + <xsl:choose> + <xsl:when test="$format='rpm'"> + <xsl:value-of select="$conf/rpm/length"/> + </xsl:when> + <xsl:when test="$format='deb'"> + <xsl:value-of select="$conf/deb/length"/> + </xsl:when> + <xsl:when test="$format='generic'"> + <xsl:value-of select="$conf/generic/length"/> + </xsl:when> + </xsl:choose> +</xsl:variable> + +<xsl:variable name="br"><br></xsl:variable> + + +<xsl:template match="/"> <xsl:apply-templates select="change_log"/> </xsl:template> +<xsl:template match="change_log"> <xsl:apply-templates select="changes"/> </xsl:template> + + +<xsl:template match="changes"> + <xsl:variable name="pday"> <xsl:call-template name="padded_day"><xsl:with-param select="@date" name="date"/></xsl:call-template></xsl:variable> + <xsl:variable name="dow"> <xsl:call-template name="day_of_week"><xsl:with-param select="@date" name="date"/></xsl:call-template></xsl:variable> + <xsl:variable name="apply"> <xsl:call-template name="string_in_list"><xsl:with-param select="@apply" name="list"/><xsl:with-param select="$pkgname" name="string"/></xsl:call-template></xsl:variable> + <xsl:variable name="pkgname_"> <xsl:call-template name="beautify"><xsl:with-param select="$pkgname" name="pkgname"/></xsl:call-template></xsl:variable> + + <xsl:if test="$apply=$pkgname"> + + <xsl:if test="$format='generic'"> + <xsl:text> </xsl:text> + + <xsl:value-of select="substring(concat($conf/changes/title, + $pkgname_, + ' ', @ver, + ' '), + 1, $conf/changes/length)"/> + + <xsl:value-of select="substring(@date, 9, 2)"/> + <xsl:value-of select="$conf/changes/month[number(substring(current()/@date, + 6, 2))]"/> + <xsl:value-of select="substring(@date, 1, 4)"/> + </xsl:if> + + <xsl:if test="$format='rpm'"> + <xsl:value-of select="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')"/> + </xsl:if> + + <xsl:if test="$format='deb'"> + <xsl:value-of select="concat($pkgname, ' (', @ver, '-', @rev, + '~%%CODENAME%%) %%CODENAME%%; urgency=low')"/> + + <xsl:text> </xsl:text> + </xsl:if> + + <xsl:text> </xsl:text> + + <xsl:apply-templates select="change"/> + + <xsl:text> </xsl:text> + + <xsl:if test="$format='deb'"> + <xsl:value-of select="concat(' -- ', @packager, ' ', + $conf/changes/day[number($dow)], ', ', + $pday, + $conf/changes/month[number(substring(current()/@date, 6, 2))], + substring(@date, 1, 4), ' ', @time)"/> + + <xsl:text> </xsl:text> + <xsl:text> </xsl:text> + </xsl:if> + </xsl:if> +</xsl:template> + + +<xsl:template match="change"> + <xsl:variable select="$conf/changes/*[local-name(.)=current()/@type]" name="prefix"/> + + <xsl:variable name="postfix"> <xsl:if test="$prefix"> <xsl:text>: </xsl:text> </xsl:if> </xsl:variable> + + <xsl:apply-templates select="para"><xsl:with-param select="concat($start, $prefix, $postfix)" name="prefix"/></xsl:apply-templates> +</xsl:template> + + +<xsl:template name="para" match="para"><xsl:param name="prefix"/> + <xsl:variable name="text"> <xsl:apply-templates/> </xsl:variable> + + <xsl:if test="$format='generic'"> + <xsl:text> </xsl:text> + </xsl:if> + + <xsl:call-template name="wrap"><xsl:with-param select="normalize-space($text)" name="text"/><xsl:with-param name="prefix"> <xsl:choose><xsl:when test="position() = 1"> <xsl:value-of select="$prefix"/> </xsl:when><xsl:otherwise> <xsl:value-of select="$indent"/> </xsl:otherwise></xsl:choose> </xsl:with-param></xsl:call-template></xsl:template> + + +<xsl:template name="wrap"><xsl:param name="text"/><xsl:param name="prefix"/> + <xsl:if test="$text"> + <xsl:variable name="offset"> + <xsl:choose> + <xsl:when test="starts-with($text, concat($br, ' '))"> + <xsl:value-of select="string-length($br) + 2"/> + </xsl:when> + <xsl:when test="starts-with($text, $br)"> + <xsl:value-of select="string-length($br) + 1"/> + </xsl:when> + <xsl:otherwise> + 1 + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:variable name="length"> + <xsl:call-template name="length"><xsl:with-param select="substring($text, $offset)" name="text"/><xsl:with-param select="string-length($prefix)" name="prefix"/><xsl:with-param select="$max" name="length"/></xsl:call-template></xsl:variable> + + <xsl:value-of select="$prefix"/> + + <xsl:value-of select="normalize-space(translate(substring($text, $offset, $length), + ' ', ' '))"/> + + <xsl:text> </xsl:text> + + <xsl:call-template name="wrap"><xsl:with-param select="substring($text, $length + $offset)" name="text"/><xsl:with-param select="$indent" name="prefix"/></xsl:call-template></xsl:if> +</xsl:template> + + +<xsl:template name="length"><xsl:param name="text"/><xsl:param name="prefix"/><xsl:param name="length"/> + <xsl:variable select="substring-before(substring($text, 1, + $length - $prefix + string-length($br)), + $br)" name="break"/> + + <xsl:choose> + <xsl:when test="$break"> <xsl:value-of select="string-length($break)"/> </xsl:when> + + <xsl:when test="$length = 0"> <xsl:value-of select="$max - $prefix"/> </xsl:when> + + <xsl:when test="string-length($text) + $prefix <= $length"> + <xsl:value-of select="$length - $prefix"/> + </xsl:when> + + <xsl:when test="substring($text, $length - $prefix + 1, 1) = ' '"> + <xsl:value-of select="$length - $prefix + 1"/> + </xsl:when> + + <xsl:otherwise> + <xsl:call-template name="length"><xsl:with-param select="$text" name="text"/><xsl:with-param select="$prefix" name="prefix"/><xsl:with-param select="$length - 1" name="length"/></xsl:call-template></xsl:otherwise> + </xsl:choose> +</xsl:template> + + +<xsl:template name="day_of_week"><xsl:param name="date"/> + <xsl:param select="substring-before($date, '-')" name="year"/> + <xsl:param select="substring-before(substring-after($date, '-'), '-')" name="month"/> + <xsl:param select="substring-after(substring-after($date, '-'), '-')" name="day"/> + + <xsl:variable select="floor((14 - $month) div 12)" name="a"/> + + <xsl:variable select="$year - $a" name="y"/> + + <xsl:variable select="$month + 12 * $a - 2" name="m"/> + + <xsl:value-of select="($day + $y + floor($y div 4) - floor($y div 100) + + floor($y div 400) + floor((31 * $m) div 12)) mod 7 + 1"/> +</xsl:template> + + +<xsl:template name="padded_day"><xsl:param name="date"/> + <xsl:value-of select="substring(concat(' ', format-number(substring($date, 9, 2), '##')), + 1 + string-length(format-number(substring($date, 9, 2), '##')))"/> +</xsl:template> + + +<xsl:template name="string_in_list"><xsl:param name="list"/><xsl:param name="string"/> + <xsl:choose> + <xsl:when test="contains($list, ',')"> + <xsl:variable select="substring-before($list, ',')" name="str"/> + <xsl:call-template name="string_in_list"><xsl:with-param select="substring-after($list, ',')" name="list"/><xsl:with-param select="$string" name="string"/></xsl:call-template></xsl:when> + <xsl:otherwise> + <xsl:if test="$list=$string"> <xsl:value-of select="$string"/> </xsl:if> + <xsl:if test="$list='*'"> <xsl:value-of select="$string"/> </xsl:if> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + + +<xsl:template name="beautify"><xsl:param name="pkgname"/> + <xsl:choose> + <xsl:when test="$pkgname='unit'">Unit</xsl:when> + <xsl:otherwise> + <xsl:value-of select="$pkgname"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + + +<xsl:template match="at">@</xsl:template> +<xsl:template match="br"> <xsl:value-of select="$br"/> </xsl:template> +<xsl:template match="nobr"> <xsl:value-of select="translate(., ' ', ' ')"/> </xsl:template> + + +</xsl:stylesheet> |