diff --git a/CMakeLists.txt b/CMakeLists.txt index b1101d71..e36d4331 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -set(ITK_OLDEST_VALIDATED_POLICIES_VERSION "3.16.3") -set(ITK_NEWEST_VALIDATED_POLICIES_VERSION "3.19.7") +set(ITK_OLDEST_VALIDATED_POLICIES_VERSION "3.22.1") +set(ITK_NEWEST_VALIDATED_POLICIES_VERSION "3.29.0") cmake_minimum_required(VERSION ${ITK_OLDEST_VALIDATED_POLICIES_VERSION}...${ITK_NEWEST_VALIDATED_POLICIES_VERSION} FATAL_ERROR) set(PRIMARY_PROJECT_NAME ITKSoftwareGuide) @@ -28,12 +28,12 @@ set(PDF_QUALITY_LEVEL "Screen" CACHE STRING "PDF Quality. Options are: Screen, P #----------------------------------------------------------------------------- # Superbuild script #----------------------------------------------------------------------------- -project(${PRIMARY_PROJECT_NAME}) # <- NOTE: Here is the main project name setting if(${PRIMARY_PROJECT_NAME}_SUPERBUILD) - project(SuperBuild_${PRIMARY_PROJECT_NAME}) # <- NOTE: Project name for pre-requisites is different form main project + project(SuperBuild_${PRIMARY_PROJECT_NAME}) # <- NOTE: Project name for pre-requisites is different from main project include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake") return() else() + project(${PRIMARY_PROJECT_NAME}) # <- NOTE: Here is the main project name setting include("${CMAKE_CURRENT_SOURCE_DIR}/${PRIMARY_PROJECT_NAME}.cmake") return() endif() diff --git a/Latex/Insight.sty b/Latex/Insight.sty index 76160181..40c1eba9 100644 --- a/Latex/Insight.sty +++ b/Latex/Insight.sty @@ -1,5 +1,5 @@ % -% Insight.sty for the Insight documentation [works only with with Latex2e] +% Insight.sty for the Insight documentation [works only with Latex2e] % \NeedsTeXFormat{LaTeX2e}[1995/12/01] @@ -1079,7 +1079,7 @@ % Definition lists; requested by AMK for HOWTO documents. Probably useful -% elsewhere as well, so keep in in the general style support. +% elsewhere as well, so keep in the general style support. % \newenvironment{definitions}{% \begin{description}% diff --git a/Latex/doubleWordCheck.pl b/Latex/doubleWordCheck.pl deleted file mode 100755 index f7cceec5..00000000 --- a/Latex/doubleWordCheck.pl +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/perl -# -# Script for searching for double words in the text -# -# Contributed by Hans Johnson, Iowa University -# This was one of the first examples in the Mastering Regular Expressions Book. -# There are several other gems like this in that book. -# - -$/ = ".\n"; -while (<>) { - next if !s/\b([a-z]+)((\s|<[^>]+>)+)(\1\b)/\e[7m$1\e[m$2\e[7m$4\e[m/ig; - s/^([^\e]*\n)+//mg; - s/^/$ARGV: /mg; - print; -} - diff --git a/Latex/doubleWordCheck.py b/Latex/doubleWordCheck.py new file mode 100755 index 00000000..dc4f9c18 --- /dev/null +++ b/Latex/doubleWordCheck.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +""" +Search for doubled words in text + +Behavior: +- Reads one or more files (or stdin if none). +- Processes input in "records" delimited by ".\n" (Perl: $/ = ".\n"). +- In each record, highlights a repeated word (case-insensitive) where the two + occurrences are separated by whitespace and/or simple HTML tags. +- Removes any leading lines that contain no escape characters. +- Prefixes each remaining line with ": ". +""" + +from __future__ import annotations + +import argparse +import re +import sys +from pathlib import Path + + +ESC = "\x1b" + +# Perl: s/\b([a-z]+)((\s|<[^>]+>)+)(\1\b)/\e[7m$1\e[m$2\e[7m$4\e[m/ig +DOUBLE_WORD_RE = re.compile( + r"\b([a-z]+)((?:\s|<[^>]+>)+)(\1\b)", + re.IGNORECASE, +) + +# Perl: s/^([^\e]*\n)+//mg +# Interpreted as: drop initial consecutive lines that contain no ESC. +LEADING_NO_ESC_LINES_RE = re.compile(r"^(?:[^\x1b]*\n)+", re.MULTILINE) + + +def highlight_double_words(record: str) -> str | None: + """ + Return transformed record if a double-word pattern is found; otherwise None. + """ + + def repl(m: re.Match[str]) -> str: + w1 = m.group(1) + sep = m.group(2) + w2 = m.group(3) # same text as group(1) as matched + return f"{ESC}[7m{w1}{ESC}[m{sep}{ESC}[7m{w2}{ESC}[m" + + new_record, n = DOUBLE_WORD_RE.subn(repl, record, count=1) + if n == 0: + return None + + new_record = LEADING_NO_ESC_LINES_RE.sub("", new_record, count=1) + return new_record + + +def iter_records(text: str, sep: str = ".\n"): + """ + Yield records split by the exact separator, including the separator (like Perl $/). + """ + start = 0 + while True: + idx = text.find(sep, start) + if idx == -1: + if start < len(text): + yield text[start:] + break + end = idx + len(sep) + yield text[start:end] + start = end + + +def process_stream(name: str, data: str, out) -> None: + for record in iter_records(data, sep=".\n"): + transformed = highlight_double_words(record) + if transformed is None: + continue + + # Perl: s/^/$ARGV: /mg => prefix each line + prefixed = re.sub(r"^", f"{name}: ", transformed, flags=re.MULTILINE) + out.write(prefixed) + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("files", nargs="*", help="Files to scan; if empty, read stdin.") + args = ap.parse_args() + + if not args.files: + data = sys.stdin.read() + process_stream("", data, sys.stdout) + return 0 + + for f in args.files: + p = Path(f) + data = p.read_text(encoding="utf-8", errors="replace") + process_stream(f, data, sys.stdout) + + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/SoftwareGuide/CMakeLists.txt b/SoftwareGuide/CMakeLists.txt index aac6e5e5..9193c94f 100644 --- a/SoftwareGuide/CMakeLists.txt +++ b/SoftwareGuide/CMakeLists.txt @@ -24,14 +24,14 @@ # images, if not the images are expected to be present in the Art/ folder # in PNG/XFIG/JPEG/EPS format. # -cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) -cmake_policy(VERSION 3.10.2) +cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR) +cmake_policy(VERSION 3.22.1) project(SoftwareGuide C) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH}) -find_package(ITK 4 REQUIRED) +find_package(ITK 5 REQUIRED) include(${ITK_USE_FILE}) set(PDF_QUALITY_LEVEL "Screen" CACHE STRING "PDF Quality. Options are: Screen, Printer, PrePress") diff --git a/SoftwareGuide/Cover/Source/CMakeLists.txt b/SoftwareGuide/Cover/Source/CMakeLists.txt index b341f39e..a7b5cfc1 100644 --- a/SoftwareGuide/Cover/Source/CMakeLists.txt +++ b/SoftwareGuide/Cover/Source/CMakeLists.txt @@ -1,9 +1,9 @@ -cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) -cmake_policy(VERSION 3.10.2) +cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR) +cmake_policy(VERSION 3.22.1) project( VWSegmentation ) -find_package( ITK REQUIRED ) +find_package( ITK 5 REQUIRED ) include( ${ITK_USE_FILE} ) set( operations diff --git a/SoftwareGuide/Examples/CMakeLists.txt b/SoftwareGuide/Examples/CMakeLists.txt index 8924b12e..7d2ac07b 100644 --- a/SoftwareGuide/Examples/CMakeLists.txt +++ b/SoftwareGuide/Examples/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) -cmake_policy(VERSION 3.10.2) +cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR) +cmake_policy(VERSION 3.22.1) project(Examples C) diff --git a/SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex b/SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex index 5efbd094..67e1ce85 100644 --- a/SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex +++ b/SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex @@ -64,8 +64,8 @@ \subsection{CMakeLists.txt} contain \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cmake} -cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) -cmake_policy(VERSION 3.10.2) +cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR) +cmake_policy(VERSION 3.22.1) project(MyModule) @@ -1293,16 +1293,16 @@ \subsection{CMakeList.txt} \begin{minted}[baselinestretch=1,fontsize=\footnotesize,linenos=false,bgcolor=ltgray]{cmake} # When this module is loaded by an app, load OpenCV too. -set(ITKVideoBridgeOpenCV_EXPORT_CODE_INSTALL " -set(OpenCV_DIR \"${OpenCV_DIR}\") -find_package(OpenCV REQUIRED) -") -set(ITKVideoBridgeOpenCV_EXPORT_CODE_BUILD " -if(NOT ITK_BINARY_DIR) +set(ITKVideoBridgeOpenCV_EXPORT_CODE_INSTALL \" set(OpenCV_DIR \"${OpenCV_DIR}\") find_package(OpenCV REQUIRED) -endif() -") +\") +set(ITKVideoBridgeOpenCV_EXPORT_CODE_BUILD \" + if(NOT ITK_BINARY_DIR) + set(OpenCV_DIR \"${OpenCV_DIR}\") + find_package(OpenCV REQUIRED) + endif() +\") \end{minted} Finally, set the \code{\_SYSTEM\_INCLUDE\_DIRS} and diff --git a/TODO b/TODO index dcaf37f1..9e4fbf13 100644 --- a/TODO +++ b/TODO @@ -1,18 +1,9 @@ -Remove all references to perl PERL Get output images only produced in BINARY_DIR. --- (DONE) Have python code line extractor throw warning when lines are too long to print. --- Reduce line length in ITK proper -- Figure out which pictures need "flipping" and how to do that with imagemagik. -- Order all tex files in SoftwareGuide/Latex/*.tex to be ordered when listed with a ##-${filename} prefix. --- Re-order chapters -- Add "Remote Module documentation" -- Remove "CenteredTransforms" from all examples in book. --- Remove redundant information. --- Describe Modularization as part of a ITKv3->ITKv4 transition appendix --- Update Acknowledgments --- Test clean builds --- Support "USE_SYSTEM_ITK" ========================================================== This is a list of potential topics to be added to the Software Guide.