Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions Latex/Insight.sty
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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}%
Expand Down
17 changes: 0 additions & 17 deletions Latex/doubleWordCheck.pl

This file was deleted.

100 changes: 100 additions & 0 deletions Latex/doubleWordCheck.py
Original file line number Diff line number Diff line change
@@ -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 "<filename>: ".
"""

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("<stdin>", 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())
6 changes: 3 additions & 3 deletions SoftwareGuide/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions SoftwareGuide/Examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
20 changes: 10 additions & 10 deletions SoftwareGuide/Latex/DevelopmentGuidelines/CreateAModule.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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{<module-name>\_SYSTEM\_INCLUDE\_DIRS} and
Expand Down
9 changes: 0 additions & 9 deletions TODO
Original file line number Diff line number Diff line change
@@ -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.
Expand Down