Switch from AsciiDoc to Asciidoctor.
authorGerald Combs <gerald@wireshark.org>
Thu, 19 Oct 2017 22:03:55 +0000 (15:03 -0700)
committerGerald Combs <gerald@wireshark.org>
Sun, 11 Feb 2018 18:22:09 +0000 (18:22 +0000)
Switch the markup text processor for files in the docbook directory from
AsciiDoc to Asciidoctor. Asciidoctor has several useful features (such
as direct PDF output) and is actively developed. It's written in Ruby
but that dependency can be sidestepped with AsciidoctorJ, a
self-contained bundle that only depends on the JRE.

The current toolchain targets require Python, AsciiDoc, DocBook XML,
DocBook XSL, Java, FOP, xsltproc, lynx, and the HTMLHelp compiler:

HTML: AsciiDoc → DocBook XML → xsltproc + DocBook XSL
Chunked HTML: AsciiDoc → DocBook XML → xsltproc + DocBook XSL
PDF: AsciiDoc → DocBook XML → xsltproc + DocBook XSL → FOP
HTMLHelp: AsciiDoc → DocBook XML → xsltproc + DocBook XSL → HHC

This change removes the AsciiDoc and FOP requirements and adds either
AsciidoctorJ or Asciidoctor + Ruby:

HTML: Asciidoctor → DocBook XML → xsltproc + DocBook XSL
Chunked HTML: Asciidoctor → DocBook XML → xsltproc + DocBook XSL
PDF: Asciidoctor
HTMLHelp: Asciidoctor → DocBook XML → xsltproc + DocBook XSL → HHC

Ideally we could generate all of these using AsciidoctorJ, Java, and
lynx. Unfortunately we're not there yet.

The release notes depend on several macros (ws-buglink, ws-salink,
cve-idlink, sort-and-group). Add Asciidoctor (Ruby) equivalents.

Remove the BUILD_xxx_GUIDES CMake options and add various output targets
automatically. This means that you have to build the various documentation
targets explicitly.

Change-Id: I31930677a656b99b1c6839bb6c33a13db951eb9a
Reviewed-on: https://code.wireshark.org/review/25668
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
35 files changed:
CMakeLists.txt
CMakeOptions.txt
Makefile.am
cmake/modules/FindASCIIDOC.cmake [deleted file]
cmake/modules/FindAsciidoctor.cmake [new file with mode: 0644]
cmake/modules/FindFOP.cmake [deleted file]
cmake/modules/FindLYNX.cmake
cmake/modules/FindXSLTPROC.cmake
configure.ac
debian/control
debian/rules
docbook/CMakeLists.txt
docbook/Makefile.am
docbook/README.adoc [moved from docbook/README.txt with 57% similarity]
docbook/asciidoctor-asciidoc.conf [deleted file]
docbook/asciidoctor-macros/README.adoc [new file with mode: 0644]
docbook/asciidoctor-macros/commaize-block.rb [new file with mode: 0644]
docbook/asciidoctor-macros/commaize-block/extension.rb [new file with mode: 0644]
docbook/asciidoctor-macros/commaize-block/sample.adoc [new file with mode: 0644]
docbook/asciidoctor-macros/cve_idlink-inline-macro.rb [new file with mode: 0644]
docbook/asciidoctor-macros/cve_idlink-inline-macro/extension.rb [new file with mode: 0644]
docbook/asciidoctor-macros/ws_buglink-inline-macro.rb [new file with mode: 0644]
docbook/asciidoctor-macros/ws_buglink-inline-macro/extension.rb [new file with mode: 0644]
docbook/asciidoctor-macros/ws_salink-inline-macro.rb [new file with mode: 0644]
docbook/asciidoctor-macros/ws_salink-inline-macro/extension.rb [new file with mode: 0644]
docbook/attributes.asciidoc
docbook/custom_layer_pdf.xsl [deleted file]
docbook/custom_layer_single_html.xsl [new file with mode: 0644]
docbook/release-notes.asciidoc
docbook/wsdg_src/WSDG_chapter_quick_setup.asciidoc
docbook/wsdg_src/WSDG_chapter_tools.asciidoc
packaging/nsis/CMakeLists.txt
tools/Makefile.am
tools/checklicenses.py
tools/runa2x.sh [deleted file]

index 1aaaaacc3496a37fa275436f41d785f46965bb33..239a96938f9146ccb4c084918ea2548813b595e1 100644 (file)
@@ -1037,9 +1037,7 @@ endif()
 
 set(PACKAGELIST ${PACKAGELIST} POD)
 
-if(ENABLE_HTML_GUIDES)
-       set(PACKAGELIST ${PACKAGELIST} DOXYGEN)
-endif()
+set(PACKAGELIST ${PACKAGELIST} DOXYGEN)
 
 set(PROGLIST)
 
@@ -1296,7 +1294,7 @@ add_subdirectory( capchild )
 add_subdirectory( caputils )
 add_subdirectory( codecs )
 add_subdirectory( doc )
-add_subdirectory( docbook )
+add_subdirectory( docbook EXCLUDE_FROM_ALL )
 add_subdirectory( epan )
 add_subdirectory( randpkt_core )
 add_subdirectory( tools/lemon )
@@ -3249,7 +3247,6 @@ if (NOT "${SHELLCHECK_EXECUTABLE}" STREQUAL "SHELLCHECK_EXECUTABLE-NOTFOUND")
                COMMAND shellcheck --external-sources
                        tools/fuzz-test.sh
                        tools/randpkt-test.sh
-                       tools/runa2x.sh
                        tools/test-captures.sh
                        tools/valgrind-wireshark.sh
                WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
index 6b53442f9a9ef4dfa0832cd9b86219d9c15f00d2..c011f3e65b2894203ff024532c21d551cd3d2d4e 100644 (file)
@@ -57,11 +57,6 @@ endif()
 option(ENABLE_STATIC            "Build Wireshark libraries statically" OFF)
 option(ENABLE_PLUGINS           "Build with plugins" ON)
 option(ENABLE_PLUGIN_IFDEMO     "Build with plugin interface demo" OFF)
-option(ENABLE_HTML_GUIDES       "Build HTML User & Developer Guides" OFF)
-option(ENABLE_PDF_GUIDES        "Build PDF User & Developer Guides" OFF)
-if(WIN32)
-       option(ENABLE_CHM_GUIDES        "Build HTML Help User & Developer Guides" OFF)
-endif()
 option(ENABLE_PCAP_NG_DEFAULT   "Enable pcapng as default file format" ON)
 
 option(ENABLE_PORTAUDIO  "Build with PortAudio support" ON)
index 240ec1833d9568461dbddba428608154627341c1..e09efb80356d5909979ab81a5a1e9efb642bff81 100644 (file)
@@ -1001,7 +1001,6 @@ shellcheck:
        $(SHELLCHECK) --external-sources \
          tools/fuzz-test.sh \
          tools/randpkt-test.sh \
-         tools/runa2x.sh \
          tools/test-captures.sh \
          tools/valgrind-wireshark.sh
 
