diff --git a/.gitignore b/.gitignore index eb76620..fd9d757 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,8 @@ geekodoc/rng/docbookxi.rng geekodoc/rng/*.srng geekodoc/rng/catalog.dtd geekodoc/rng/geekodoc5*.rng -geekodoc/tests/*.err +geekodoc/tests/*/*.err +geekodoc/tests/last-test-run-errors build/ autom4te.cache/ diff --git a/ChangeLog b/ChangeLog index f42b4a4..bcea0fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +------------------------------------------------------------------ +Fri Jan 09 13:23:00 UTC 2018 - toms@opensuse.org + +Bugfix release 1.0.2.1 + +* Correct version in GeekoDoc schema +* Add missing 'fig' value (#43) +* Improve test suite + + +------------------------------------------------------------------ +Tue Oct 06 00:00:00 UTC 2018 - toms@opensuse.org + +Release 1.0.2 + +* Only a package release without any changes in the schemas. +* Fixes issue #41 to reduce number of files in packages + + ------------------------------------------------------------------ Thu Oct 26 00:00:00 UTC 2018 - toms@opensuse.org diff --git a/geekodoc/rng/ChangeLog b/geekodoc/rng/ChangeLog deleted file mode 100644 index da0fa93..0000000 --- a/geekodoc/rng/ChangeLog +++ /dev/null @@ -1,154 +0,0 @@ -------------------------------------------------------------------- -Mon Jan 29 16:32:00 UTC 2018 - toms@opensuse.org - -Created 1.0.1 -https://github.com/openSUSE/geekodoc/releases/tag/v1.0.1 - -* Geekodoc - * Forbid xml:id on row and entry (#37) - * Allow affiliation inside author (#36) - * Forbid xml:id on remark (#32) - * Inconsistency between informalfigure and informaltable (#35) - * Allow sections (#34) - -* Novdoc - no changes - -------------------------------------------------------------------- -Thu Oct 26 11:20:00 UTC 2017 - toms@opensuse.org - -Created 1.0.0 -https://github.com/openSUSE/geekodoc/releases/tag/v1.0.0 - -* Geekodoc - * Missing mediaobject in cover (#30) - -* Novdoc - no changes - - -------------------------------------------------------------------- -Fri Oct 13 09:52:00 UTC 2017 - toms@opensuse.org - -Created 0.9.9 -https://github.com/openSUSE/geekodoc/releases/tag/v0.9.9 - -* Geekodoc - * Allow Lowercase Values in format Attribute (#29) - * Add list elements in taskprerequisites (#25) - -* Novdoc - * No changes - - -------------------------------------------------------------------- -Fri Sep 15 09:49:37 UTC 2017 - toms@opensuse.org - -Created 0.9.8 -https://github.com/openSUSE/geekodoc/releases/tag/v0.9.8 - -* GeekoDoc - * Restrict Possible Values in format Attribute (#24) - * Fix outdated Schematron rules (#22) - * Implement task elements (#20) - * Adapt content model of task* elements (#1) - * Add test cases and use Travis to check schema - -* Novdoc - * No changes - - -------------------------------------------------------------------- -Thu Dec 1 09:56:45 UTC 2016 - toms@opensuse.org - -Created 0.9.7 -https://github.com/openSUSE/geekodoc/releases/tag/v0.9.7 - - -* GeekoDoc - * link without "xlink:href" attribute is currently valid (#15) - -* Novdoc - * Content model of step is not determinist (#17) - - -------------------------------------------------------------------- -Thu Nov 24 15:56:33 UTC 2016 - toms@opensuse.org - -Created 0.9.6 -https://github.com/openSUSE/geekodoc/releases/tag/v0.9.6 - -* GeekoDoc - * Remove title in step (#4) - * Empty does not trigger a warning (#9) - * Allow common attributes in link (#10) - * Disallow xreflabel (#11) - * Restrict element (#14) - -* Novdoc - * Missing novdocx-core.rnc (#5) - * Allow only in
and - * (#7) - * Fix content model for step to allow para, substeps, - * para (#12) - * Allow phrase inside productnumber (#13) - * Both - * Update Novdoc/GeekoDoc to disallow screen in entry (#2) - - -------------------------------------------------------------------- -Fri Aug 19 14:07:55 UTC 2016 - toms@opensuse.org - -Created v0.9.5 - -* First release on OBS, Documentation:Tools -* Use catalog.d directory for GeekoDoc and Novdoc catalog files - - -------------------------------------------------------------------- -Wed Jul 6 13:21:00 UTC 2010 - toms@opensuse.org - -Created 0.9.4 - -* Fixes several problems - * allow informaltable in db.step.blocks - * allow bridgeheads - * remove db.admonition.contentmodel (using standard admon - contentmodel) - * remove info inside steps (db.step.info) - - -------------------------------------------------------------------- -Tue Jul 5 13:31:00 UTC 2010 - toms@opensuse.org - -Created 0.9.3 - -* Fixes #4 to remove title in step -* Rename SUSEDoc -> GeekoDoc - - -------------------------------------------------------------------- -Tue May 12 16:06:38 UTC 2010 - toms@opensuse.org - -Created 0.9.2 - -* Allow footnote again (for Meike!) -* Change content model for admonitions: allow only db.para - db.simplelist, db.itemizedlist, db.variablelist, - db.orderedlist, db.verbatim.blocks, db.remark (together - with db._info.title.only) - - -------------------------------------------------------------------- -Tue May 12 16:06:38 UTC 2010 - toms@opensuse.org - -Created 0.9.1 - -* Adapt version attribute to "5.1-subset SUSEDoc-0.9.1" -* Remove bridgehead and revhistory in db.nopara.blocks -* Remove blockquote, bridgehead, and msgset -* Correct step - * Introduce db.step.blocks pattern - * Redefine db.step to use db.step.blocks pattern - * Remove db.procedure, db.segmentedlist, db.glosslist, - db.bibliolist, and db.qandaset diff --git a/geekodoc/rng/geekodoc5-flat.rnc b/geekodoc/rng/geekodoc5-flat.rnc index 430d9d7..147092e 100644 --- a/geekodoc/rng/geekodoc5-flat.rnc +++ b/geekodoc/rng/geekodoc5-flat.rnc @@ -18,7 +18,7 @@ namespace xlink = "http://www.w3.org/1999/xlink" s:ns [ uri = "http://docbook.org/ns/docbook" prefix = "db" ] s:ns [ uri = "http://www.w3.org/1999/xlink" prefix = "xlink" ] # Constants -suse.schema.version = "5.1-subset GeekoDoc-1.0.1" +suse.schema.version = "5.1-subset GeekoDoc-1.0.2.1" # div { div { @@ -171,6 +171,9 @@ div { | ## Format of the xfig tool "FIG" + | + ## Format of the xfig tool + "fig" | ## LibreOffice illustration format "ODG" diff --git a/geekodoc/rng/geekodoc5.rnc b/geekodoc/rng/geekodoc5.rnc index 00c5447..d675b5f 100644 --- a/geekodoc/rng/geekodoc5.rnc +++ b/geekodoc/rng/geekodoc5.rnc @@ -5,7 +5,7 @@ # # This schema is a customization of DocBook for SUSE documents # -# Author: Thomas Schraitle, 2015-2017 +# Author: Thomas Schraitle, 2015-2018 # default namespace db = "http://docbook.org/ns/docbook" datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes" @@ -31,7 +31,7 @@ s:ns [ uri = "http://docbook.org/ns/docbook" prefix = "db" ] s:ns [ uri = "http://www.w3.org/1999/xlink" prefix = "xlink" ] # Constants -suse.schema.version = "5.1-subset GeekoDoc-1.0.1" +suse.schema.version = "5.1-subset GeekoDoc-1.0.2.1" # @@ -133,6 +133,8 @@ div { "eps" | ## Format of the xfig tool "FIG" | + ## Format of the xfig tool + "fig" | ## LibreOffice illustration format "ODG" | ## LibreOffice illustration format diff --git a/geekodoc/tests/bad/article-format-on-informalfigure.xml b/geekodoc/tests/bad/article-format-on-informalfigure.xml new file mode 100644 index 0000000..9858119 --- /dev/null +++ b/geekodoc/tests/bad/article-format-on-informalfigure.xml @@ -0,0 +1,15 @@ + + +
+ Test xml:id on an informalfigure + + + + + + + + + + +
diff --git a/geekodoc/tests/bad/article-id-on-informalfigure.xml b/geekodoc/tests/bad/article-id-on-informalfigure.xml new file mode 100644 index 0000000..e3a3fdf --- /dev/null +++ b/geekodoc/tests/bad/article-id-on-informalfigure.xml @@ -0,0 +1,12 @@ + + +
+ Test xml:id on an informalfigure + + + + + + + +
diff --git a/geekodoc/tests/bad/article-id-on-informaltable.xml b/geekodoc/tests/bad/article-id-on-informaltable.xml new file mode 100644 index 0000000..3081b6d --- /dev/null +++ b/geekodoc/tests/bad/article-id-on-informaltable.xml @@ -0,0 +1,15 @@ + + +
+ Test xml:id on an informaltable + + + + + A + B + + + + +
diff --git a/geekodoc/tests/bad/article-id-on-remark.xml b/geekodoc/tests/bad/article-id-on-remark.xml new file mode 100644 index 0000000..1e61b8f --- /dev/null +++ b/geekodoc/tests/bad/article-id-on-remark.xml @@ -0,0 +1,6 @@ + + +
+ Test Article + The quick brown fox jumps over the lazy dog. +
diff --git a/geekodoc/tests/bad/article-id-on-rows.xml b/geekodoc/tests/bad/article-id-on-rows.xml new file mode 100644 index 0000000..9551e9c --- /dev/null +++ b/geekodoc/tests/bad/article-id-on-rows.xml @@ -0,0 +1,16 @@ + + +
+ Test xml:id on rows + + A Title with an xml:id on a row + + + + A + B + + + +
+
diff --git a/geekodoc/tests/bad/article-task.xml b/geekodoc/tests/bad/article-task.xml new file mode 100644 index 0000000..e7a0960 --- /dev/null +++ b/geekodoc/tests/bad/article-task.xml @@ -0,0 +1,39 @@ + + +
+ An Article with a Task + + Changing a light bulb + + How to change a light bulb + + + + + + + + + + + + Make sure you have a new light bulb. + + + Make sure you have turned off the light switch. + + + + + Remove the old light bulb. + Insert the new light bulb. + Turn on the new light bulb. + Recycle the old light bulb. + + + See section how to buy a + light bulb for further information. + + +
diff --git a/geekodoc/tests/article-admons.xml b/geekodoc/tests/good/article-admons.xml similarity index 100% rename from geekodoc/tests/article-admons.xml rename to geekodoc/tests/good/article-admons.xml diff --git a/geekodoc/tests/good/article-authorgroup.xml b/geekodoc/tests/good/article-authorgroup.xml new file mode 100644 index 0000000..f64a8f2 --- /dev/null +++ b/geekodoc/tests/good/article-authorgroup.xml @@ -0,0 +1,31 @@ + + +
+ + Test: authorgroup + + + + Tux + Penguin + + tux@example.org + + + + + Bla + + + + + + + + + +
+
diff --git a/geekodoc/tests/article-base.xml b/geekodoc/tests/good/article-base.xml similarity index 100% rename from geekodoc/tests/article-base.xml rename to geekodoc/tests/good/article-base.xml diff --git a/geekodoc/tests/article-cover.xml b/geekodoc/tests/good/article-cover.xml similarity index 100% rename from geekodoc/tests/article-cover.xml rename to geekodoc/tests/good/article-cover.xml diff --git a/geekodoc/tests/good/article-format-on-informalfigure.xml b/geekodoc/tests/good/article-format-on-informalfigure.xml new file mode 100644 index 0000000..306b9c5 --- /dev/null +++ b/geekodoc/tests/good/article-format-on-informalfigure.xml @@ -0,0 +1,63 @@ + + +
+ Test xml:id on an informalfigure + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/geekodoc/tests/article-images.xml b/geekodoc/tests/good/article-images.xml similarity index 100% rename from geekodoc/tests/article-images.xml rename to geekodoc/tests/good/article-images.xml diff --git a/geekodoc/tests/article-lists.xml b/geekodoc/tests/good/article-lists.xml similarity index 100% rename from geekodoc/tests/article-lists.xml rename to geekodoc/tests/good/article-lists.xml diff --git a/geekodoc/tests/article-task.xml b/geekodoc/tests/good/article-task.xml similarity index 100% rename from geekodoc/tests/article-task.xml rename to geekodoc/tests/good/article-task.xml diff --git a/geekodoc/tests/book.storage.admin.xml b/geekodoc/tests/good/book.storage.admin.xml similarity index 100% rename from geekodoc/tests/book.storage.admin.xml rename to geekodoc/tests/good/book.storage.admin.xml diff --git a/geekodoc/tests/book.suma-cloud.xml b/geekodoc/tests/good/book.suma-cloud.xml similarity index 100% rename from geekodoc/tests/book.suma-cloud.xml rename to geekodoc/tests/good/book.suma-cloud.xml diff --git a/geekodoc/tests/book.suma.reference.xml b/geekodoc/tests/good/book.suma.reference.xml similarity index 100% rename from geekodoc/tests/book.suma.reference.xml rename to geekodoc/tests/good/book.suma.reference.xml diff --git a/geekodoc/tests/run-tests.sh b/geekodoc/tests/run-tests.sh index 88bf143..87b4fff 100755 --- a/geekodoc/tests/run-tests.sh +++ b/geekodoc/tests/run-tests.sh @@ -1,9 +1,14 @@ -#!/bin/bash +#!/bin/bash -i # # Run test cases # +# The test cases are separated into "good" and "bad": +# +# * good are tests which MUST SUCCEED, otherwise it is an error +# * bad are tests which MUST FAIL, otherwise it is an error +# # Author: Thomas Schraitle -# Date: December 2016 +# Date: 2016-2018 VALIDATOR="xmllint" PROG=${0##*/} @@ -12,35 +17,55 @@ PROGDIR=${0%/*} SCHEMA=${PROGDIR}/../rng/geekodoc5-flat.rng SCHEMA=$(readlink -f ${SCHEMA}) ERRORS=0 +ERRORFILE=${PROGDIR}/last-test-run-errors + +SUCCESS=0 +FAILURE=1 + +MAKE=1 + +TEST_CATEGORY=all -function validate_with_jing { - local _RNG=$1 - local _XML=$2 - local _ERROR=${2%*.xml}.err - jing $_RNG $_XML >$_ERROR - echo $? +export LANG=C + +function logerror() { + local fatal=0 + if [[ $1 == '--fatal' ]]; then + fatal=1 + shift + fi + echo -e "\e[1;31mERROR: $1\e[0m" + [[ $fatal -ne 0 ]] && exit 1 } -function validate_with_xmllint { - local _RNG=$1 - local _XML=$2 - local _ERROR=${2%*.xml}.err - xmllint --noout --relaxng $_RNG $_XML 2>$_ERROR - echo $? +function loginfo() { + local extraoptions= + if [[ $1 == '-n' ]]; then + extraoptions='-n' + shift + fi + echo -e $extraoptions "\e[1;39mINFO: $1\e[0m" } -function validator { +function logwarn() { + echo -e "\e[1;95mWARN: $1\e[0m" +} + +function validator() { case "$VALIDATOR" in "xmllint") - validate_with_xmllint "$1" "$2" + # sed '$ d' removes the last line in which xmllint just prints the + # validation status (which we don't want cluttering our output). + xmllint --noout --relaxng "$1" "$2" 2>&1 | sed '$ d' ;; "jing") - validate_with_jing "$1" "$2" + jing "$1" "$2" ;; *) - echo "Wrong validator: $VALIDATOR" 1>&2 + echo "Unrecognized validator: $VALIDATOR" 1>&2 ;; esac + return 1 } function print_help { @@ -54,15 +79,73 @@ Options: -h, --help Shows this help message -V VALIDATOR, --validator VALIDATOR Choose to validate either with "jing" or "xmllint" + -t, --test Choose the test category: + * 'bad' check only tests which are expected to fail + * 'good' check only tests which are expected to succeed + * 'all' chooses both (default) + -n, --noremake Do not run make on the geekodoc/rng/ directory + (useful for running this in the RPM %check section) EOF_helptext } -VALIDATOR_FUNC=validate_with_xmllint +function test_check() +{ + local TEST=$1 + local RESULT=$2 + local RESULTSTR= + + RESULTSTR="\e[1;32mPASSED\e[0m" + case "$1" in + good) + if [[ ! "$RESULT" == '' ]]; then + RESULTSTR="\e[1;31mFAILED\e[0m" + ERRORS=$(($ERRORS + 1)) + fi + ;; + bad) + if [[ "$RESULT" == '' ]]; then + RESULTSTR="\e[1;31mFAILED\e[0m" + ERRORS=$(($ERRORS + 1)) + fi + ;; + *) + ;; + esac + echo -e $RESULTSTR +} + +function test_files() { + local DIR=$1 + local CHECK=$2 + local GOOD_OR_BAD=${DIR##*/} + local result + local resultstr + local re='^[0-9]+$' + + for xmlfile in $DIR/*.xml; do + loginfo -n "Validating '$xmlfile'... " + wellformedness=$(xmllint --noout --noent $xmlfile 2>&1) + if [[ ! $wellformedness == '' ]]; then + # In this case, we always want to say "FAILED", so this usage is correct. + # (But we are abusing the existing test_check() function somewhat.) + test_check good 'not good' + echo -e "$wellformedness" + logerror --fatal "Test case is not well-formed: '$xmlfile'. Quitting." + fi + result=$(validator $SCHEMA $xmlfile) + test_check $GOOD_OR_BAD "$result" + if [[ ! "$result" == '' ]]; then + [[ $GOOD_OR_BAD == 'good' ]] && echo -e "$result" + echo "###### Errors in '$xmlfile' ######" >> $ERRORFILE + echo -e "\n$result\n\n" >> $ERRORFILE + fi + done +} # ----- # -ARGS=$(getopt -o h,V: -l help,validator: -n "$PROG" -- "$@") +ARGS=$(getopt -o h,V:,t:,n -l help,validator:,test:,nomake -n "$PROG" -- "$@") eval set -- "$ARGS" while true ; do case "$1" in @@ -73,17 +156,40 @@ while true ; do ;; -V|--validator) case "$2" in - 'xmllint' | 'jing') + 'xmllint' | 'jing') VALIDATOR="$2" ;; *) print_help - echo "ERROR: Wrong validator '$2'" 2>/dev/stderr + echo "ERROR: Unrecognized validator '$2'" 2>/dev/stderr exit 10 ;; esac shift 2 ;; + -t|--test) + case "$2" in + all) + # don't do anything, this is the default + ;; + bad|good) + TEST_CATEGORY=$2 + shift 2 + ;; + -*) + # another option, don't use it + shift 1 + ;; + *) + logerror "Expected 'all', 'bad', or 'good' for option $1" + exit 1 + ;; + esac + ;; + -n|--nomake) + MAKE=0 + shift + ;; --) shift break @@ -91,39 +197,40 @@ while true ; do esac done -echo "INFO: Using validator '$VALIDATOR'..." +if [[ $MAKE -eq 1 ]]; then + loginfo "Making flat GeekoDoc..." + make -C "$PROGDIR/../rng" > /dev/null + [[ ! $? -eq 0 ]] && logerror --fatal "Make error. Quitting." +else + loginfo "Not making flat GeekoDoc" +fi -# Cleanup any *.err files first... -rm -f $PROGDIR/*.err 2>/dev/null +loginfo "Using validator '$VALIDATOR'" +loginfo "Selected category: '$TEST_CATEGORY'" + +rm -r "$ERRORFILE" 2> /dev/null + +case "$TEST_CATEGORY" in + all) + test_files $PROGDIR/good test_check_good + echo "----------------------------------" + test_files $PROGDIR/bad test_check_bad + ;; + good) + test_files $PROGDIR/good test_check_good + ;; + bad) + test_files $PROGDIR/bad test_check_bad + ;; +esac -# Iterating over all XML files inside this directory... -for xmlfile in $PROGDIR/*.xml; do - result=$(validator $SCHEMA $xmlfile ) - if [[ $result = '0' ]]; then - RESULTSTR="\e[1;32mPASSED\e[0m" - else - RESULTSTR="\e[1;31mFAILED\e[0m" - ERRORS=$(($ERROR + 1)) - fi - echo -e "Validating '$xmlfile'... $RESULTSTR" - if [[ $result != '0' ]]; then - cat "${xmlfile%*.xml}.err" 1>&2 - echo "----------------------------------------------" - fi -done echo -if [[ $ERRORS -eq 0 ]]; then - echo -e "Found\e[1;32m $ERRORS errors\e[0m. Congratulations! :-)" +loginfo "Find all validation errors in $ERRORFILE" +if [ 0 -eq "$ERRORS" ]; then + loginfo "Found\e[1;32m $ERRORS errors\e[0m. Congratulations! :-)" + exit 0 else - echo -e "Found\e[1;31m $ERRORS error(s)\e[0m. :-(" + loginfo "Found\e[1;31m $ERRORS error(s)\e[0m. :-(" exit 1 fi - -# Remove any error files which are zero bytes, but keep the ones which -# contains error messages -for errfile in $PROGDIR/*.err; do - [[ -s $errfile ]] || rm $errfile 2>/dev/null -done - -exit 0