From e3c7b2eec0a23c977d7ddfaa5593eff81dbb9bec Mon Sep 17 00:00:00 2001 From: jedarden Date: Mon, 18 May 2026 02:27:40 -0400 Subject: [PATCH] fix(pdftract-l993m): fix Tera template syntax in Methods templates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix incorrect Tera template syntax in per-language Methods templates: - Change `elsif` to `elif` (correct Tera conditional syntax) - Fix inline ternary-like syntax to use proper `{% if %}...{% else %}...{% endif %}` - Fix truncated package name in Java template (codegen → codegen) Affected templates: - PHP: Methods.php.tera - Python: methods.py.tera - Ruby: methods.rb.tera - Swift: Methods.swift.tera - Java: Methods.java.tera All 8 subprocess SDK templates now render correctly with the codegen command. Verified via `pdftract sdk codegen --lang --out /tmp/sdk-`. Co-Authored-By: Claude Code Bead-Id: pdftract-l993m --- .../com/jedarden/pdftract/codegen/Methods.java.tera | 2 +- .../sdk-skeleton/php/src/Codegen/Methods.php.tera | 10 +++++----- .../pdftract_subprocess/codegen/methods.py.tera | 6 +++--- .../ruby/lib/pdftract/codegen/methods.rb.tera | 8 ++++---- .../swift/Sources/PdftractCodegen/Methods.swift.tera | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/templates/sdk-skeleton/java/src/main/java/com/jedarden/pdftract/codegen/Methods.java.tera b/templates/sdk-skeleton/java/src/main/java/com/jedarden/pdftract/codegen/Methods.java.tera index d6de734..f3aa887 100644 --- a/templates/sdk-skeleton/java/src/main/java/com/jedarden/pdftract/codegen/Methods.java.tera +++ b/templates/sdk-skeleton/java/src/main/java/com/jedarden/pdftract/codegen/Methods.java.tera @@ -1,4 +1,4 @@ -package com.jedarden.pdftract.codeg +package com.jedarden.pdftract.codegen; import com.google.gson.Gson; import com.google.gson.JsonObject; diff --git a/templates/sdk-skeleton/php/src/Codegen/Methods.php.tera b/templates/sdk-skeleton/php/src/Codegen/Methods.php.tera index bb90ec6..500412d 100644 --- a/templates/sdk-skeleton/php/src/Codegen/Methods.php.tera +++ b/templates/sdk-skeleton/php/src/Codegen/Methods.php.tera @@ -104,7 +104,7 @@ class Client throw $this->mapError($stderr, $exitCode); } } - {% elsif method.name == 'search' %} + {% elif method.name == 'search' %} /** * {{ method.description }} * @@ -159,14 +159,14 @@ class Client throw $this->mapError($stderr, $exitCode); } } - {% elsif method.name == 'verify_receipt' %} + {% elif method.name == 'verify_receipt' %} public function {{ method.camel_name }}(string $path, string $receipt): bool { $output = $this->exec(['{{ method.cli_flag }}', $path, $receipt]); return trim($output) === 'true'; } {% else %} - public function {{ method.camel_name }}(Source $source{% if method.has_options %}, ?{{ method.options_type }} $options = null{% endif %}): {{ method.return_type == 'string' ? 'string' : 'array' }} + public function {{ method.camel_name }}(Source $source{% if method.has_options %}, ?{{ method.options_type }} $options = null{% endif %}): {% if method.return_type == 'string' %}string{% else %}array{% endif %} { $args = array_merge(['{{ method.cli_flag }}'], $source->toArgs()); @@ -178,9 +178,9 @@ class Client {% if method.name == 'extract_text' %} $args[] = '--text'; - {% elseif method.name == 'extract_markdown' %} + {% elif method.name == 'extract_markdown' %} $args[] = '--md'; - {% elseif method.name == 'get_metadata' %} + {% elif method.name == 'get_metadata' %} $args[] = '--metadata-only'; {% endif %} diff --git a/templates/sdk-skeleton/python-subprocess/pdftract_subprocess/codegen/methods.py.tera b/templates/sdk-skeleton/python-subprocess/pdftract_subprocess/codegen/methods.py.tera index d03304f..8f4a59b 100644 --- a/templates/sdk-skeleton/python-subprocess/pdftract_subprocess/codegen/methods.py.tera +++ b/templates/sdk-skeleton/python-subprocess/pdftract_subprocess/codegen/methods.py.tera @@ -76,7 +76,7 @@ class Client: if process.returncode != 0: stderr = process.stderr.read() raise self._map_error(stderr, process.returncode) - {% elsif method.name == 'search' %} + {% elif method.name == 'search' %} def {{ method.snake_name }}( self, source: Source, pattern: str, options=None ) -> Iterator[dict]: @@ -107,7 +107,7 @@ class Client: if process.returncode != 0: stderr = process.stderr.read() raise self._map_error(stderr, process.returncode) - {% elsif method.name == 'verify_receipt' %} + {% elif method.name == 'verify_receipt' %} def {{ method.snake_name }}(self, path: str, receipt: str) -> bool: """{{ method.description }}""" output = self._exec("{{ method.cli_flag }}", path, receipt) @@ -115,7 +115,7 @@ class Client: {% else %} def {{ method.snake_name }}( self, source: Source{% if method.has_options %}, options=None{% endif %} - ) -> {{ 'str' if method.returns_string else 'dict' }}: + ){% if method.returns_string %} -> str:{% else %} -> dict:{% endif %} """{{ method.description }}""" args = ["{{ method.cli_flag }}", *source.to_args()] diff --git a/templates/sdk-skeleton/ruby/lib/pdftract/codegen/methods.rb.tera b/templates/sdk-skeleton/ruby/lib/pdftract/codegen/methods.rb.tera index 18bc296..9bff7d5 100644 --- a/templates/sdk-skeleton/ruby/lib/pdftract/codegen/methods.rb.tera +++ b/templates/sdk-skeleton/ruby/lib/pdftract/codegen/methods.rb.tera @@ -63,7 +63,7 @@ module Pdftract end end end - {% elsif method.name == 'search' %} + {% elif method.name == 'search' %} def {{ method.snake_name }}(source, pattern, options = nil) args = ["grep", pattern, *source.to_args] args.concat(options.to_args) if options @@ -83,7 +83,7 @@ module Pdftract end end end - {% elsif method.name == 'verify_receipt' %} + {% elif method.name == 'verify_receipt' %} def {{ method.snake_name }}(path, receipt) output = exec("{{ method.cli_flag }}", path, receipt) output.strip == "true" @@ -98,9 +98,9 @@ module Pdftract {% if method.name == 'extract_text' %} args << "--text" - {% elsif method.name == 'extract_markdown' %} + {% elif method.name == 'extract_markdown' %} args << "--md" - {% elsif method.name == 'get_metadata' %} + {% elif method.name == 'get_metadata' %} args << "--metadata-only" {% endif %} diff --git a/templates/sdk-skeleton/swift/Sources/PdftractCodegen/Methods.swift.tera b/templates/sdk-skeleton/swift/Sources/PdftractCodegen/Methods.swift.tera index c9e1863..11d2f57 100644 --- a/templates/sdk-skeleton/swift/Sources/PdftractCodegen/Methods.swift.tera +++ b/templates/sdk-skeleton/swift/Sources/PdftractCodegen/Methods.swift.tera @@ -108,7 +108,7 @@ public class Pdftract { } } } - {% elsif method.name == 'search' %} + {% elif method.name == 'search' %} public func {{ method.camel_name }}(_ source: Source, _ pattern: String, options: {{ method.options_type }}? = nil) -> AsyncStream<{{ method.return_type }}> { return AsyncStream { continuation in var args = ["grep", pattern] @@ -160,13 +160,13 @@ public class Pdftract { } } } - {% elsif method.name == 'verify_receipt' %} + {% elif method.name == 'verify_receipt' %} public func {{ method.camel_name }}(_ path: String, _ receipt: String) throws -> Bool { let output = try exec(["{{ method.cli_flag }}", path, receipt]) return output.trimmingCharacters(in: .whitespacesAndNewlines) == "true" } {% else %} - public func {{ method.camel_name }}(_ source: Source{% if method.has_options %}, options: {{ method.options_type }}? = nil{% endif %}) throws -> {{ method.return_type == 'string' ? 'String' : method.return_type }} { + public func {{ method.camel_name }}(_ source: Source{% if method.has_options %}, options: {{ method.options_type }}? = nil{% endif %}) throws -> {% if method.return_type == 'string' %}String{% else %}{{ method.return_type }}{% endif %} { var args = ["{{ method.cli_flag }}"] args.append(contentsOf: source.toArgs())