From eca594a98dead26ea53be699620be1bb14f20ed3 Mon Sep 17 00:00:00 2001 From: Guido Draheim Date: Sat, 15 Sep 2018 02:57:43 +0200 Subject: [PATCH] migrate rules for xmlto pdf and make site --- Makefile | 2 +- docs/CMakeLists.txt | 46 ++++++++++++++++++++++++++++++++++++++--- docs/zzipdoc/htm2dbk.py | 13 +++++++++++- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 20358e4..d0ac4ca 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ libzzip libzzipmmapped libzzipfseeko libzzipwrap zzipwrap: cd build && $(MAKE) $@ VERBOSE=1 zzip unzzip unzzip-mix unzzip-mem unzzip-big zzdir zzcat zzcatsdl zzxorcat zzxordir zzobfuscated: cd build && $(MAKE) $@ VERBOSE=1 -sfx zzipself zzipsetstub doc htm man htmpages htmpages: +sfx zzipself zzipsetstub doc htm man htmpages manpages site dbk pdf: cd build && $(MAKE) $@ VERBOSE=1 builds: config build local diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index a96fbf7..054019d 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -23,14 +23,15 @@ find_package ( ZLIB REQUIRED ) # pkg_search_module ( ZZIP zzip ) find_package(PythonInterp 2.6 REQUIRED) find_package(UnixCommands REQUIRED) # bash cp mv rm gzip tar +find_program(XMLTO xmlto) set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX}) set(README ${CMAKE_SOURCE_DIR}/README) # targets ######################################################## -set(doc_FILES = README.MSVC6 README.SDL COPYING.MPL COPYING.LIB COPYING.ZLIB +set(doc_FILES README.MSVC6 README.SDL COPYING.MPL COPYING.LIB COPYING.ZLIB zziplib.html zzipmmapped.html zzipfseeko.html) -set(htm_FILES = zzip-index.htm zzip-zip.htm zzip-file.htm zzip-sdl-rwops.htm +set(htm_FILES zzip-index.htm zzip-zip.htm zzip-file.htm zzip-sdl-rwops.htm zzip-extio.htm zzip-xor.htm zzip-crypt.htm zzip-cryptoid.htm zzip-api.htm zzip-basics.htm zzip-extras.htm zzip-parse.htm 64on32.htm future.htm fseeko.htm mmapped.htm memdisk.htm @@ -48,8 +49,47 @@ set(zzipdoc_FILES makedocs.py zzipdoc/__init__.py set(topdir ${CMAKE_SOURCE_DIR}) set(srcdir ${CMAKE_CURRENT_SOURCE_DIR}) -set(docinfo --package="zziplib" --version=${VERSION}) +set(outdir ${CMAKE_CURRENT_BINARY_DIR}) set(PY2 ${PYTHON_EXECUTABLE}) + +add_custom_command(OUTPUT changes.htm + COMMAND ${BASH} -c "E=changes.htm \ + ; echo '
' > $E ; cat ${topdir}/ChangeLog \
+    | sed -e 's,\\&,\\&\\;,g' \
+    -e 's,<,\\<\\;,g' -e 's,>,\\>\\;,g' \
+    -e '/^[A-Z].*[12][09][09][09]/s,\\(.*\\),&,' \
+    -e '/^[0-9]/s,\\(.*\\),&,' >> $E ; echo '
' >>$E" + DEPENDS ${topdir}/ChangeLog + VERBATIM) + +set(mksite_sh_args --VERSION=${VERSION} --xml --src-dir=${srcdir} --print) +add_custom_command(OUTPUT site.html + COMMAND ${CP} ${srcdir}/body.htm site.htm + COMMAND ${BASH} ${srcdir}/mksite.sh ${mksite_sh_args} site.htm + DEPENDS ${htm_FILES} changes.htm + VERBATIM) +add_custom_target(site DEPENDS site.html) + +add_custom_command(OUTPUT zzip.xml + COMMAND ${PY2} ${srcdir}/zzipdoc/htm2dbk.py ${htm_FILES} zziplib.xml -o ${outdir}/zzip.xml + DEPENDS zziplib.xml ${htm_FILES} + WORKING_DIRECTORY ${srcdir} + VERBATIM) +add_custom_target(dbk DEPENDS zzip.xml) + +if(XMLTO) +add_custom_command(OUTPUT zzip.html + COMMAND ${XMLTO} html-nochunks zzip.xml + DEPENDS zzip.xml + VERBATIM) +add_custom_command(OUTPUT zzip.pdf + COMMAND ${XMLTO} pdf zzip.xml + DEPENDS zzip.xml + VERBATIM) +add_custom_target(pdf DEPENDS zzip.pdf) +endif() + +set(docinfo --package="zziplib" --version=${VERSION}) add_custom_command(OUTPUT zziplib.xml COMMAND ${PY2} ${srcdir}/makedocs.py ${topdir}/zzip/*.c ${docinfo} --onlymainheader=zzip/lib.h --output=zziplib COMMAND ${MV} zziplib.docbook zziplib.xml diff --git a/docs/zzipdoc/htm2dbk.py b/docs/zzipdoc/htm2dbk.py index ec9685b..816a695 100644 --- a/docs/zzipdoc/htm2dbk.py +++ b/docs/zzipdoc/htm2dbk.py @@ -155,4 +155,15 @@ def html2docbook(text): return htm2dbk_conversion().convert2(text) if __name__ == "__main__": - print htm2dbk_files(sys.argv[1:]) + from optparse import OptionParser + cmdline = OptionParser("%prog [options] files...") + cmdline.add_option("-o", "--into", metavar="FILE", default="") + opt, args = cmdline.parse_args() + result = htm2dbk_files(args) + if not opt.into: + print result + else: + f = open(opt.into, "w") + f.write(result) + f.close() + -- 2.40.0