diff --git a/cmake/modules/FindASCIIDOC.cmake b/cmake/modules/FindASCIIDOC.cmake
deleted file mode 100644 (file)
index d8dff81..0000000
+++ /dev/null
@@ -1,262 +0,0 @@
-#
-# - Find unix commands from cygwin
-# This module looks for some usual Unix commands.
-#
-
-INCLUDE(FindCygwin)
-
-FIND_PROGRAM(A2X_EXECUTABLE
-    NAMES
-        a2x
-    PATHS
-        ${CYGWIN_INSTALL_PATH}/bin
-        /bin
-        /usr/bin
-        /usr/local/bin
-        /sbin
-)
-
-string( TOLOWER "${CYGWIN_INSTALL_PATH}" l_cyg_path)
-string( TOLOWER "${A2X_EXECUTABLE}" l_a2x_ex)
-if (NOT "${CYGWIN_INSTALL_PATH}" STREQUAL "" AND "${l_a2x_ex}" MATCHES "${l_cyg_path}")
-    message(STATUS "Using Cygwin a2x")
-    # We have most likely found a symlink to a2x.py. This won't work from the Windows shell.
-    FIND_PROGRAM(CYGPATH_EXECUTABLE
-        NAMES cygpath
-        PATHS ${CYGWIN_INSTALL_PATH}/bin
-    )
-
-    MACRO( TO_A2X_COMPATIBLE_PATH _cmake_path _result )
-        execute_process(
-            COMMAND ${CYGPATH_EXECUTABLE} -u ${_cmake_path}
-            OUTPUT_VARIABLE _cygwin_path
-        )
-        # cygpath adds a linefeed.
-        string(STRIP "${_cygwin_path}" _cygwin_path)
-
-        set( ${_result} ${_cygwin_path} )
-    ENDMACRO()
-
-    TO_A2X_COMPATIBLE_PATH( ${CMAKE_SOURCE_DIR}/tools/runa2x.sh RUNA2X_CYGWIN_PATH )
-
-    # It's difficult or impossible to call /usr/bin/a2x directly from
-    # Windows because:
-    # - /usr/bin/a2x, which is a symlink to /usr/bin/a2x.py.
-    # - We need to set environment variables (LC_ALL, PATH, TZ, PYTHONHOME)
-    # so we use a wrapper script.
-    set( RUNA2X ${SH_EXECUTABLE} ${RUNA2X_CYGWIN_PATH} )
-else()
-    # Make sure we don't get language specific quotes
-    set( RUNA2X LC_ALL=C TZ=UTC ${A2X_EXECUTABLE} )
-
-    MACRO( TO_A2X_COMPATIBLE_PATH _cmake_path _result )
-        set( ${_result} ${_cmake_path} )
-    ENDMACRO()
-endif()
-
-# Handle the QUIETLY and REQUIRED arguments and set ASCIIDOC_FOUND to TRUE if
-# all listed variables are TRUE
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(ASCIIDOC DEFAULT_MSG RUNA2X)
-
-MARK_AS_ADVANCED(RUNA2X)
-
-TO_A2X_COMPATIBLE_PATH( ${CMAKE_CURRENT_BINARY_DIR} _a2x_current_binary_dir )
-
-MACRO( ASCIIDOC2DOCBOOK _asciidocsource _conf_files _src_files _built_deps )
-    GET_FILENAME_COMPONENT( _source_base_name ${_asciidocsource} NAME_WE )
-    set( A2X_HTML_OPTS --stylesheet=ws.css )
-    set( _output_xml ${_source_base_name}.xml )
-
-    foreach(_conf_file ${${_conf_files}})
-        TO_A2X_COMPATIBLE_PATH ( ${CMAKE_CURRENT_SOURCE_DIR}/${_conf_file} _a2x_conf_file )
-        set( _conf_opts_list ${_conf_opts_list} --conf-file=${_a2x_conf_file})
-    endforeach()
-    string( REPLACE ";" " " _conf_opts "${_conf_opts_list}")
-
-    foreach(_conf_file ${${_conf_files}})
-        set( _conf_deps ${_conf_deps} ${CMAKE_CURRENT_SOURCE_DIR}/${_conf_file})
-    endforeach()
-
-    foreach(_src_file ${${_src_files}})
-        set( _src_deps ${_src_deps} ${CMAKE_CURRENT_SOURCE_DIR}/${_src_file})
-    endforeach()
-
-    TO_A2X_COMPATIBLE_PATH ( ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource} _a2x_asciidocsource )
-
-    if(CMAKE_GENERATOR MATCHES "Visual Studio")
-      # Workaround to prevent parallel msbuild builds from failing, see function
-      # get_docbook_xml_depends in FindXSLTPROC.cmake for details. This command
-      # updates the stamp file when the XML file is updated.
-      set(_stamp_file "${CMAKE_CURRENT_BINARY_DIR}/${_output_xml}-stamp")
-      set_property(SOURCE "${_stamp_file}" PROPERTY GENERATED)
-      set(_command_touch_stamp COMMAND "${CMAKE_COMMAND}" -E touch "${_stamp_file}")
-    else()
-      set(_command_touch_stamp "")
-    endif()
-
-    add_custom_command(
-        OUTPUT
-            ${_output_xml}
-        # XXX - Output to a specific directory, e.g. wsdg_generated_src
-        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-        COMMAND ${RUNA2X}
-            --verbose
-            --attribute=build_dir=${_a2x_current_binary_dir}
-            --attribute=docinfo
-            --destination-dir=${_a2x_current_binary_dir}
-            --asciidoc-opts=${_conf_opts}
-            --no-xmllint
-            --format=docbook
-            --fop
-            ${A2X_HTML_OPTS}
-            ${_a2x_asciidocsource}
-        ${_command_touch_stamp}
-        DEPENDS
-            ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource}
-            ${_conf_deps}
-            ${_src_deps}
-            ${${_built_deps}}
-    )
-    add_custom_target(generate_${_output_xml} DEPENDS ${_output_xml})
-    set_target_properties(generate_${_output_xml} PROPERTIES FOLDER "Docbook")
-    unset(_src_deps)
-    unset(_conf_deps)
-    unset(_conf_opts_list)
-ENDMACRO()
-
-MACRO( ASCIIDOC2HTML _output _asciidocsource _conf_files )
-    GET_FILENAME_COMPONENT( _source_base_name ${_asciidocsource} NAME_WE )
-    SET( A2X_HTML_OPTS --stylesheet=ws.css )
-
-    SET( _conf_opts_list )
-    FOREACH( _conf_file ${_conf_files} )
-        TO_A2X_COMPATIBLE_PATH ( ${CMAKE_CURRENT_SOURCE_DIR}/${_conf_file} _a2x_conf_file )
-        SET( _conf_opts_list ${_conf_opts_list} --conf-file=${_a2x_conf_file})
-    ENDFOREACH()
-    STRING( REPLACE ";" " " _conf_opts "${_conf_opts_list}" )
-
-    SET( _conf_deps )
-    FOREACH( _conf_file ${_conf_files} )
-        SET( _conf_deps ${_conf_deps} ${CMAKE_CURRENT_SOURCE_DIR}/${_conf_file} )
-    ENDFOREACH()
-
-    TO_A2X_COMPATIBLE_PATH ( ${_asciidocsource} _a2x_asciidocsource )
-
-    ADD_CUSTOM_COMMAND(
-        OUTPUT
-            ${_output}
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-        COMMAND ${RUNA2X}
-            --format=xhtml
-            --destination-dir=${_a2x_current_binary_dir}
-            --asciidoc-opts=${_conf_opts}
-            --fop
-            ${A2X_HTML_OPTS}
-            ${_a2x_asciidocsource}
-        # Replacing file with itself will fail
-        # COMMAND ${CMAKE_COMMAND} -E rename
-        #     ${CMAKE_CURRENT_BINARY_DIR}/${_source_base_name}.html
-        #     ${CMAKE_CURRENT_BINARY_DIR}/${_output}
-        DEPENDS
-            ${_asciidocsources}
-            ${_conf_deps}
-            ${_otherdependencies}
-    )
-    unset(_conf_deps)
-    unset(_conf_opts_list)
-ENDMACRO()
-
-MACRO( ASCIIDOC2TXT _output _asciidocsource _conf_files )
-    GET_FILENAME_COMPONENT( _source_base_name ${_asciidocsource} NAME_WE )
-    if( LYNX_EXECUTABLE MATCHES lynx )
-        set( A2X_TEXT_OPTS --lynx )
-    else()
-        set( A2X_TEXT_OPTS  )
-    endif()
-    SET( A2X_HTML_OPTS --stylesheet=ws.css )
-
-    SET( _conf_opts_list )
-    FOREACH( _conf_file ${_conf_files} )
-        TO_A2X_COMPATIBLE_PATH ( ${CMAKE_CURRENT_SOURCE_DIR}/${_conf_file} _a2x_conf_file )
-        SET( _conf_opts_list ${_conf_opts_list} --conf-file=${_a2x_conf_file})
-    ENDFOREACH()
-    STRING( REPLACE ";" " " _conf_opts "${_conf_opts_list}" )
-
-    SET( _conf_deps )
-    FOREACH( _conf_file ${_conf_files} )
-        SET( _conf_deps ${_conf_deps} ${CMAKE_CURRENT_SOURCE_DIR}/${_conf_file} )
-    ENDFOREACH()
-
-    TO_A2X_COMPATIBLE_PATH ( ${_asciidocsource} _a2x_asciidocsource )
-
-    ADD_CUSTOM_COMMAND(
-        OUTPUT
-            ${_output}
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-        COMMAND ${RUNA2X}
-            --format=text
-            --destination-dir=${_a2x_current_binary_dir}
-            --asciidoc-opts=${_conf_opts}
-            --fop
-            ${A2X_TEXT_OPTS}
-            # XXX This generates a CMake working but correcting it looks
-            # messy.
-            --xsltproc-opts '--stringparam generate.toc "article nop" '
-            ${_a2x_asciidocsource}
-        COMMAND ${CMAKE_COMMAND} -E rename
-            ${CMAKE_CURRENT_BINARY_DIR}/${_source_base_name}.text
-            ${CMAKE_CURRENT_BINARY_DIR}/${_output}
-        DEPENDS
-            ${_asciidocsource}
-            ${_conf_deps}
-    )
-    unset(_conf_deps)
-    unset(_conf_opts_list)
-ENDMACRO()
-
-# news: release-notes.txt
-#         ${CMAKE_COMMAND} -E copy_if_different release-notes.txt ../NEWS
-
-MACRO( ASCIIDOC2PDF _output _asciidocsource _conf_files _paper )
-    GET_FILENAME_COMPONENT( _source_base_name ${_asciidocsource} NAME_WE )
-    SET( A2X_HTML_OPTS --stylesheet=ws.css )
-
-    SET( _conf_opts_list )
-    FOREACH( _conf_file ${_conf_files} )
-        TO_A2X_COMPATIBLE_PATH ( ${CMAKE_CURRENT_SOURCE_DIR}/${_conf_file} _a2x_conf_file )
-        SET( _conf_opts_list ${_conf_opts_list} --conf-file=${_a2x_conf_file})
-    ENDFOREACH()
-    STRING( REPLACE ";" " " _conf_opts "${_conf_opts_list}")
-
-    SET( _conf_deps )
-    FOREACH( _conf_file ${_conf_files} )
-        SET( _conf_deps ${_conf_deps} ${CMAKE_CURRENT_SOURCE_DIR}/${_conf_file} )
-    ENDFOREACH()
-
-    TO_A2X_COMPATIBLE_PATH ( ${_asciidocsource} _a2x_asciidocsource )
-
-    ADD_CUSTOM_COMMAND(
-        OUTPUT
-            ${_output}
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-        COMMAND ${RUNA2X}
-            --format=pdf
-            --destination-dir=${_a2x_current_binary_dir}
-            --asciidoc-opts=${_conf_opts}
-            --fop
-            ${A2X_HTML_OPTS}
-            --xsltproc-opts "--stringparam paper.type ${_paper} --nonet"
-            --xsl-file=custom_layer_pdf.xsl
-            ${_a2x_asciidocsource}
-        COMMAND ${CMAKE_COMMAND} -E rename
-            ${CMAKE_CURRENT_BINARY_DIR}/${_source_base_name}.pdf
-            ${CMAKE_CURRENT_BINARY_DIR}/${_output}
-        DEPENDS
-            ${_asciidocsources}
-            ${_conf_deps}
-            ${_otherdependencies}
-    )
-    unset(_conf_deps)
-    unset(_conf_opts_list)
-ENDMACRO()
diff --git a/cmake/modules/FindAsciidoctor.cmake b/cmake/modules/FindAsciidoctor.cmake
new file mode 100644 (file)
index 0000000..f387432
--- /dev/null
@@ -0,0 +1,146 @@
+#
+# - Find Asciidoctor
+# Sets:
+#  ASCIIDOCTOR_EXECUTABLE
+#
+
+INCLUDE(FindChocolatey)
+
+FIND_PROGRAM(ASCIIDOCTOR_EXECUTABLE
+    NAMES
+        asciidoctorj
+        asciidoctor
+    PATHS
+        /bin
+        /usr/bin
+        /usr/local/bin
+        ${CHOCOLATEY_BIN_PATH}/bin
+    DOC "Path to Asciidoctor or AsciidoctorJ"
+)
+
+if(ASCIIDOCTOR_EXECUTABLE)
+    # The AsciidctorJ wrapper script sets -Xmx256m. This isn't enough
+    # for the User's Guide.
+    set(_asciidoctorj_opts "-Xmx800m $ENV{ASCIIDOCTORJ_OPTS}")
+    execute_process( COMMAND ${ASCIIDOCTOR_EXECUTABLE} --version OUTPUT_VARIABLE _ad_full_version )
+    separate_arguments(_ad_full_version)
+    list(GET _ad_full_version 1 ASCIIDOCTOR_VERSION)
+
+    function(set_asciidoctor_target_properties _target)
+        set_target_properties(${_target} PROPERTIES
+            FOLDER "Docbook"
+            EXCLUDE_FROM_DEFAULT_BUILD True
+            )
+    endfunction(set_asciidoctor_target_properties)
+
+    set (_asciidoctor_common_args
+        --attribute build_dir=${CMAKE_CURRENT_BINARY_DIR}
+        --require ${CMAKE_CURRENT_SOURCE_DIR}/asciidoctor-macros/commaize-block.rb
+        --require ${CMAKE_CURRENT_SOURCE_DIR}/asciidoctor-macros/cve_idlink-inline-macro.rb
+        --require ${CMAKE_CURRENT_SOURCE_DIR}/asciidoctor-macros/ws_buglink-inline-macro.rb
+        --require ${CMAKE_CURRENT_SOURCE_DIR}/asciidoctor-macros/ws_salink-inline-macro.rb
+    )
+
+    set(_asciidoctor_common_command ${CMAKE_COMMAND} -E
+        env TZ=UTC ASCIIDOCTORJ_OPTS="${_asciidoctorj_opts}"
+        ${ASCIIDOCTOR_EXECUTABLE}
+        ${_asciidoctor_common_args}
+    )
+
+    MACRO( ASCIIDOCTOR2DOCBOOK _asciidocsource )
+        GET_FILENAME_COMPONENT( _source_base_name ${_asciidocsource} NAME_WE )
+        set( _output_xml ${_source_base_name}.xml )
+
+        add_custom_command(
+            OUTPUT
+                ${_output_xml}
+            COMMAND ${_asciidoctor_common_command}
+                --backend docbook
+                --out-file ${_output_xml}
+                ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource}
+            DEPENDS
+                ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource}
+                ${ARGN}
+        )
+        add_custom_target(generate_${_output_xml} DEPENDS ${_output_xml})
+        set_asciidoctor_target_properties(generate_${_output_xml})
+        unset(_output_xml)
+    ENDMACRO()
+
+    # Currently single page only.
+    MACRO( ASCIIDOCTOR2HTML _asciidocsource )
+        GET_FILENAME_COMPONENT( _source_base_name ${_asciidocsource} NAME_WE )
+        set( _output_html ${_source_base_name}.html )
+
+        ADD_CUSTOM_COMMAND(
+            OUTPUT
+                ${_output_html}
+            COMMAND ${_asciidoctor_common_command}
+                --backend html
+                --out-file ${_output_html}
+                ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource}
+            DEPENDS
+                ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource}
+                ${ARGN}
+        )
+        add_custom_target(generate_${_output_html} DEPENDS ${_output_html})
+        set_asciidoctor_target_properties(generate_${_output_html})
+        unset(_output_html)
+    ENDMACRO()
+
+    MACRO( ASCIIDOCTOR2TXT _asciidocsource )
+        if( LYNX_EXECUTABLE )
+            GET_FILENAME_COMPONENT( _source_base_name ${_asciidocsource} NAME_WE )
+            set( _output_html ${_source_base_name}.html )
+            set( _output_txt ${_source_base_name}.txt )
+
+            ADD_CUSTOM_COMMAND(
+                OUTPUT
+                    ${_output_txt}
+                COMMAND ${LYNX_EXECUTABLE}
+                    -dump
+                    ${_output_html}
+                    > ${_output_txt}
+                DEPENDS
+                    ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource}
+                    ${_output_html}
+                    ${ARGN}
+            )
+            unset(_output_html)
+            unset(_output_txt)
+        endif( LYNX_EXECUTABLE )
+    ENDMACRO()
+
+    # news: release-notes.txt
+    #         ${CMAKE_COMMAND} -E copy_if_different release-notes.txt ../NEWS
+
+    MACRO( ASCIIDOCTOR2PDF _asciidocsource )
+        GET_FILENAME_COMPONENT( _source_base_name ${_asciidocsource} NAME_WE )
+        set( _output_pdf ${_source_base_name}.pdf )
+
+        ADD_CUSTOM_COMMAND(
+            OUTPUT
+                ${_output_pdf}
+            COMMAND ${_asciidoctor_common_command}
+                --backend pdf
+                ${_asciidoctor_common_args}
+                --out-file ${_output_pdf}
+                ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource}
+            DEPENDS
+                ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource}
+                ${ARGN}
+        )
+        add_custom_target(generate_${_output_pdf} DEPENDS ${_output_pdf})
+        set_asciidoctor_target_properties(generate_${_output_pdf})
+        unset(_output_pdf)
+    ENDMACRO()
+
+endif(ASCIIDOCTOR_EXECUTABLE)
+
+include( FindPackageHandleStandardArgs )
+find_package_handle_standard_args( ASCIIDOCTOR
+    REQUIRED_VARS ASCIIDOCTOR_EXECUTABLE
+    VERSION_VAR ASCIIDOCTOR_VERSION
+    )
+
+mark_as_advanced( ASCIIDOCTOR_EXECUTABLE )
diff --git a/cmake/modules/FindFOP.cmake b/cmake/modules/FindFOP.cmake
deleted file mode 100644 (file)
index e504338..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# - Find unix commands from cygwin
-# This module looks for some usual Unix commands.
-#
-
-INCLUDE(FindCygwin)
-
-INCLUDE(FindWSWinLibs)
-FindWSWinLibs("fop-2.1" "FOP21_HINTS")
-FindWSWinLibs("fop-2.0" "FOP20_HINTS")
-FindWSWinLibs("fop-1.1" "FOP11_HINTS")
-FindWSWinLibs("fop-1.0" "FOP10_HINTS")
-
-FIND_PROGRAM(FOP_EXECUTABLE
-  NAMES
-    fop
-  PATHS
-    ${CYGWIN_INSTALL_PATH}/bin
-    /bin
-    /usr/bin
-    /usr/local/bin
-    /sbin
-  HINTS
-    ${FOP21_HINTS}
-    ${FOP20_HINTS}
-    ${FOP11_HINTS}
-    ${FOP10_HINTS}
-)
-
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(FOP DEFAULT_MSG FOP_EXECUTABLE)
-
-IF(${FOP_EXECUTABLE})
-       SET(FOP_OPTS -Xmx256m)
-       SET(FOP_EXECUTABLE FOP_OPTS=${FOP_OPTS} JAVA_OPTS=${FOP_OPTS} ${FOP_EXECUTABLE})
-ENDIF()
-MARK_AS_ADVANCED(FOP_EXECUTABLE)
index 683b574ae55a48bc67dddc50ecbf59781d5ce703..654c9442e7ccaca1f0f9fc582b8ddf8d78882203 100644 (file)
@@ -1,13 +1,15 @@
 #
