The support for variables in the text-from-texi script is used to automatically insert the current version of Window Maker, inherited from the definition in the AC_INIT command, so it will be always correctly updated without the need for hand work.
Having this version information is recommended by GNU texinfo because if the document happens to get distributed outside a package it can help user avoid problems. The second use is to define a variable 'emailsupport' which contains the email address of the development team, so we can also inherit it from the AC_INIT setting. The third use is for a special variable 'cctexi2txt' to differentiate between texi2any and our script, because when using texi2any the title page is not generated, so we need to duplicate some information in the source, but we do not want it to appear twice in our generated doc. Signed-off-by: Christophe CURIS <christophe.cu...@free.fr> --- autogen.sh | 3 +++ doc/build/Makefile.am | 3 ++- doc/build/Translations.texi | 14 +++++++++++ script/generate-txt-from-texi.sh | 54 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index 46e56fc..33490b3 100755 --- a/autogen.sh +++ b/autogen.sh @@ -3,6 +3,9 @@ # Generate the documentation about compiling Window Maker ./script/generate-txt-from-texi.sh doc/build/Translations.texi > README.i18n +# Change date of the files to the past so they will be regenerated by 'make' +touch -d '2000-01-01' README.i18n + # Generate the configure script from the 'configure.ac' autoreconf -vfi -I m4 diff --git a/doc/build/Makefile.am b/doc/build/Makefile.am index bbb75dd..161da6e 100644 --- a/doc/build/Makefile.am +++ b/doc/build/Makefile.am @@ -9,7 +9,8 @@ all-local: $(top_srcdir)/README.i18n $(top_srcdir)/README.i18n: $(srcdir)/Translations.texi $(top_srcdir)/script/generate-txt-from-texi.sh $(AM_V_GEN)if test -w "$(top_srcdir)/README.i18n" ; then \ $(top_srcdir)/script/generate-txt-from-texi.sh \ - $(srcdir)/Translations.texi -o $(top_srcdir)/README.i18n ; \ + $(srcdir)/Translations.texi -o $(top_srcdir)/README.i18n \ + -Dversion="$(PACKAGE_VERSION)" -e "$(PACKAGE_BUGREPORT)" ; \ else \ echo "Warning: \"$(top_srcdir)/README.i18n\" is not writeable, not regenerated" ; \ fi diff --git a/doc/build/Translations.texi b/doc/build/Translations.texi index f7a7d66..ceaa484 100644 --- a/doc/build/Translations.texi +++ b/doc/build/Translations.texi @@ -22,7 +22,17 @@ @finalout +@c If the version was not given to texi2any with -D, assume we are being run +@c on the git dev branch +@ifclear version @set version git#next +@end ifclear + +@c We provide the ability to change the email address for support from the +@c command line +@ifclear emailsupport +@set emailsupport @email{wmaker-dev@@lists.windowmaker.org} +@end ifclear @c ---------------------------------------------------------------------------------- Title Page --- @@ -67,15 +77,19 @@ Published by The Window Maker team on @today{}. @ifnottex @top Window Maker Internationalisation +@ifclear cctexi2txt A guide to enable support for language translations in @sc{Window Maker}. +@end ifclear @end ifnottex @contents @ifnottex +@ifclear cctexi2txt @sp 1 This manual is for Window Maker, version @value{version}. +@end ifclear @end ifnottex @menu diff --git a/script/generate-txt-from-texi.sh b/script/generate-txt-from-texi.sh index 7a8eef7..4aaafb6 100755 --- a/script/generate-txt-from-texi.sh +++ b/script/generate-txt-from-texi.sh @@ -97,6 +97,8 @@ print_help() { echo "$0: convert a Texinfo file into a plain text file" echo "Usage: $0 [options...] file.texi" echo "valid options are:" + echo " -Dvar=val : set variable 'var' to value 'val'" + echo " -e email : set email address in variable 'emailsupport'" echo " -v version : version of the project" echo " -o file : name of text file to create" exit 0 @@ -106,6 +108,18 @@ print_help() { while [ $# -gt 0 ]; do case $1 in + -D*) + echo "$1" | grep '^-D[a-zA-Z][a-zA-Z]*=' > /dev/null || arg_error "syntax error for '$1', expected -Dname=value" + var_defs="$var_defs +`echo "$1" | sed -e 's/^-D/ variable["/ ; s/=/"] = "/ ; s/$/";/' `" + ;; + + -e) + shift + var_defs="$var_defs + variable[\"emailsupport\"] = \"@email{`echo "$1" | sed -e 's/@/@@/g' `}\";" + ;; + -h|-help|--help) print_help ;; -o) @@ -181,6 +195,17 @@ function end_conditional(name, local_i) { } } +# Texinfo Variables +# the texinfo standard allows to have variables set with @set and used +# with @value; they can also be defined from command-line (-D) +# they are stored in the global array "variable[name]" +function set_variable(line, local_split, local_idx) { + local_idx = match(line, /^([^ \t]+)([ \t]*)(.*)$/, local_split); + if (local_idx > 0) { + variable[ local_split[1] ] = local_split[3]; + } +} + # Write a single line to the output function write_line(line) { if (!cond_state) { return; } @@ -724,6 +749,14 @@ function execute_commands(line, replaced_line) { replaced_line = replaced_line generate_url_reference(cmdargs); break; + # Variable and Conditional commands ######################################## + case "value": + if (variable[cmdargs] == "") { + report_error("variable '" cmdargs "' is unknow, for @value at line " NR); + } + line = variable[cmdargs] line; + break; + # Miscelleanous commands ################################################### case "c": # Comments: ignore everything to the end of line @@ -816,6 +849,12 @@ BEGIN { # Number of entries in the Table of Content toc_count = 0; toc_file = "'"$toc_file"'"; + + # Define a custom variable so it is possible to differentiate between + # texi2any and this script + variable["cctexi2txt"] = "1.0"; + + # Variables inherited from the command line'"$var_defs"' } # First line is special, we always ignore it @@ -1005,6 +1044,21 @@ BEGIN { case "ifnottex": start_conditional(command[1], 1); line = ""; next; case "ifnotxml": start_conditional(command[1], 1); line = ""; next; + case "ifclear": start_conditional(command[1], (variable[line] == "")); next; + case "ifset": start_conditional(command[1], (variable[line] != "")); next; + + case "clear": + if (cond_state) { + variable[ execute_commands(line) ] = ""; + } + next; + + case "set": + if (cond_state) { + set_variable(execute_commands(line)); + } + next; + # Miscelleanous commands ################################################### case "bye": # Mark the end of file, we are supposed to ignore everything after -- 2.1.4 -- To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.