-# - Find unix commands from cygwin
-# This module looks for lynx (used by asciidoc)
+# This module looks for an HTML to plain text converter which accepts
+# a "-dump" argument.
+#
+# Lynx is preferred since it generates URL footnotes.
 #
 
 INCLUDE(FindCygwin)
 
 FIND_PROGRAM(LYNX_EXECUTABLE
   NAMES
-    lynx
+    lynx w3m links
   PATHS
     ${CYGWIN_INSTALL_PATH}/bin
     /bin
index 62d71af846e350d4188b5806d498da063f698263..fb2d50a77a5406211d21b38c0e4d5ca4a44dcf7b 100644 (file)
@@ -5,13 +5,6 @@
 
 include(FindCygwin)
 
-if(ENABLE_PDF_GUIDES)
-    find_package(FOP)
-    if(${FOP_EXECUTABLE} STREQUAL "FOP_EXECUTABLE-NOTFOUND")
-        message(FATAL_ERROR "fop wasn't found, but is necessary for building PDFs." )
-    endif()
-endif()
-
 find_program(XSLTPROC_EXECUTABLE
   NAMES
     xsltproc
@@ -44,7 +37,6 @@ if (WIN32 AND NOT "${CYGWIN_INSTALL_PATH}" STREQUAL "" AND ${XSLTPROC_EXECUTABLE
         NAMES cygpath
         PATHS ${CYGWIN_INSTALL_PATH}/bin
     )
-    # XXX Duplicate of TO_A2X_COMPATIBLE_PATH
     MACRO( TO_XSLTPROC_COMPATIBLE_PATH _cmake_path _result )
         execute_process(
             COMMAND ${CYGPATH_EXECUTABLE} -u ${_cmake_path}
@@ -103,13 +95,18 @@ MACRO(XML2HTML _target_dep _dir_pfx _mode _dbk_source _gfx_sources)
     # We depend on the docbook target to avoid parallel builds.
     SET(_dbk_dep ${_target_dep}_docbook)
 
+    # We can pass chunker.xxx parameters to customize the chunked output.
+    # We have to use a custom layer to customize the single-page output.
+    # Set the output encoding for both to UTF-8. Indent the single-page
+    # output because we sometimes need to copy and paste the release
+    # note contents.
     IF(${_mode} STREQUAL "chunked")
         SET(_basedir ${_dir_pfx}_html_chunked)
-        SET(_STYLESHEET "http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl")
-        SET(_modeparams --noout)
+        SET(_stylesheet "http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl")
+        SET(_modeparams --stringparam chunker.output.encoding UTF-8)
     ELSE() # single-page
         SET(_basedir ${_dir_pfx}_html)
-        SET(_STYLESHEET "http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl")
+        SET(_stylesheet custom_layer_single_html.xsl)
         SET(_modeparams --output ${_basedir}/index.html)
     ENDIF()
 
@@ -121,11 +118,6 @@ MACRO(XML2HTML _target_dep _dir_pfx _mode _dbk_source _gfx_sources)
         set(_gfx_deps ${CMAKE_CURRENT_SOURCE_DIR}/${_tmpgfx})
     ENDFOREACH()
 
-#    GET_FILENAME_COMPONENT(_GFXDIR ${_gfx} ABSOLUTE)
-#    GET_FILENAME_COMPONENT(_GFXDIR ${_GFXDIR} PATH)
-#    GET_FILENAME_COMPONENT(_OUTDIR ${_output} PATH)
-#    SET(_OUTDIR ${CMAKE_CURRENT_BINARY_DIR}/${_OUTDIR})
-
     SET(_gfx_dir ${_dir_pfx}_graphics)
     ADD_CUSTOM_COMMAND(
         OUTPUT
@@ -148,12 +140,13 @@ MACRO(XML2HTML _target_dep _dir_pfx _mode _dbk_source _gfx_sources)
             ${_common_xsltproc_args}
             --stringparam admon.graphics.path ${_gfx_dir}/
             ${_modeparams}
-            ${_STYLESHEET}
+            --noout ${_stylesheet}
             ${_dbk_source}
         DEPENDS
             ${_dbk_xml_deps}
             ${_dbk_dep}
             ${_gfx_deps}
+            custom_layer_single_html.xsl
     )
     IF(NOT WIN32)
         ADD_CUSTOM_COMMAND(
@@ -166,41 +159,6 @@ MACRO(XML2HTML _target_dep _dir_pfx _mode _dbk_source _gfx_sources)
     ENDIF()
 ENDMACRO(XML2HTML)
 
-# Translate XML to FO to PDF
-#XML2PDF(
-#       user-guide-a4.fo or user-guide-us.fo
-#       WSUG_SOURCE
-#       custom_layer_pdf.xsl
-#       A4 or letter
-#)
-MACRO(XML2PDF _target_dep _output _dbk_source _stylesheet)
-    # We depend on the docbook target to avoid parallel builds.
-    SET(_dbk_dep ${_target_dep}_docbook)
-    file(RELATIVE_PATH _img_relative_path ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-    get_docbook_xml_depends(_dbk_xml_deps "${_dbk_source}")
-    ADD_CUSTOM_COMMAND(
-        OUTPUT
-            ${_output}
-            ${_output}.fo
-        COMMAND ${XSLTPROC_EXECUTABLE}
-            --path "${_xsltproc_path}"
-            --stringparam img.src.path ${_img_relative_path}/
-            --stringparam use.id.as.filename 1
-            --stringparam admon.graphics.path ${_img_relative_path}/common_graphics/
-            --nonet
-            --output ${_output}.fo
-            ${_stylesheet}
-            ${_dbk_source}
-        COMMAND ${FOP_EXECUTABLE}
-            ${_output}.fo
-            ${_output}
-        DEPENDS
-            ${_dbk_xml_deps}
-            ${_dbk_dep}
-            ${_stylesheet}
-    )
-ENDMACRO(XML2PDF)
-
 # Translate XML to HHP
 #XML2HHP(
 #       wsug or wsdg
index 129f3cb99ef98b98140cd1e675b0e4c32aaeb9e1..dc191705643564dd8b57293b758d5edb932e7e99 100644 (file)
@@ -444,40 +444,36 @@ AC_ARG_ENABLE(guides,
 # Check for programs used when building DocBook documentation.
 #
 have_wsug=yes
-AC_PATH_PROG(XSLTPROC, xsltproc, xsltproc)
-AS_IF([test ! -x "$XSLTPROC"],
+AC_PATH_PROGS(ASCIIDOCTOR, [asciidoctorj asciidoctor])
+AC_CHECK_PROGS(HAVE_ASCIIDOCTOR, [asciidoctorj asciidoctor], "yes", "no")
+AM_CONDITIONAL(HAVE_ASCIIDOCTOR, test x$HAVE_ASCIIDOCTOR = xyes)
+AS_IF([test ! -x "$ASCIIDOCTOR"],
        [
          AS_IF([test "x$want_wsug" = xyes],
-               [AC_MSG_ERROR([xlstproc not found but required to build the Wireshark User's Guide])])
+               [AC_MSG_ERROR([Asciidoctor not found. This is required to build the release notes and guides])])
          have_wsug=no
        ])
-AC_PATH_PROG(A2X, a2x, a2x)
-AS_IF([test ! -x "$A2X"],
+AC_PATH_PROG(XSLTPROC, xsltproc, xsltproc)
+AS_IF([test ! -x "$XSLTPROC"],
        [
          AS_IF([test "x$want_wsug" = xyes],
-               [AC_MSG_ERROR([a2x not found but required to build the Wireshark User's Guide])])
+               [AC_MSG_ERROR([xlstproc not found but required to build the Wireshark User's Guide])])
          have_wsug=no
        ])
 
-AC_PATH_PROG(FOP, fop, fop)
-
 AM_CONDITIONAL(BUILD_USER_GUIDE, [test "x$have_wsug" = xyes -a "x$want_wsug" != xno])
 
-# HTML to text processor
+# HTML to text processor. Executable must support "-dump".
 AC_MSG_CHECKING([for an HTML to text processor])
-AS_IF([w3m -version >&AS_MESSAGE_LOG_FD 2>&1], [have_a2x_text=w3m],
-       [lynx -version >&AS_MESSAGE_LOG_FD 2>&1], [have_a2x_text=lynx],
-       [have_a2x_text=no])
-AC_MSG_RESULT([$have_a2x_text])
-AM_CONDITIONAL(HAVE_A2X_TEXT, [test "x$have_a2x_text" != xno])
-AS_IF([test $have_a2x_text = lynx], [A2X_LYNX="--lynx"])
-AC_SUBST(A2X_LYNX)
+AC_PATH_PROGS(LYNX, [lynx w3m links])
+AC_CHECK_PROGS(HAVE_LYNX, [lynx w3m links], "yes", "no")
+AM_CONDITIONAL(HAVE_LYNX, test x$HAVE_LYNX = xyes)
 
 # RPM
 AC_CHECK_PROGS(RPMBUILD, [rpmbuild], [rpmbuild])
 
 # Shellcheck
-AC_CHECK_PROGS(SHELLCHECK, shellcheck, shellcheck)
+AC_CHECK_PROG(SHELLCHECK, shellcheck)
 
 #
 # Check compiler vendor. For GCC this will be 'gnu' and for Clang 'clang'.
index fc5712f882ac5cc507231a46cf4755335cfb5515..2639d60d8decdbfb0273760057a4cb9a1b44c247 100644 (file)
@@ -20,7 +20,7 @@ Build-Depends: libgtk-3-dev, lsb-release,
  libgnutls-dev,
  libgcrypt-dev, portaudio19-dev, libkrb5-dev, liblua5.2-dev, libsmi2-dev,
  libgeoip-dev, dpkg-dev (>= 1.16.1~),
- libnl-genl-3-dev [linux-any], libnl-route-3-dev [linux-any], asciidoc,
+ libnl-genl-3-dev [linux-any], libnl-route-3-dev [linux-any], asciidoctor,
  cmake (>= 2.8.8), w3m, libsbc-dev, libnghttp2-dev, libssh-gcrypt-dev,
  liblz4-dev, libsnappy-dev, libspandsp-dev, libxml2-dev
 Build-Conflicts: libsnmp4.2-dev, libsnmp-dev
index efb6c8f420ff5504090f96b9ef38c7afda9c0329..88ece0c94e870f6e34c9dba3ec0e077e33974d7f 100755 (executable)
@@ -27,13 +27,14 @@ export docdir = /usr/share/doc/wireshark-doc
        dh $@ --with python2 --buildsystem cmake --with quilt --parallel
 
 override_dh_auto_configure:
-       dh_auto_configure -- -DBUILD_xxx2deb=ON -DENABLE_HTML_GUIDES=ON -DCMAKE_INSTALL_LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
+       dh_auto_configure -- -DBUILD_xxx2deb=ON -DCMAKE_INSTALL_LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
        -DBUILD_wireshark_gtk=ON \
 #      -DENABLE_QT5=OFF
 
 override_dh_auto_build:
        $(MAKE) -C $(CURDIR)/obj-* asn1
        dh_auto_build
+       $(MAKE) -C $(CURDIR)/obj-* user_guide_html developer_guide_html
        # fix links in documentation
        sed -i "s|$(CURDIR)/docbook|..|" obj-*/docbook/ws*g_html_chunked/*.html
 
index 370c7077ad69d90b4fe3ebdf2e179e756e86a18f..259c4d3231129c138c8ab1887c72c0751f5d46cf 100644 (file)
@@ -7,29 +7,30 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
 #
 
+# To do:
+# - Rename *.asciidoc to *.adoc
+# - Make the build targets top-level on Windows, similar to the NSIS,
+#   WiX, and PortableApps targets?
+
 find_package( LYNX )
-if(ENABLE_HTML_GUIDES OR ENABLE_PDF_GUIDES OR ENABLE_CHM_GUIDES)
-       find_package( ASCIIDOC REQUIRED )
-       find_package( XSLTPROC REQUIRED )
-else()
-       # This is an optional add of the packages
-       find_package( ASCIIDOC )
-       find_package( XSLTPROC )
-endif()
+find_package( Asciidoctor 1.5 )
+find_package( XSLTPROC )
+
+function(set_docbook_target_properties _target)
+       set_target_properties(${_target} PROPERTIES
+               FOLDER "Docbook"
+               EXCLUDE_FROM_DEFAULT_BUILD True
+               )
+endfunction(set_docbook_target_properties)
 
-if(ENABLE_CHM_GUIDES)
-       find_package( HTMLHelp REQUIRED )
+if(WIN32)
+       find_package( HTMLHelp )
        if(HTML_HELP_COMPILER)
                # We do not need the HTML Help headers and library, just the
                # compiler. To avoid confusion, report the package as found.
                # https://gitlab.kitware.com/cmake/cmake/issues/15886
                set(HTMLHelp_FOUND 1)
-       else()
-               message(FATAL_ERROR "HTML Help Compiler is not installed (required for ENABLE_CHM_GUIDES)")
        endif()
-endif()
-
-if(WIN32)
        macro( HHP2CHM _hhpsource )
                get_filename_component( _source_base_name ${_hhpsource} NAME_WE )
 
@@ -117,6 +118,7 @@ add_custom_command(
 add_custom_target(update_tools_help
        DEPENDS ${WSUG_TOOLS_PHONY_DEPS}
 )
+set_docbook_target_properties(update_tools_help)
 
 set(WSUG_FILES
        wsug_src/WSUG_app_files.asciidoc
@@ -371,36 +373,35 @@ ADD_CUSTOM_COMMAND(
 set( WSDG_BUILT_DEPS ws.css wsluarm )
 
 set( ASCIIDOC_CONF_FILES
-       asciidoc.conf
-       asciidoctor-asciidoc.conf
        attributes.asciidoc
+       # XXX Add macros
 )
 
-if(ENABLE_HTML_GUIDES OR ENABLE_PDF_GUIDES OR ENABLE_CHM_GUIDES)
+if(ASCIIDOCTOR_EXECUTABLE)
        # Generate the DocBook sources of user and developer guides
 
-       ASCIIDOC2DOCBOOK(user-guide.asciidoc ASCIIDOC_CONF_FILES WSUG_SOURCE WSUG_BUILT_DEPS)
+       ASCIIDOCTOR2DOCBOOK(user-guide.asciidoc ${ASCIIDOC_CONF_FILES} ${WSUG_SOURCE} ${WSUG_BUILT_DEPS})
        add_custom_target(user_guide_docbook DEPENDS generate_user-guide.xml)
-       set_target_properties(user_guide_docbook PROPERTIES FOLDER "Docbook")
+       set_docbook_target_properties(user_guide_docbook)
 
-       ASCIIDOC2DOCBOOK(developer-guide.asciidoc ASCIIDOC_CONF_FILES WSDG_SOURCE WSDG_BUILT_DEPS)
+       ASCIIDOCTOR2DOCBOOK(developer-guide.asciidoc ${ASCIIDOC_CONF_FILES} ${WSDG_SOURCE} ${WSDG_BUILT_DEPS})
        add_custom_target(developer_guide_docbook DEPENDS generate_developer-guide.xml)
-       set_target_properties(developer_guide_docbook PROPERTIES FOLDER "Docbook")
+       set_docbook_target_properties(developer_guide_docbook)
 
        # Top-level guide targets.
 
        add_custom_target(user_guides DEPENDS user_guide_docbook)
-       set_target_properties(user_guides PROPERTIES FOLDER "Docbook")
+       set_docbook_target_properties(user_guides)
 
        add_custom_target(developer_guides DEPENDS developer_guide_docbook)
-       set_target_properties(developer_guides PROPERTIES FOLDER "Docbook")
+       set_docbook_target_properties(developer_guides)
 
-       add_custom_target(all_guides ALL DEPENDS user_guides developer_guides )
-       set_target_properties(all_guides PROPERTIES FOLDER "Docbook")
+       add_custom_target(all_guides DEPENDS user_guides developer_guides )
+       set_docbook_target_properties(all_guides)
 endif()
 
 # User's Guide chain.
-if(ENABLE_HTML_GUIDES)
+if(ASCIIDOCTOR_EXECUTABLE AND XSLTPROC_EXECUTABLE)
        XML2HTML(
                user_guide
                wsug
@@ -422,31 +423,23 @@ if(ENABLE_HTML_GUIDES)
                        wsug_html/index.html
                        wsug_html_chunked/index.html
        )
-       set_target_properties(user_guide_html PROPERTIES FOLDER "Docbook")
+       set_docbook_target_properties(user_guide_html)
        add_dependencies(user_guides user_guide_html)
 endif()
 
-if(ENABLE_PDF_GUIDES)
-       # To do:
-       # - Generate PDFs using AsciiDoctor.
-
-       XML2PDF(
-               user_guide
-               user-guide.pdf
-               user-guide.xml
-               custom_layer_pdf.xsl
-       )
+if(ASCIIDOCTOR_EXECUTABLE)
+       ASCIIDOCTOR2PDF(user-guide.asciidoc ${WSUG_SOURCE} ${WSUG_BUILT_DEPS})
 
        add_custom_target(
                user_guide_pdf
                DEPENDS
                        user-guide.pdf
        )
-       set_target_properties(user_guide_pdf PROPERTIES FOLDER "Docbook")
+       set_docbook_target_properties(user_guide_pdf)
        add_dependencies(user_guides user_guide_pdf)
 endif()
 
-if(ENABLE_CHM_GUIDES)
+if(WIN32 AND ASCIIDOCTOR_EXECUTABLE)
        XML2HHP(user_guide wsug user-guide.xml)
        HHP2CHM(user-guide.hhp)
        add_custom_target(
@@ -454,12 +447,12 @@ if(ENABLE_CHM_GUIDES)
                DEPENDS
                        user-guide.chm
        )
-       set_target_properties(user_guide_chm PROPERTIES FOLDER "Docbook")
+       set_docbook_target_properties(user_guide_chm)
        add_dependencies(user_guides user_guide_chm)
 endif()
 
 # Developer's Guide chain.
-if(ENABLE_HTML_GUIDES)
+if(ASCIIDOCTOR_EXECUTABLE AND XSLTPROC_EXECUTABLE)
        XML2HTML(
                developer_guide
                wsdg
@@ -481,28 +474,23 @@ if(ENABLE_HTML_GUIDES)
                        wsdg_html/index.html
                        wsdg_html_chunked/index.html
        )
-       set_target_properties(developer_guide_html PROPERTIES FOLDER "Docbook")
+       set_docbook_target_properties(developer_guide_html)
        add_dependencies(developer_guides developer_guide_html)
 endif()
 
-if(ENABLE_PDF_GUIDES)
-       XML2PDF(
-               developer_guide
-               developer-guide.pdf
-               developer-guide.xml
-               custom_layer_pdf.xsl
-       )
+if(ASCIIDOCTOR_EXECUTABLE)
+       ASCIIDOCTOR2PDF(developer-guide.asciidoc ${WSDG_SOURCE} ${WSDG_BUILT_DEPS})
 
        add_custom_target(
                developer_guide_pdf
                DEPENDS
                        developer-guide.pdf
        )
-       set_target_properties(developer_guide_pdf PROPERTIES FOLDER "Docbook")
+       set_docbook_target_properties(developer_guide_pdf)
        add_dependencies(developer_guides developer_guide_pdf)
 endif()
 
-if(ENABLE_CHM_GUIDES)
+if(WIN32 AND ASCIIDOCTOR_EXECUTABLE)
        XML2HHP(developer_guide wsdg developer-guide.xml)
        HHP2CHM(developer-guide.hhp)
        add_custom_target(
@@ -510,22 +498,23 @@ if(ENABLE_CHM_GUIDES)
                DEPENDS
                        developer-guide.chm
        )
-       set_target_properties(developer_guide_chm PROPERTIES FOLDER "Docbook")
+       set_docbook_target_properties(developer_guide_chm)
        add_dependencies(developer_guides developer_guide_chm)
 endif()
 
 # release_notes: release-notes.html release-notes.txt
 
-add_custom_target( release_notes_html DEPENDS ws.css release-notes.html )
-set_target_properties(release_notes_html PROPERTIES FOLDER "Docbook")
+add_custom_target( release_notes_html DEPENDS release-notes.html )
+set_docbook_target_properties(release_notes_html)
 add_custom_target( release_notes_txt DEPENDS release-notes.txt )
-set_target_properties(release_notes_txt PROPERTIES FOLDER "Docbook")
+set_docbook_target_properties(release_notes_txt)
 
-# Force serial execution so that separate a2x instances don't trip on each other
-add_dependencies ( release_notes_txt release_notes_html )
+# Force serial execution so that separate asciidoctor instances don't
+# trip on each other
+# add_dependencies ( release_notes_txt release_notes_html )
 
 add_custom_target( release_notes )
-set_target_properties(release_notes PROPERTIES FOLDER "Docbook")
+set_docbook_target_properties(release_notes)
 add_dependencies ( release_notes release_notes_txt release_notes_html )
 
 add_custom_target(
@@ -536,20 +525,11 @@ add_custom_target(
        DEPENDS
                ${CMAKE_CURRENT_BINARY_DIR}/release-notes.txt
 )
-set_target_properties(news PROPERTIES FOLDER "Docbook")
-
-if( ASCIIDOC_FOUND )
-       ASCIIDOC2HTML(
-               release-notes.html
-               release-notes.asciidoc
-               "${ASCIIDOC_CONF_FILES}"
-       )
+set_docbook_target_properties(news)
 
-       ASCIIDOC2TXT(
-               release-notes.txt
-               release-notes.asciidoc
-               "${ASCIIDOC_CONF_FILES}"
-       )
+if( ASCIIDOCTOR_FOUND )
+       ASCIIDOCTOR2HTML( release-notes.asciidoc )
+       ASCIIDOCTOR2TXT( release-notes.asciidoc )
 endif()
 
 #
index 08093f977eec19138d5dc291e647c3fd4f3d5a11..5f98865c228a5f6f1f929ba055449b1376510e6b 100644 (file)
@@ -1,19 +1,9 @@
 #
 # Make the "Wireshark User Guide" and "Wireshark Developer Guide"
 # in several formats.
-# See the Readme.txt file for instructions.
+# See the README.adoc file for instructions.
 #
 
-# formatting objects processor
-# Additional options to fop.
-# This needs to contain at least the argument '-Xmx256m'
-# fop executable is found in configure.ac.
-FOP_OPTS=-Xmx256m
-
-# Asciidoc converter
-A2X_HTML_OPTS="--stylesheet=ws.css"
-A2X_TEXT_OPTS=
-
 ############### YOU SHOULDN'T HAVE TO EDIT ANYTHING BELOW THIS LINE! ################
 
 WSUG_FILES =   \
@@ -239,7 +229,7 @@ WSUG_DIST = \
        user-guide.asciidoc     \
        attributes.asciidoc     \
        custom_layer_chm.xsl    \
-       custom_layer_pdf.xsl    \
+       custom_layer_single_html.xsl    \
        $(WSUG_FILES)           \
        $(WSUG_TOOLS_HELP_FILES)        \
        $(WSUG_GRAPHICS)        \
@@ -253,7 +243,7 @@ WSDG_DIST = \
        developer-guide.asciidoc        \
        attributes.asciidoc     \
        custom_layer_chm.xsl    \
-       custom_layer_pdf.xsl    \
+       custom_layer_single_html.xsl    \
        $(WSDG_FILES)           \
        $(WSDG_GRAPHICS)        \
        $(COMMON_FILES)         \
@@ -262,10 +252,7 @@ WSDG_DIST =        \
 WSDG_SOURCE = $(WSDG_GENERATED_SOURCE) $(WSDG_DIST)
 
 RELEASE_NOTES_SOURCE = \
-       release-notes.asciidoc  \
-       attributes.asciidoc     \
-       asciidoc.conf           \
-       asciidoctor-asciidoc.conf
+       release-notes.asciidoc
 
 CLEANFILES =   \
        *.chm                   \
@@ -335,61 +322,62 @@ COMMON_XSLTPROC_ARGS = \
 WSUG_XSLTPROC_ARGS = \
        --stringparam admon.graphics.path wsug_graphics/
 
-WSUG_PDF_XSLTPROC_ARGS = \
-               --stringparam img.src.path $(srcdir)/ \
-               --stringparam admon.graphics.path $(srcdir)/common_graphics/
-
 WSDG_XSLTPROC_ARGS = \
        --stringparam admon.graphics.path wsdg_graphics/
 
-WSDG_PDF_XSLTPROC_ARGS = \
-               --stringparam img.src.path $(srcdir)/ \
-               --stringparam admon.graphics.path $(srcdir)/common_graphics/
-
 SINGLE_XSLTPROC_ARGS = \
-       --nonet http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl
+       --nonet custom_layer_single_html.xsl
 
 CHUNKED_XSLTPROC_ARGS = \
+       --stringparam chunker.output.encoding UTF-8 \
        --nonet http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl
 
 HTMLHELP_XSLTPROC_ARGS = \
        --nonet custom_layer_chm.xsl
 #      --nonet http://docbook.sourceforge.net/release/xsl/current/htmlhelp/htmlhelp.xsl
 
-# Automatically generate .pdf files from .fo files
-# Suse needs FOP_OPTS, Debian needs JAVA_OPTS
-.fo.pdf:
-       FOP_OPTS=$(FOP_OPTS) JAVA_OPTS=$(FOP_OPTS) $(FOP) $< $@
+ASCIIDOCTOR_COMMON_ARGS = \
+       --require $(srcdir)/asciidoctor-macros/commaize-block.rb \
+       --require $(srcdir)/asciidoctor-macros/cve_idlink-inline-macro.rb \
+       --require $(srcdir)/asciidoctor-macros/ws_buglink-inline-macro.rb \
+       --require $(srcdir)/asciidoctor-macros/ws_salink-inline-macro.rb
+
+ASCIIDOCTOR_COMMON_COMMAND = TZ=UTC ASCIIDOCTORJ_OPTS="-Xmx800m ${ASCIIDOCTORJ_OPTS}" \
+       $(ASCIIDOCTOR) \
+       $(ASCIIDOCTOR_COMMON_ARGS)
+
+.asciidoc.pdf:
+       $(ASCIIDOCTOR_COMMON_COMMAND) --backend pdf --out-file $@ $<
+
+.asciidoc.xml:
+       $(ASCIIDOCTOR_COMMON_COMMAND) --backend docbook --out-file $@ $<
 
 docbook_all_local_targets =
 if BUILD_USER_GUIDE
 docbook_all_local_targets += wsug_html_chunked
-endif
 
 all-local: $(docbook_all_local_targets)
 
-all-html: wsug wsdg release-notes
+all-html: wsug wsdg release_notes
 
-all-pdf: wsug-pdf wsdg-pdf
+all-pdf: wsug_pdf wsdg_pdf
 
 # Wireshark User Guide
 wsug: wsug_html_chunked wsug_html
 
-wsug-pdf: wsug user-guide.pdf
+wsug_pdf: wsug user-guide.pdf
+
+user-guide.xml: user-guide.asciidoc $(WSUG_FILES)
 
-user-guide.xml: user-guide.asciidoc $(WSUG_FILES) $(WSUG_TOOLS_HELP_FILES)
-       $(A2X) --verbose \
-               --attribute=docinfo \
-               --asciidoc-opts="--conf-file=$(srcdir)/asciidoc.conf --conf-file=$(srcdir)/asciidoctor-asciidoc.conf" \
-               --no-xmllint \
-               --format=docbook \
-               --destination-dir=$(builddir) \
-               $<
+user-guide.pdf: user-guide.asciidoc $(WSUG_FILES)
+endif
 
 # create html single page file
+if BUILD_USER_GUIDE
 wsug_html: wsug_html/index.html
+endif
 
-wsug_html/index.html: $(WSUG_SOURCE)
+wsug_html/index.html: user-guide.xml
        @ echo --- WSUG - HTML SINGLE PAGE ---
        mkdir -p wsug_html/wsug_graphics/toolbar
        cp $(srcdir)/wsug_graphics/*.* wsug_html/wsug_graphics
@@ -401,9 +389,11 @@ wsug_html/index.html: $(WSUG_SOURCE)
        -chmod -R og+rX wsug_html
 
 # create html chunked page files
+if BUILD_USER_GUIDE
 wsug_html_chunked: wsug_html_chunked/index.html
+endif
 
-wsug_html_chunked/index.html: $(WSUG_SOURCE)
+wsug_html_chunked/index.html: user-guide.xml
        @ echo --- WSUG - HTML CHUNKED ---
        mkdir -p wsug_html_chunked/wsug_graphics/toolbar
        cp $(srcdir)/wsug_graphics/*.* wsug_html_chunked/wsug_graphics
@@ -414,14 +404,6 @@ wsug_html_chunked/index.html: $(WSUG_SOURCE)
                    $(WSUG_XSLTPROC_ARGS) $(CHUNKED_XSLTPROC_ARGS) $<
        -chmod -R og+rX wsug_html_chunked
 
-# create pdf file (through XSL-FO), portrait pages on PA4 (210 x 280 mm) "paper"
-# you will get lots of errors, but that's ok
-user-guide.fo: $(WSUG_SOURCE) custom_layer_pdf.xsl
-       @ echo --- WSUG - PDF PA4 PAPER ---
-       $(XSLTPROC) \
-               $(COMMON_XSLTPROC_ARGS) $(WSUG_PDF_XSLTPROC_ARGS) \
-               --nonet $(srcdir)/custom_layer_pdf.xsl $< > $@
-
 wsluarm: make-wsluarm.pl $(WSLUA_MODULES)
        mkdir -p wsluarm_src
        $(PERL) $(srcdir)/make-wsluarm.pl $(WSLUA_MODULES)
@@ -431,22 +413,20 @@ wsluarm: make-wsluarm.pl $(WSLUA_MODULES)
 # Wireshark Developer Guide
 wsdg: wsdg_html_chunked wsdg_html
 
-wsdg-pdf: wsdg developer-guide.pdf
+if BUILD_USER_GUIDE
+wsdg_pdf: developer-guide.pdf
+endif
 
 developer-guide.xml: developer-guide.asciidoc $(WSDG_FILES) wsluarm
-       $(A2X) --verbose \
-               --attribute=docinfo \
-               --attribute=build_dir=$(abs_builddir) \
-               --asciidoc-opts="--conf-file=$(srcdir)/asciidoc.conf --conf-file=$(srcdir)/asciidoctor-asciidoc.conf" \
-               --no-xmllint \
-               --format=docbook \
-               --destination-dir=$(builddir) \
-               $<
+
+developer-guide.pdf: developer-guide.asciidoc $(WSDG_FILES) wsluarm
 
 # create html single page file
+if BUILD_USER_GUIDE
 wsdg_html: wsdg_html/index.html
+endif
 
-wsdg_html/index.html: $(WSDG_SOURCE)
+wsdg_html/index.html: developer-guide.xml
        @ echo --- WSDG - HTML SINGLE PAGE ---
        mkdir -p wsdg_html/wsdg_graphics/toolbar
        cp $(srcdir)/wsdg_graphics/*.* wsdg_html/wsdg_graphics
@@ -459,9 +439,11 @@ wsdg_html/index.html: $(WSDG_SOURCE)
        -chmod -R og+rX wsdg_html
 
 # create html chunked page files
-wsdg_html_chunked: wsdg_html_chunked/index.html
+if BUILD_USER_GUIDE
+wsdg_html_chunked: developer-guide.xml wsdg_html_chunked/index.html
+endif
 
-wsdg_html_chunked/index.html: $(WSDG_SOURCE)
+wsdg_html_chunked/index.html: developer-guide.xml
        @ echo --- WSDG - HTML CHUNKED ---
        mkdir -p wsdg_html_chunked/wsdg_graphics/toolbar
        cp $(srcdir)/wsdg_graphics/*.* wsdg_html_chunked/wsdg_graphics
@@ -473,37 +455,30 @@ wsdg_html_chunked/index.html: $(WSDG_SOURCE)
                $(WSDG_XSLTPROC_ARGS) $(CHUNKED_XSLTPROC_ARGS) $<
        -chmod -R og+rX wsdg_html_chunked
 
-# create pdf file (through XSL-FO), portrait pages on PA4 (210 x 280 mm) "paper"
-# you will get lot's of errors, but that's ok
-developer-guide.fo: $(WSDG_SOURCE) custom_layer_pdf.xsl
-       @ echo --- WSDG - PDF PA4 PAPER ---
-       $(XSLTPROC) \
-                   $(COMMON_XSLTPROC_ARGS) $(WSDG_PDF_XSLTPROC_ARGS) \
-                   --path .:wsluarm_src:$(srcdir) \
-                   --nonet $(srcdir)/custom_layer_pdf.xsl $< > $@
-
 # Release notes
-if HAVE_A2X_TEXT
-release-notes: release-notes.html release-notes.txt
-else
-release-notes: release-notes.html
+if HAVE_ASCIIDOCTOR
+release_note_deps = release-notes.html
+if HAVE_LYNX
+release_note_deps += release-notes.txt
+endif
 endif
+release_notes: $(release_note_deps)
 
 # create html single page file
 release-notes.html: $(RELEASE_NOTES_SOURCE)
        @ echo --- RELEASE NOTES - HTML ---
-       $(A2X) --format=xhtml $(A2X_HTML_OPTS) \
-               --destination-dir=$(builddir) \
+       $(ASCIIDOCTOR_COMMON_COMMAND) \
+               --backend html \
+               --out-file $(builddir)/release-notes.html \
                $(srcdir)/release-notes.asciidoc
 
 # create txt single page file (through HTML)
-release-notes.txt: $(RELEASE_NOTES_SOURCE)
+release-notes.txt: release-notes.html
        @ echo --- RELEASE NOTES - TXT ---
-       TZ=UTC $(A2X) --format=text @A2X_LYNX@ $(A2X_TEXT_OPTS) \
-               --xsltproc-opts "--stringparam generate.toc \"article nop\"" \
-               --destination-dir=$(builddir) \
-               $(srcdir)/release-notes.asciidoc && \
-               mv release-notes.text $@
+       $(LYNX) \
+               -dump \
+               $(builddir)/release-notes.html \
+               > $(builddir)/release-notes.txt
 
 news: release-notes.txt
        cp release-notes.txt ../NEWS
@@ -526,5 +501,5 @@ EXTRA_DIST = \
        $(WSDG_DIST)            \
        $(RELEASE_NOTES_SOURCE) \
        make-wsluarm.pl         \
-       README.txt              \
+       README.adoc             \
        CMakeLists.txt
similarity index 57%
rename from docbook/README.txt
rename to docbook/README.adoc
index dffcfc6e6820d1cded346a7dd0dba6e26ac38866..aa63ae0124b721095866cb8b43fcc52bd8dd623a 100644 (file)
@@ -1,99 +1,99 @@
-= Introduction =
+= Introduction
 
 This directory contains the source files needed to build the:
 
- - Wireshark User's guide
- - Wireshark Developer's Guide
- - Release notes (NEWS)
- - Lua Reference
+- Wireshark User’s Guide
+- Wireshark Developer’s Guide
+- Release notes (NEWS)
+- Lua Reference
 
-To build everything, just run `make` or `msbuild all_guides.vcxproj`.
-Requirements are listed below.
+To build everything, build the `all_guides` target, e.g. `ninja
+all_guides` or `msbuild all_guides.vcxproj`. Requirements are listed
+below.
 
-The guides and release notes are written in AsciiDoc (http://asciidoc.org),
-but use many Asciidoctor (http://asciidoctor.org/) markup extensions which
-are provided in asciidoctor-asciidoc.conf. The documentation toolchain may
-switch exclusively to Asciidoctor at some point in the future. See the
-AsciiDoctor section at the end of this document for details.
+The guides and release notes are written in
+http://asciidoctor.org/docs/asciidoc-syntax-quick-reference/[Asciidoctor syntax].
+For more information see http://asciidoctor.org.
 
-To get HTML, PDF or other output formats, conversions are done using XSL
-stylesheets, which provides a flexible way for these conversions.
+Conversions from Asciidoctor markup to each of our supported output
+formats is done via the following steps:
 
-By default the Makefile generates HTML in single page and multiple (chunked)
-formats and two PDF's.
+- HTML: Asciidoctor → DocBook XML → xsltproc + DocBook XSL
+- Chunked HTML: Asciidoctor → DocBook XML → xsltproc + DocBook XSL
+- PDF: Asciidoctor
+- HTMLHelp: Asciidoctor → DocBook XML → xsltproc + DocBook XSL → HHC
+- Text: [HTML output] → elinks
 
-Requirements:
--------------
+= Requirements
 
-AsciiDoc
---------
-Text documentation format and conversion suite:
-http://asciidoc.org/
+Ultimately we'd like to reduce the toolchain requirements to AsciidoctorJ
+alone, but that's not yet possible. Additional tooling is required for
+the HTML,
 
-DocBook XML DTD
----------------
-DocBook "official" XML DTD V4.5:
-http://www.oasis-open.org/docbook/xml/
-(available as a package for Linux / Cygwin)
+== AsciidoctorJ (recommended) or Asciidoctor
 
-DocBook XSL
------------
-The "official" XSL stylesheets from Norman Walsh:
-http://docbook.sourceforge.net/
-(available as a package for Linux / Cygwin)
+Text markup format and publishing toolchain:
+http://asciidoctor.org/
 
-xsltproc
---------
-The XSL processor xsltproc. Part of libxslt:
-http://xmlsoft.org/xslt/
-Available as a package for Linux / Cygwin.
-Supplied with Mac OS X Panther and later.
+AsciidoctorJ is a self-contained bundle which includes Asciidoctor and
+JRuby. It can be installed via Chocolatey on Windows, Homebrew on macOS,
+or a .zip extraction anywhere
+(https://bintray.com/asciidoctor/maven/asciidoctorj).
 
-FOP processor (for PDF generation only)
----------------------------------------
-FOP processor from the apache project:
-http://xml.apache.org/fop/
+== DocBook XML and XSL
 
-FOP is a Java program, so you need to have a Java environment installed.
-The makefiles look for fop-2.1 in the docbook directory. You can change
-this location by setting the FOP environment variable.
+Converting from DocBook to HTML and CHM requires the DocBook DTD
+(http://www.sagehill.net/docbookxsl/ToolsSetup.html) and DocBook
+stylesheets
+(http://www.sagehill.net/docbookxsl/InstallStylesheets.html).
+These are available via installable packages on most Linux distributions,
+and Homebrew.
 
-FOP might return an OutOfMemoryException. You can limit its memory usage
-by adding " -Xmx256m" to the FOP_OPTS environment variable. The Windows
-makefile does this by default.
+== xsltproc
 
-Hyphenation Patterns
---------------------
-Hyphenation patterns for FOP can be found at
-http://offo.sourceforge.net/hyphenation/. Different pattern files have
-different licenses. The English patterns may have restrictions on
-commercial use.
+http://xmlsoft.org/xslt/[xsltproc] converts DocBook XML to various
+formats based on XSL stylesheets. It either ships as part of the
+operating system or is available via an installable package on
+most Linux distributions.
 
+== Lynx
 
-AsciiDoc Notes
---------------
+https://invisible-island.net/lynx/[Lynx] is a text based web browser which can
+convert HTML to plain text. We may add w3m, elinks, or other alternatives
+in the future.
 
-AsciiDoc can use either w3m (default) or Lynx for plain text output. We use
-AsciiDoc for the Developer's Guide, User's Guide, and for the release notes.
-Lynx is used to render the official plaintext release announcements.
+== HTML Help Workshop (Windows only)
 
-The AsciiDoc files have been converted from DocBook. In a lot of cases the
-markup is wrong, inconsistent, or both. Use the following markup conventions
-for any new or revised text:
+The HTML Help compiler is part of the
+http://www.microsoft.com/en-us/download/details.aspx?id=21138[HTML Help Workshop]
+from Microsoft. It is used to generate the documentation shipped with
+the Windows installers.
 
-- Window and dialog box names should be in ``curly quotes''.
+= Asciidoctor Markup
 
-- Use Asciidoctor compatibility macros for buttons, keys, and menus:
+The User’s and Developer’s Guides were originally written in DocBook and
+were later converted to http://asciidoc.org/[AsciiDoc]. We subsequently
+switched from AsciiDoc to Asciidoctor. As a result we currently use
+http://asciidoctor.org/docs/migration/[compat mode], but may switch
+to Asciidoctor’s modern markup at a later date.
 
-  The button:[Start] button
-  Press kbd:[Shift+Ctrl+P] to open the preferences dialog.
-  Select menu:File[Open] from the main menu.
+Please use the following conventions when writing documentation:
 
-  This ensures that UI elements are shown consistently and lets us apply styles
-  to each type of element.
+- Window and dialog box names should be in “curly quotes”.
 
-- Command line examples should reflect the OS:
+- Use Asciidoctor macros for buttons, keys, and menus. Note that these
+  are currently experimental:
+
+-- The button:[Start] button
+-- Press kbd:[Shift+Ctrl+P] to open the preferences dialog.
+-- Select menu:File[Open] from the main menu.
+
+This ensures that UI elements are shown consistently and lets us apply styles
+to each type of element.
 
+- Command line examples should reflect the OS:
++
++++
 ----
 $ echo Linux and UNIX
 ----
@@ -101,28 +101,55 @@ $ echo Linux and UNIX
 ----
 C:\> echo Windows
 ----
++++
 
 Admonitions ([NOTE], [TIP], and [WARNING]) can be used to highlight important
 information. Keep in mind that they interrupt the flow of text by design. Too
 many (especially in a row) are distracting and annoying.
 
+= HTML Help Alternatives
 
-Lynx
-----
-Text based web browser which can convert HTML to plain text.
-(Alternatives: w3m and elinks)
+Ideally we would ship documentation with Wireshark that is pleasant to
+read, browsable, and searchable. Unfortunately we don't have an easy way
+to do this. The closest we've been able to come is by shipping an HTML
+Help (.chm) file on Windows. However, HTML Help a) is limited to Windows,
+b) crusty on normal displays, and c) really crusty on HiDPI displays.
+
+The following alternative formats are available, each with advantages
+and disadvantages:
+
+== WebHelp
+
+https://en.wikipedia.org/wiki/Web_help[WebHelp] has three main
+dependencies:
+
+- DocBook XSL, including...
+- webhelpindexer.jar
+- The user's local web browser
+
+This format generates both HTML pages and JavaScript, which might not run
+reliably on end user machines.
+
+== PDF
 
-dblatex
--------
-DocBook to LaTeX converter. Required for AsciiDoc PDF conversion on Win32.
+PDF output is page oriented, with static page sizes. This _usually_ isn't
+a problem with modern reader software. However it doesn't look like we
+can reliably load a PDF file and jump to specific section on some
+platforms. For example, loading +++file:///path/to/user_guide.pdf#location+++
+works in Firefox & Chrome, but not in Safari, Preview, or Internet Explorer.
 
-Win32 only: HTML help compiler (for .chm generation only)
----------------------------------------------------------
-HTML Help Compiler (hhc.exe) from Microsoft:
-http://www.microsoft.com/en-us/download/details.aspx?id=21138
+== Qt Help
+
+Qt provides an extensive http://doc.qt.io/qt-5/qthelp-framework.html[help system].
+However, to use it we need to generate a Qt Help Project (.qhp) file,
+which isn't currently supported by Asciidoctor or via DocBook XSL.
+
+The default help application (Qt Assistant) is ugly. We'd probably want
+to write our own help viewer app or integrate help directly via
+QHelpEngine.
+
+= Packages For Windows
 
-Packages for Win32
-------------------
 Installing the asciidoc package will pull in almost all the other required Cygwin packages.
 You may need to run "build-docbook-catalog" from a Cygwin bash prompt in order to register your catalog properly.
 
@@ -245,29 +272,3 @@ Using the prefix wsdg_ instead of wsug_ will build the same targets but for the
 Wireshark Developer's Guide.
 
 The makefile is written to be run with make on UNIX/Linux platforms.
-
-AsciiDoctor
------------
-
-At the time of this writing (October 2017) the Asciidoctor project is
-much more active than AsciiDoc. It also supports extra features
-including additional markup and diagrams. At some point it might be
-worth the effort to migrate to Asciidoctor. To do so we'd have to do the
-following at a minimum:
-
-- Require Ruby + Asciidoctor or Java + AsciidoctorJ to build the
-  documentation.
-
-- Port the macros in asciidoc.conf to Asciidoctor extensions.
-  https://github.com/asciidoctor/asciidoctor-extensions-lab
-
-- Choose a "compat" mode: http://asciidoctor.org/docs/migration/
-
-Targets
--------
-
-Asciidoctor alone doesn't entirely cover our various build targets. It
-can generate single-page HTML, Docbook, PDF, Epub3, and a few other
-formats. Our current toolchain generates single-page HTML, chunked HTML,
-text, HTMLHelp, and PDF output. We would still depend on DocBook, XSLT,
-and HTMLHelp for most targets.
diff --git a/docbook/asciidoctor-asciidoc.conf b/docbook/asciidoctor-asciidoc.conf
deleted file mode 100644 (file)
index 5d6c754..0000000
+++ /dev/null
@@ -1,401 +0,0 @@
-# This file is an AsciiDoc configuration file that makes
-# AsciiDoc conform with Asciidoctor's fixes and customizations.
-#
-# Place this file in the same directory as your AsciiDoc document and the
-# AsciiDoc processor (asciidoc) will automatically use it.
-
-# Copied from from https://raw.githubusercontent.com/asciidoctor/asciidoctor/master/compat/asciidoc.conf
-# AsciiDoctor is available under the MIT license.
-
-[miscellaneous]
-newline=\n
-
-[attributes]
-# make html5 the default html backend
-backend-alias-html=html5
-apostrophe='
-asterisk=*
-backtick=`
-brvbar=&#166;
-caret=^
-# plus introduced in AsciiDoc 8.6.9
-plus=&#43;
-space=" "
-tilde=~
-cpp=C++
-user-home={eval:os.path.expanduser('~')}
-vbar=|
-# NOTE use -a no-inline-literal to set compat-mode to default when using AsciiDoc Python
-ifndef::no-inline-literal[]
-compat-mode=legacy
-endif::[]
-
-[replacements]
-# right single quote
-(?<!\\)`'=&#8217;
-# escaped right single quote
-\\`'=`'
-
-# Disabled for now.
-# Appears to be incompatible with Cygwin's version of AsciiDoc (8.6.3)
-#[quotes]
-## disable single quotes as constrained formatting marks for emphasis
-## this change can also be made in the document using the attribute entry :quotes.':
-#ifdef::compat-mode[]
-#'=
-#+=
-#++=
-#`=
-#``=#monospaced
-#`|`=monospaced
-#\##=#mark
-#\#=mark
-#endif::[]
-
-# enables markdown-style headings
-[titles]
-sect0=^(=|#) +(?P<title>[\S].*?)(?: +\1)?$
-sect1=^(==|##) +(?P<title>[\S].*?)(?: +\1)?$
-sect2=^(===|###) +(?P<title>[\S].*?)(?: +\1)?$
-sect3=^(====|####) +(?P<title>[\S].*?)(?: +\1)?$
-sect4=^(=====|#####) +(?P<title>[\S].*?)(?: +\1)?$
-sect5=^(======|######) +(?P<title>[\S].*?)(?: +\1)?$
-
-# Disable subs on pass block by default
-[blockdef-pass]
-subs=none
-
-# enables fenced code blocks
-# FIXME I haven't sorted out yet how to do syntax highlighting
-[blockdef-fenced-code]
-delimiter=^```(?:\w+(?:,numbered)?)?$
-ifdef::language[]
-style=source
-template::[source-filter-style]
-endif::language[]
-ifndef::language[]
-template=listingblock
-subs=verbatim
-posattrs=style
-endif::language[]
-
-# enables blockquotes to be defined using two double quotes
-[blockdef-air-quote]
-template::[blockdef-quote]
-delimiter=^""$
-
-# markdown-style blockquote (paragraph only)
-# FIXME does not strip leading > on subsequent lines
-[paradef-markdown-quote]
-delimiter=(?s)>\s*(?P<text>\S.*)
-style=quote
-quote-style=template="quoteparagraph",posattrs=("style","attribution","citetitle")
-
-# fix regex for callout list to require number; also makes markdown-style blockquote work
-[listdef-callout]
-posattrs=style
-delimiter=^<?(?P<index>\d+>) +(?P<text>.+)$
-type=callout
-tags=callout
-style=arabic
-
-# enables literal block to be used as source block
-[blockdef-literal]
-template::[source-filter-style]
-
-# enables source block when source-highlighter is not defined
-ifndef::source-highlighter[]
-[source-filter-style]
-source-style=template="listingblock",subs=("specialcharacters","callouts"),posattrs=("style","language","src_numbered","src_tab")
-
-[paradef-default]
-template::[source-filter-style]
-
-[paradef-literal]
-template::[source-filter-style]
-
-[blockdef-open]
-template::[source-filter-style]
-
-[blockdef-listing]
-template::[source-filter-style]
-endif::source-highlighter[]
-
-[tabledef-csv]
-template::[tabledef-default]
-delimiter=^,={3,}$
-format=csv
-
-[tabledef-dsv]
-template::[tabledef-default]
-delimiter=^:={3,}$
-format=dsv
-
-[macros]
-ifdef::no-inline-literal[]
-(?su)\\?\+\+(?P<passtext>.*?)\+\+=pass[specialcharacters]
-(?su)(?<![+\w])(\\?\+(?P<passtext>\S|\S.*?\S)\+)(?![+\w])=pass[specialcharacters]
-endif::no-inline-literal[]
-
-# additional callout match behind line comments
-#(?://|#|;;) ?\((?P<index>\d+)\)=callout
-# additional callout match for XML
-[\\]?&lt;!--(?P<index>\d+)--&gt;=callout
-
-# --- or *** or ___ or - - - or * * * or _ _ _ (in addition to the built-in ''')
-^ {0,3}([-\*_])( *)\1\2\1$=#ruler
-
-# btn:[Save]
-(?su)(?<!\w)\\?btn:\[(?P<attrlist>(?:\\\]|[^\]])+?)\]=button
-
-# kbd:[F11] or kbd:[Ctrl+T] or kbd:[Ctrl,T]
-(?su)(?<!\w)\\?kbd:\[(?P<attrlist>(?:\\\]|[^\]])+?)\]=keyboard
-
-# menu:Search[] or menu:File[New...] or menu:View[Page Style, No Style]
-# TODO implement menu:View[Page Style > No Style] syntax
-(?su)(?<!\w)[\\]?(?P<name>menu):(?P<target>\w|\w.*?\S)?\[(?P<attrlist>.*?)\]=
-
-ifdef::basebackend-html[]
-
-[sect5]
-<div class="sect5{style? {style}}{role? {role}}">
-<h6{id? id="{id}"}>{title}</h6>
-|
-</div>
-
-[button-inlinemacro]
-<b class="button">{1}</b>
-
-[keyboard-inlinemacro]
-{set2:keys:{eval:re.split(r'(?<!\+ |.\+)\+', '{1}')}}
-{2%}{eval:len({keys}) == 1}<kbd>{1}</kbd>
-{2%}{eval:len({keys}) == 2}<kbd class="combo"><kbd>{eval:{keys}[0].strip()}</kbd>+<kbd>{eval:{keys}[1].strip()}</kbd></kbd>
-{2%}{eval:len({keys}) == 3}<kbd class="combo"><kbd>{eval:{keys}[0].strip()}</kbd>+<kbd>{eval:{keys}[1].strip()}</kbd>+<kbd>{eval:{keys}[2].strip()}</kbd></kbd>
-{2#}{3%}<kbd class="combo"><kbd>{1}</kbd>+<kbd>{2}</kbd></kbd>
-{3#}<kbd class="combo"><kbd>{1}</kbd>+<kbd>{2}</kbd>+<kbd>{3}</kbd></kbd>
-
-[menu-inlinemacro]
-{1%}<span class="menu">{target}</span>
-{1#}{2%}<span class="menuseq"><span class="menu">{target}</span>&#160;&#9656; <span class="menuitem">{1}</span></span>
-{2#}{3%}<span class="menuseq"><span class="menu">{target}</span>&#160;&#9656; <span class="submenu">{1}</span>&#160;&#9656; <span class="menuitem">{2}</span></span>
-{3#}<span class="menuseq"><span class="menu">{target}</span>&#160;&#9656; <span class="submenu">{1}</span>&#160;&#9656; <span class="submenu">{2}</span>&#160;&#9656; <span class="menuitem">{3}</span></span>
-
-[literal-inlinemacro]
-<code>{passtext}</code>
-
-[tags]
-emphasis=<em{1? class="{1}"}>|</em>
-strong=<strong{1? class="{1}"}>|</strong>
-monospaced=<code{1? class="{1}"}>|</code>
-superscript=<sup{1? class="{1}"}>|</sup>
-subscript=<sub{1? class="{1}"}>|</sub>
-mark={1=<mark>}{1?<span class="{1}">}|{1?</span>}{1=</mark>}
-
-[monospacedwords]
-<code>{words}</code>
-
-ifdef::linkattrs[]
-[http-inlinemacro]
-<a href="{name}:{target}"{id? id="{id}"}{role? class="{role}"}{window? target="{window}"}>{1={name}:{target}}</a>
-[https-inlinemacro]
-<a href="{name}:{target}"{id? id="{id}"}{role? class="{role}"}{window? target="{window}"}>{1={name}:{target}}</a>
-[ftp-inlinemacro]
-<a href="{name}:{target}"{id? id="{id}"}{role? class="{role}"}{window? target="{window}"}>{1={name}:{target}}</a>
-[file-inlinemacro]
-<a href="{name}:{target}"{id? id="{id}"}{role? class="{role}"}{window? target="{window}"}>{1={name}:{target}}</a>
-[irc-inlinemacro]
-<a href="{name}:{target}"{id? id="{id}"}{role? class="{role}"}{window? target="{window}"}>{1={name}:{target}}</a>
-[mailto-inlinemacro]
-<a href="mailto:{target}"{id? id="{id}"}{role? class="{role}"}{window? target="{window}"}>{1={target}}</a>
-[link-inlinemacro]
-<a href="{target}"{id? id="{id}"}{role? class="{role}"}{window? target="{window}"}>{1={target}}</a>
-endif::linkattrs[]
-
-[listtags-numbered]
-list=<div class="olist{style? {style}}{compact-option? compact}{role? {role}}"{id? id="{id}"}>{title?<div class="title">{title}</div>}<ol class="{style}"{style@loweralpha: type="a"}{style@lowerroman: type="i"}{style@upperalpha: type="A"}{style@upperroman: type="I"}{start? start="{start}"}>|</ol></div>
-
-[tabletags-monospaced]
-paragraph=<p class="tableblock"><code>|</code></p>
-
-[sect0]
-<h1{id? id="{id}"} class="sect0">{title}</h1>
-|
-
-# support for document title in embedded documents
-ifeval::[not config.header_footer]
-[preamble]
-<h1>{title={doctitle}}</h1>{set:title-rendered:}
-<div id="preamble">
-<div class="sectionbody">
-|
-</div>
-{toc,toc2#}{toc-placement$preamble:}{template:toc}
-</div>
-
-[sect1]
-{title-rendered%}<h1>{doctitle}</h1>
-<div class="sect1{style? {style}}{role? {role}}">
-<h2{id? id="{id}"}>{numbered?{sectnum} }{title}</h2>
-<div class="sectionbody">
-|
-</div>
-</div>
-endif::[]
-
-# override to add the admonition name to the class attribute of the outer element
-[admonitionblock]
-<div class="admonitionblock {name}{role? {role}}{unbreakable-option? unbreakable}"{id? id="{id}"}>
-<table><tr>
-<td class="icon">
-{data-uri%}{icons#}<img src="{icon={iconsdir}/{name}.png}" alt="{caption}">
-{data-uri#}{icons#}<img alt="{caption}" src="data:image/png;base64,
-{data-uri#}{icons#}{sys:"{python}" -u -c "import base64,sys; base64.encode(sys.stdin,sys.stdout)" < "{eval:os.path.join(r"{indir={outdir}}",r"{icon={iconsdir}/{name}.png}")}"}">
-{icons%}<div class="title">{caption}</div>
-</td>
-<td class="content">
-<div class="title">{title}</div>
-|
-</td>
-</tr></table>
-</div>
-
-# modified so that:
-# a. imagesdir is only prepended if target is not a uri or absolute path (relative path only)
-# b. automatic alt text is calculated from basename of target without extension
-# note that the escaped_target attribute must be set in order to use a uri in the conditional attribute reference
-[image-inlinemacro]
-<span class="image{role? {role}}"{float? style="float: {float}"}>{set2:escaped_target:{eval:'{target}'.replace(':','\:')}}
-<a class="image" href="{link}">
-{data-uri%}<img src="{target@^(/|https?\://).*:{escaped_target}:{imagesdir?{imagesdir}}{imagesdir?/}{escaped_target}}" alt="{alt={eval:os.path.splitext(os.path.basename('{target}'))[0]}}"{width? width="{width}"}{height? height="{height}"}{title? title="{title}"}>
-{data-uri#}<img alt="{alt={target}}"{width? width="{width}"}{height? height="{height}"}{title? title="{title}"}
-{data-uri#}{sys:"{python}" -u -c "import mimetypes,base64,sys; print 'src=\"data:'+mimetypes.guess_type(r'{target}')[0]+';base64,'; base64.encode(sys.stdin,sys.stdout)" < "{eval:os.path.join(r"{indir={outdir}}",r"{imagesdir=}",r"{target}")}"}">
-{link#}</a>
-</span>
-
-# modified so that:
-# a. imagesdir is only prepended if target is not a uri or absolute path (relative path only)
-# b. automatic alt text is calculated from basename of target without extension
-# note that the escaped_target attribute must be set in order to use a uri in the conditional attribute reference
-[image-blockmacro]
-<div class="imageblock{style? {style}}{role? {role}}{unbreakable-option? unbreakable}"{id? id="{id}"}{align? style="text-align:{align};"}{float? style="float: {float}"}>
-<div class="content">{set2:escaped_target:{eval:'{target}'.replace(':','\:')}}
-<a class="image" href="{link}">
-{data-uri%}<img src="{target@^(/|https?\://).*:{escaped_target}:{imagesdir?{imagesdir}}{imagesdir?/}{escaped_target}}" alt="{alt={eval:os.path.splitext(os.path.basename('{target}'))[0]}}"{width? width="{width}"}{height? height="{height}"}>
-{data-uri#}<img alt="{alt={target}}"{width? width="{width}"}{height? height="{height}"}
-{data-uri#}{sys:"{python}" -u -c "import mimetypes,base64,sys; print 'src=\"data:'+mimetypes.guess_type(r'{target}')[0]+';base64,'; base64.encode(sys.stdin,sys.stdout)" < "{eval:os.path.join(r"{indir={outdir}}",r"{imagesdir=}",r"{target}")}"}">
-{link#}</a>
-</div>
-<div class="title">{caption={figure-caption} {counter:figure-number}. }{title}</div>
-</div>
-
-# a common template for emitting the attribute for a quote or verse block
-# don't output attribution div if attribution or citetitle are both empty
-[attribution]
-{attribution,citetitle#}<div class="attribution">
-&#8212; {attribution}{citetitle?<br>}
-<cite>{citetitle}</cite>
-{attribution,citetitle#}</div>
-
-# override to use blockquote element for content and cite element for cite title
-[quoteblock]
-<div class="quoteblock{role? {role}}{unbreakable-option? unbreakable}"{id? id="{id}"}>
-<div class="title">{title}</div>
-<blockquote>
-|
-</blockquote>
-template::[attribution]
-</div>
-
-# override to use cite element for cite title
-[verseblock]
-<div class="verseblock{role? {role}}{unbreakable-option? unbreakable}"{id? id="{id}"}>
-<div class="title">{title}</div>
-<pre class="content">
-|
-</pre>
-template::[attribution]
-</div>
-
-# override tabletags to support cellbgcolor
-[tabletags-default]
-headdata=<th class="tableblock halign-{halign=left} valign-{valign=top}"{colspan@1:: colspan="{colspan}"}{rowspan@1:: rowspan="{rowspan}"}{cellbgcolor? style="background-color:{cellbgcolor};"}>|</th>
-bodydata=<td class="tableblock halign-{halign=left} valign-{valign=top}"{colspan@1:: colspan="{colspan}"}{rowspan@1:: rowspan="{rowspan}"}{cellbgcolor? style="background-color:{cellbgcolor};"}>|</td>
-
-# override header cells to use th
-[tabletags-header]
-bodydata=<th class="tableblock halign-{halign=left} valign-{valign=top}" {colspan@1::colspan="{colspan}" }{rowspan@1::rowspan="{rowspan}" }>|</th>
-paragraph=<p class="tableblock">|</p>
-
-[toc]
-<div id="toc">
-<div id="toctitle">{toc-title}</div>
-ifdef::toc2[]
-<script type="text/javascript">
-document.body.className += ' toc2';
-document.getElementById('toc').className = 'toc2';
-</script>
-endif::toc2[]
-<noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
-</div>
-
-endif::basebackend-html[]
-
-# Override docinfo to support subtitle
-ifdef::basebackend-docbook[]
-
-[sect5]
-<section{id? id="{id}"}{role? role="{role}"}{reftext? xreflabel="{reftext}"}>
-<title>{title}</title>
-|
-</section>
-
-[tags]
-monospaced=<literal{1? role="{1}"}>|</literal>
-subscript=<subscript{1? role="{1}"}>|</subscript>
-superscript=<superscript{1? role="{1}"}>|</superscript>
-
-[button-inlinemacro]
-<guibutton>{1}</guibutton>
-
-[keyboard-inlinemacro]
-{set2:keys:{eval:re.split(r'(?<!\+ |.\+)\+', '{1}')}}
-{2%}{eval:len({keys}) == 1}<keycap>{1}</keycap>
-{2%}{eval:len({keys}) == 2}<keycombo><keycap>{eval:{keys}[0].strip()}</keycap><keycap>{eval:{keys}[1].strip()}</keycap></keycombo>
-{2%}{eval:len({keys}) == 3}<keycombo><keycap>{eval:{keys}[0].strip()}</keycap><keycap>{eval:{keys}[1].strip()}</keycap><keycap>{eval:{keys}[2].strip()}</keycap></keycombo>
-{2#}{3%}<keycombo><keycap>{1}</keycap><keycap>{2}</keycap></keycombo>
-{3#}<keycombo><keycap>{1}</keycap><keycap>{2}</keycap><keycap>{3}</keycap></keycombo>
-
-[menu-inlinemacro]
-{1%}<guimenu>{target}</guimenu>
-{1#}{2%}<menuchoice><guimenu>{target}</guimenu> <guimenuitem>{1}</guimenuitem></menuchoice>
-{2#}{3%}<menuchoice><guimenu>{target}</guimenu> <guisubmenu>{1}</guisubmenu> <guimenuitem>{2}</guimenuitem></menuchoice>
-{3#}<menuchoice><guimenu>{target}</guimenu> <guisubmenu>{1}</guisubmenu> <guisubmenu>{2}</guisubmenu> <guimenuitem>{3}</guimenuitem></menuchoice>
-
-# override tabletags to support cellbgcolor
-[tabletags-default]
-headdata=<entry align="{halign}" valign="{valign}"{colspan@1:: namest="col_{colstart}" nameend="col_{colend}"}{morerows@0:: morerows="{morerows}"}>{cellbgcolor?<?dbfo bgcolor="{cellbgcolor}"?>}|</entry>
-bodydata=<entry align="{halign}" valign="{valign}"{colspan@1:: namest="col_{colstart}" nameend="col_{colend}"}{morerows@0:: morerows="{morerows}"}>{cellbgcolor?<?dbfo bgcolor="{cellbgcolor}"?>}|</entry>
-
-[docinfo]
-ifndef::notitle[]
-{set2:subtitle_offset:{eval:'{doctitle}'.rfind(': ')}}
-{eval:{subtitle_offset} != -1}<title>{eval:'{doctitle}'[0:{subtitle_offset}]}</title>
-{eval:{subtitle_offset} != -1}<subtitle>{eval:'{doctitle}'[{subtitle_offset} + 2:]}</subtitle>
-{eval:{subtitle_offset} < 0}<title>{doctitle}</title>
-endif::notitle[]
-<date>{revdate}</date>
-# To ensure valid articleinfo/bookinfo when there is no AsciiDoc header.
-{doctitle%}{revdate%}<date>{docdate}</date>
-{authored#}<author>
-<firstname>{firstname}</firstname>
-<othername>{middlename}</othername>
-<surname>{lastname}</surname>
-<email>{email}</email>
-{authored#}</author>
-<authorinitials>{authorinitials}</authorinitials>
-<revhistory><revision>{revnumber?<revnumber>{revnumber}</revnumber>}<date>{revdate}</date>{authorinitials?<authorinitials>{authorinitials}</authorinitials>}{revremark?<revremark>{revremark}</revremark>}</revision></revhistory>
-{docinfo1,docinfo2#}{include:{docdir}/docinfo.xml}
-{docinfo,docinfo2#}{include:{docdir}/{docname}-docinfo.xml}
-<orgname>{orgname}</orgname>
-
-endif::basebackend-docbook[]
diff --git a/docbook/asciidoctor-macros/README.adoc b/docbook/asciidoctor-macros/README.adoc
new file mode 100644 (file)
index 0000000..cc5d64e
--- /dev/null
@@ -0,0 +1,5 @@
+Asciidoctor macros.
+
+These files are available under the MIT license to match the
+https://github.com/asciidoctor/asciidoctor-extensions-lab[Asciidoctor Extensions Lab]
+and Asciidoctor itself.
diff --git a/docbook/asciidoctor-macros/commaize-block.rb b/docbook/asciidoctor-macros/commaize-block.rb
new file mode 100644 (file)
index 0000000..aff6a3c
--- /dev/null
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: MIT
+RUBY_ENGINE == 'opal' ? (require 'commaize-block/extension') : (require_relative 'commaize-block/extension')
+
+Extensions.register do
+  block CommaizeBlock
+end
diff --git a/docbook/asciidoctor-macros/commaize-block/extension.rb b/docbook/asciidoctor-macros/commaize-block/extension.rb
new file mode 100644 (file)
index 0000000..9b37823
--- /dev/null
@@ -0,0 +1,46 @@
+# SPDX-License-Identifier: MIT
+require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
+
+include Asciidoctor
+
+# An extension that converts a list of lines to an inline Oxford comma-separated list.
+#
+# Usage
+#
+#   [commaize]
+#   --
+#   item1
+#   item2
+#   item3
+#   --
+#
+class CommaizeBlock < Extensions::BlockProcessor
+  use_dsl
+
+  named :commaize
+  on_contexts :paragraph, :open
+  # XXX What's the difference between text, raw, simple, verbatim, etc?
+  parse_content_as :simple
+
+  def process parent, reader, attrs
+    lines = reader.lines
+    sort = attrs.fetch('sort', 'true') == 'true'
+
+    lines.reject { |line| line.empty? }
+    lines = lines.collect(&:strip)
+
+    if sort
+      lines = lines.sort_by { |line| line.downcase }
+    end
+
+    if lines.length < 2
+      create_paragraph parent, lines, attrs
+    elsif lines.length == 2
+      create_paragraph parent, (lines.join(" and ")), attrs
+    else
+      commaized = lines[0..-2].join(", ")
+      commaized << ", and " + lines[-1]
+      create_paragraph parent, commaized, attrs
+    end
+  end
+end
diff --git a/docbook/asciidoctor-macros/commaize-block/sample.adoc b/docbook/asciidoctor-macros/commaize-block/sample.adoc
new file mode 100644 (file)
index 0000000..9cb2e1e
--- /dev/null
@@ -0,0 +1,31 @@
+= Sorted, delimited, empty lines
+
+[commaize]
+--
+One
+two
+
+red
+
+blue
+Fish
+--
+
+= Unsorted
+
+[commaize, sort=false]
+One
+two
+red
+blue
+Fish
+
+= Two elements
+
+[commaize]
+One
+Two
+
+= One element
+[commaize]
+Just the one
diff --git a/docbook/asciidoctor-macros/cve_idlink-inline-macro.rb b/docbook/asciidoctor-macros/cve_idlink-inline-macro.rb
new file mode 100644 (file)
index 0000000..e2dd67e
--- /dev/null
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: MIT
+# Copied from https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/man-inline-macro.rb
+
+RUBY_ENGINE == 'opal' ? (require 'cve_idlink-inline-macro/extension') : (require_relative 'cve_idlink-inline-macro/extension')
+
+Extensions.register :uri_schemes do
+  inline_macro CVEIdLinkInlineMacro
+end
diff --git a/docbook/asciidoctor-macros/cve_idlink-inline-macro/extension.rb b/docbook/asciidoctor-macros/cve_idlink-inline-macro/extension.rb
new file mode 100644 (file)
index 0000000..1e505d4
--- /dev/null
@@ -0,0 +1,31 @@
+# SPDX-License-Identifier: MIT
+require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
+
+include ::Asciidoctor
+
+# An inline macro that generates links to related man pages.
+#
+# Usage
+#
+#   cve_idlink:<cve-number>[]
+#
+class CVEIdLinkInlineMacro < Extensions::InlineMacroProcessor
+  use_dsl
+
+  named :cve_idlink
+
+  def process parent, target, attrs
+    cvename = "CVE-#{target}"
+    cvenum = target
+    suffix = ''
+    target = %(https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-{cvenum})
+    if parent.document.basebackend? 'html'
+      parent.document.register :links, target
+      %(#{(create_anchor parent, cvename, type: :link, target: target).render})
+    elsif parent.document.backend == 'manpage'
+      %(\\fB#{cvename})
+    else
+      %(#{cvename})
+    end
+  end
+end
diff --git a/docbook/asciidoctor-macros/ws_buglink-inline-macro.rb b/docbook/asciidoctor-macros/ws_buglink-inline-macro.rb
new file mode 100644 (file)
index 0000000..185fb39
--- /dev/null
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: MIT
+# Copied from https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/man-inline-macro.rb
+
+RUBY_ENGINE == 'opal' ? (require 'ws_buglink-inline-macro/extension') : (require_relative 'ws_buglink-inline-macro/extension')
+
+Extensions.register :uri_schemes do
+  inline_macro WSBugLinkInlineMacro
+end
diff --git a/docbook/asciidoctor-macros/ws_buglink-inline-macro/extension.rb b/docbook/asciidoctor-macros/ws_buglink-inline-macro/extension.rb
new file mode 100644 (file)
index 0000000..f6509da
--- /dev/null
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: MIT
+require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
+
+include ::Asciidoctor
+
+# An inline macro that generates links to related man pages.
+#
+# Usage
+#
+#   ws_buglink:<number>[<bug text>]
+#   Default bug text is "Bug".
+#
+class WSBugLinkInlineMacro < Extensions::InlineMacroProcessor
+  use_dsl
+
+  named :'ws_buglink'
+  name_positional_attributes 'bugtext'
+
+  def process parent, target, attrs
+    bugnum = target
+    bugtext = if (attrs['bugtext'])
+      attrs['bugtext']
+    else
+      'Bug'
+    end
+    target = %(https://bugs.wireshark.org/bugzilla/show_bug.cgi?id={bugnum})
+    if parent.document.basebackend? 'html'
+      parent.document.register :links, target
+      %(#{(create_anchor parent, bugtext, type: :link, target: target).render})
+    elsif parent.document.backend == 'manpage'
+      %(\\fB#{bugtext})
+    else
+      %(#{bugtext})
+    end
+  end
+end
diff --git a/docbook/asciidoctor-macros/ws_salink-inline-macro.rb b/docbook/asciidoctor-macros/ws_salink-inline-macro.rb
new file mode 100644 (file)
index 0000000..9e82f28
--- /dev/null
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: MIT
+# Copied from https://github.com/asciidoctor/asciidoctor-extensions-lab/blob/master/lib/man-inline-macro.rb
+
+RUBY_ENGINE == 'opal' ? (require 'ws_salink-inline-macro/extension') : (require_relative 'ws_salink-inline-macro/extension')
+
+Extensions.register :uri_schemes do
+  inline_macro WSSALinkInlineMacro
+end
diff --git a/docbook/asciidoctor-macros/ws_salink-inline-macro/extension.rb b/docbook/asciidoctor-macros/ws_salink-inline-macro/extension.rb
new file mode 100644 (file)
index 0000000..c76776b
--- /dev/null
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: MIT
+require 'asciidoctor/extensions' unless RUBY_ENGINE == 'opal'
+
+include ::Asciidoctor
+
+# An inline macro that generates links to related man pages.
+#
+# Usage
+#
+#   ws_salink:<dddd>[]
+#
+class WSSALinkInlineMacro < Extensions::InlineMacroProcessor
+  use_dsl
+
+  named :'ws_salink'
+
+  def process parent, target, attrs
+    sanum = target
+    satext = "wnpa-sec-#{target}"
+    target = %(https://www.wireshark.org/security/wnpa-sec-{sanum})
+    if parent.document.basebackend? 'html'
+      parent.document.register :links, target
+      %(#{(create_anchor parent, satext, type: :link, target: target).render})
+    elsif parent.document.backend == 'manpage'
+      %(\\fB#{satext})
+    else
+      %(#{satext})
+    end
+  end
+end
index fb933d01ca1cde02a38366c6d9eed409ab887353..da1bd8b64224fa74842b837f254463765f00a284 100644 (file)
@@ -1,11 +1,17 @@
 // Common attributes
 
 :wireshark-version: 2.5.1
+
 // We're migrating from AsciiDoc.
 :compat-mode:
 // Required for btn, kbd:, and menu: macros.
 :experimental:
 
+// Create PA4 (210 × 280mm) pages: https://en.wikipedia.org/wiki/Paper_size#PA4_or_L4
+// This is the approximate intersection of A4 (210 × 297mm) and U.S. Letter
+// (216 × 279mm).
+:pdf-page-size: 210mm x 280mm
+
 //
 // URLs
 //
diff --git a/docbook/custom_layer_pdf.xsl b/docbook/custom_layer_pdf.xsl
deleted file mode 100644 (file)
index 94a6512..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-<?xml version='1.0'?>
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-                version="1.0">
-
-<!-- import the main stylesheet -->
-<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl"/>
-
-<!-- page size -->
-<!-- Create PA4 (210 × 280mm) pages: https://en.wikipedia.org/wiki/Paper_size#PA4_or_L4
-     This is the approximate intersection of A4 (210 × 297mm) and U.S.
-     Letter (216 × 279mm).
--->
-<xsl:param name="paper.type">PA4</xsl:param>
-<xsl:param name="page.width.portrait">210mm</xsl:param>
-<xsl:param name="page.height.portrait">280mm</xsl:param>
-
-<!-- create pdf bookmarks -->
-<xsl:param name="fop1.extensions" select="1"/>
-
-<!-- don't use the draft mode (no loading of image from the web) -->
-<xsl:param name="draft.mode" select="no"/>
-
-<!-- use graphics for admons (note, tip, ...) -->
-<xsl:param name="admon.graphics" select="1"/>
-<xsl:param name="admon.graphics.path">common_graphics/</xsl:param>
-<xsl:param name="admon.graphics.extension" select="'.svg'"/>
-
-<!-- use numbering for sections (not only for chapters) -->
-<xsl:param name="section.autolabel" select="1"/>
-<xsl:param name="section.label.includes.component.label" select="1"/>
-
-<!-- include a single TOC (use book style TOC, removes the list of figures etc.) -->
-<xsl:param name="generate.toc" select="'book toc'"/>
-
-<!-- include page numbers in cross references -->
-<!-- <xsl:param name="insert.xref.page.number" select="1"/> -->
-
-<!-- don't show URL's, but only the text of it -->
-<xsl:param name="ulink.show" select="0"/>
-
-<!-- hyphenate URL's after the slash -->
-<!-- (http://docbook.sourceforge.net/release/xsl/current/doc/fo/ulink.hyphenate.html) -->
-<xsl:param name="ulink.hyphenate.chars" select="'/:'"></xsl:param>
-<xsl:param name="ulink.hyphenate" select="'&#x200B;'"></xsl:param>
-
-<!-- don't allow section titles to be hyphenated -->
-<xsl:attribute-set name="section.title.properties">
-  <xsl:attribute name="hyphenate">false</xsl:attribute>
-</xsl:attribute-set>
-
-<!-- put a page break after each section
-<xsl:attribute-set name="section.level1.properties">
-  <xsl:attribute name="break-after">page</xsl:attribute>
-</xsl:attribute-set>
--->
-
-<!-- set link style to blue and underlined -->
-<xsl:attribute-set name="xref.properties">
-  <xsl:attribute name="color">blue</xsl:attribute>
-  <xsl:attribute name="text-decoration">underline</xsl:attribute>
-</xsl:attribute-set>
-
-<!-- reduce the size of programlisting to make them fit the page -->
-<!-- We might want to set the hyphenation character to "\":
-     http://www.sagehill.net/docbookxsl/FittingText.html
--->
-<xsl:attribute-set name="monospace.verbatim.properties">
-  <xsl:attribute name="font-size">80%</xsl:attribute>
-  <xsl:attribute name="wrap-option">wrap</xsl:attribute>
-</xsl:attribute-set>
-
-<!-- Render AsciiDoc's labeled lists as blocks -->
-<xsl:param name="variablelist.as.blocks" select="1"></xsl:param>
-
-<!-- Increase the ordered list label width, otherwise we overflow
-     in some places.
--->
-<xsl:param name="orderedlist.label.width">1.8em</xsl:param>
-
-<!-- Right align ordered list labels. -->
-<!-- Doesn't look right, disabled for now.
-<xsl:attribute-set name="orderedlist.label.properties">
-  <xsl:attribute name="text-align">right</xsl:attribute>
-</xsl:attribute-set>
--->
-
-
-
-</xsl:stylesheet>
diff --git a/docbook/custom_layer_single_html.xsl b/docbook/custom_layer_single_html.xsl
new file mode 100644 (file)
index 0000000..bdd136d
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version="1.0">
+
+<!-- copied from custom_layer_chm.xsl -->
+
+<!-- import the main stylesheet -->
+<xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
+
+<xsl:output
+    method="html"
+    encoding="UTF-8"
+    indent="yes"
+    />
+
+</xsl:stylesheet>
index d6f04a53c372e89dc2f5d07517b67a1537d345c5..7e1ddfabb53ad96837ab0e4ae1142281501a643e 100644 (file)
@@ -22,9 +22,9 @@ Features section below for more details.
 
 //The following bugs have been fixed:
 
-//* ws-buglink:5000[]
-//* ws-buglink:6000[Wireshark bug]
-//* cve-idlink:2014-2486[]
+//* ws_buglink:5000[]
+//* ws_buglink:6000[Wireshark bug]
+//* cve_idlink:2014-2486[]
 //* Wireshark convinced you to switch seats on the plane while neglecting to tell you that its seat was noticeably moist.
 
 //_Non-empty section placeholder._
@@ -75,8 +75,9 @@ since version 2.4.0:
 
 === New Protocol Support
 
-// Add one protocol per line between the --sort-and-group-- delimiters.
---sort-and-group--
+// Add one protocol per line between the -- delimiters.
+[commaize]
+--
 ActiveMQ Artemis Core Protocol
 AMT (Automatic Multicast Tunneling)
 Bluetooth Mesh
@@ -104,7 +105,7 @@ Tibia
 TWAMP and OWAMP
 Wi-Fi Device Provisioning Protocol
 802.11ax (High Efficiency WLAN (HEW))
---sort-and-group--
+--
 
 === Updated Protocol Support
 
@@ -114,16 +115,16 @@ Too many protocols have been updated to list here.
 
 //_Non-empty section placeholder._
 // Add one file type per line between the --sort-and-group-- delimiters.
---sort-and-group--
+[commaize]
 Microsoft Network Monitor
---sort-and-group--
 
 === New and Updated Capture Interfaces support
 
 //_Non-empty section placeholder._
---sort-and-group--
+[commaize]
+--
 LoRaTap
---sort-and-group--
+--
 
 //=== Major API Changes
 
index b8d9674e22c5d234b63ac028cc1075484c805fbb..e5627130161d754889895e855b5abc89760a4ca5 100644 (file)
@@ -150,8 +150,6 @@ so it shows a version number for:
 
 * Web/wget (not needed if using CMake)
 
-* Text/asciidoc
-
 * Text/docbook-xml45
 
 // Also need: bash/sh, sed
@@ -173,14 +171,14 @@ Alternatively you can install Cygwin and its packages using Chocolatey:
 PS$>choco install cygwin
 PS$>choco install cyg-get
 ----
-//PS$>choco install sed asciidoc [...] -source cygwin
+//PS$>choco install sed [...] -source cygwin
 
 Chocolatey installs Cygwin in _C:\tools\cygwin_ by default.
 
 You can directly download packages via `cyg-get`
 
 ----
-PS$>cyg-get asciidoc patch docbook-xml45 [...]
+PS$>cyg-get docbook-xml45 [...]
 ----
 
 You can use Chocolatey’s Win flex-bison packages rather than the Cygwin
@@ -281,6 +279,20 @@ PS$>choco install cmake.portable
 
 Chocolatey ensures cmake.exe is on your path.
 
+[[ChSetupAsciidoctor]]
+
+==== Install Asciidoctor
+
+http://asciidoctor.org/[Asciidoctor] can be run directly as a Ruby
+script or via a Java wrapper (AsciidoctorJ). The easiest way to install
+it on Windows is via Chocolatey:
+
+----
+PS$>choco install asciidoctorj
+----
+
+Chocolatey ensures that asciidoctorj.exe is on your path.
+
 ==== Install and Prepare Sources
 
 [TIP]
@@ -422,7 +434,7 @@ If you've closed the Visual Studio Command Prompt <<ChSetupPrepareCommandCom,pre
 
 To generate the build files enter the following at the Visual Studio command prompt:
 ----
-> cmake -DENABLE_CHM_GUIDES=on -G "Visual Studio 14 2015" ..\wireshark
+> cmake -G "Visual Studio 14 2015" ..\wireshark
 ----
 
 Adjusting the paths as required to Python and the wireshark source tree.
index 41227ba13380beb52af4f16d9faf609a5e012d59..f3b0d0145c3869ceae114b88c4fd558bb0e813f5 100644 (file)
@@ -231,8 +231,6 @@ using the `-D` flag. Useful variables and generators include the following:
 
 -DENABLE_GTK3=ON:: Enable GTK+ 3
 
--DENABLE_HTML_GUIDES=ON -DENABLE_PDF_GUIDES=ON:: Build documentation
-
 +++-DCMAKE_C_FLAGS='-Qunused-arguments'+++:: Make ccache and clang work together
 
 -DPYTHON_EXECUTABLE=c:/Python27/python:: Force the Python path. Useful on Windows since Cygwin’s /usrbin/python is a symlink.
index a32b1ab8e75975554f2de875f4e4f789fe11752a..a43a3601d6ca0dbc95eca1131cf8c9cd2598cf94 100644 (file)
@@ -224,7 +224,7 @@ macro( ADD_NSIS_PACKAGE_TARGET )
                DEPENDS
                        ${NSIS_FILES}
                        copy_data_files
-                       user_guides
+                       user_guide_chm
                        ${CMAKE_BINARY_DIR}/docbook/user-guide.chm
                        ${DATAFILE_DIR}/uninstall.exe
        )
index 5a194c75d83bda8c4ac2613f75bd43b1564cf469..2bcb22722e713e9d40a4ce460b1d8f875f0ab876 100644 (file)
@@ -83,7 +83,6 @@ EXTRA_DIST = \
        randpkt-test.sh                                 \
        rdps.py                                         \
        rpm_setup.sh                                    \
-       runa2x.sh                                       \
        test-common.sh                                  \
        test-captures.sh                                \
        textify.ps1                                     \
index f7ed3043d01ff3e79e0b8818f8040d63547fba85..ae370dc7214855b3993c5324ec39421ea845ff4a 100755 (executable)
@@ -95,10 +95,10 @@ PATH_SPECIFIC_WHITELISTED_LICENSES = {
     'doc/': [
         'UNKNOWN',
     ],
-    'docbook/custom_layer_pdf.xsl': [
+    'docbook/custom_layer_chm.xsl': [
         'UNKNOWN',
     ],
-    'docbook/custom_layer_chm.xsl': [
+    'docbook/custom_layer_single_html.xsl': [
         'UNKNOWN',
     ],
     'docbook/ws.css' : [
diff --git a/tools/runa2x.sh b/tools/runa2x.sh
deleted file mode 100755 (executable)
index 1c234f4..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/sh -xv
-
-#
-# runa2x.sh
-# Wrapper script for running Cygwin's a2x via CMake.
-#
-# Wireshark - Network traffic analyzer
-# By Gerald Combs <gerald@wireshark.org>
-# Copyright 2015 Gerald Combs
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-#
-
-# Bugs:
-# - This script shouldn't exist. Unfortunately there doesn't appear
-#   to be a way to construct a Windows command line that can set the
-#   environment variables below, then run /usr/bin/a2x (which is a symlink).
-
-# Ensure cygwin bin dir is on the path if running under it
-if [[ $OSTYPE == "cygwin" ]]; then
-       PATH="$PATH:/usr/bin"
-else
-    >&2 echo "We're trying to limit the scope of this insanity to CMake + Cygwin"
-    exit 1
-fi
-
-LC_ALL=C
-export LC_ALL
-
-TZ=UTC
-export TZ
-
-PATH=/usr/bin
-export PATH
-
-PYTHONHOME=/
-export PYTHONHOME
-
-echo "running a2x with args $@"
-
-a2x "$@"