Skip to content

Commit 8fa0110

Browse files
committed
feat(ffi): add C badge to READMEs, expand FFI docs, add tests and examples
Add C FFI badge across all package READMEs and the main README. Expand kreuzberg-ffi README with full badge grid. Add plugin error injection and concurrent access C tests. Add basic_extraction and batch_extraction C examples with Makefile.
1 parent e75b8f5 commit 8fa0110

File tree

16 files changed

+633
-46
lines changed

16 files changed

+633
-46
lines changed

.pre-commit-config.yaml

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ repos:
5252
rev: v1.19.1
5353
hooks:
5454
- id: mypy
55-
exclude: "e2e/|scripts/"
55+
exclude: "e2e/|scripts/|examples/|tests/test_apps/|benchmarks/"
5656

5757
# Rust: formatting, linting, and license checking
5858
- repo: https://github.com/AndrejOrsula/pre-commit-cargo
@@ -117,7 +117,7 @@ repos:
117117
hooks:
118118
- id: golangci-lint-full
119119
name: golangci-lint (all Go modules)
120-
entry: task go:lint:check
120+
entry: task go:lint
121121
language: system
122122
files: \.go$
123123
pass_filenames: false
@@ -145,106 +145,106 @@ repos:
145145
hooks:
146146

147147
# Ruby - prek doesn't support Ruby yet
148-
- id: ruby-format-check
149-
name: Check Ruby formatting (rubocop)
150-
entry: task ruby:format:check
148+
- id: ruby-format
149+
name: Ruby formatting (rubocop)
150+
entry: task ruby:format
151151
language: system
152-
files: ^packages/ruby/.*\.rb$
152+
files: \.rb$
153153
pass_filenames: false
154154
require_serial: true
155155
stages: [commit]
156156

157-
- id: ruby-lint-check
158-
name: Check Ruby linting (rubocop + steep)
159-
entry: task ruby:lint:check
157+
- id: ruby-lint
158+
name: Ruby linting (rubocop + steep)
159+
entry: task ruby:lint
160160
language: system
161-
files: ^packages/ruby/(lib|sig)/.*\.(rb|rbs)$
161+
files: \.(rb|rbs)$
162162
pass_filenames: false
163163
require_serial: true
164164
stages: [commit]
165165

166166
# Java - prek doesn't support Java
167-
- id: java-format-check
168-
name: Check Java formatting (spotless)
169-
entry: task java:format:check
167+
- id: java-format
168+
name: Java formatting (spotless)
169+
entry: task java:format
170170
language: system
171-
files: ^packages/java/src/.*\.java$
171+
files: \.java$
172172
pass_filenames: false
173173
require_serial: true
174174
stages: [commit]
175175

176-
- id: java-lint-check
177-
name: Check Java linting (checkstyle + pmd)
178-
entry: task java:lint:check
176+
- id: java-lint
177+
name: Java linting (checkstyle + pmd)
178+
entry: task java:lint
179179
language: system
180-
files: ^packages/java/src/.*\.java$
180+
files: \.java$
181181
pass_filenames: false
182182
require_serial: true
183183
stages: [commit]
184184

185185
# C# - prek doesn't support C#
186-
- id: csharp-format-check
187-
name: Check C# formatting (dotnet format)
188-
entry: task csharp:format:check
186+
- id: csharp-format
187+
name: C# formatting (dotnet format)
188+
entry: task csharp:format
189189
language: system
190-
files: ^packages/csharp/
190+
files: \.cs$
191191
pass_filenames: false
192192
require_serial: true
193193
stages: [commit]
194194

195-
- id: csharp-lint-check
196-
name: Check C# linting (dotnet format verify)
197-
entry: task csharp:lint:check
195+
- id: csharp-lint
196+
name: C# linting (dotnet format)
197+
entry: task csharp:lint
198198
language: system
199-
files: ^packages/csharp/
199+
files: \.cs$
200200
pass_filenames: false
201201
require_serial: true
202202
stages: [commit]
203203

204204
# PHP - prek doesn't support PHP
205-
- id: php-format-check
206-
name: Check PHP formatting (php-cs-fixer)
207-
entry: task php:format:check
205+
- id: php-format
206+
name: PHP formatting (php-cs-fixer)
207+
entry: task php:format
208208
language: system
209-
files: ^packages/php/.*\.php$
209+
files: \.php$
210210
pass_filenames: false
211211
require_serial: true
212212
stages: [commit]
213213

214-
- id: php-lint-check
215-
name: Check PHP linting (phpstan + php-cs-fixer)
216-
entry: task php:lint:check
214+
- id: php-lint
215+
name: PHP linting (phpstan + php-cs-fixer)
216+
entry: task php:lint
217217
language: system
218-
files: ^packages/php/.*\.php$
218+
files: \.php$
219219
pass_filenames: false
220220
require_serial: true
221221
stages: [commit]
222222

223223
# R - prek doesn't support R yet
224-
- id: r-format-check
225-
name: Check R formatting (styler)
226-
entry: task r:format:check
224+
- id: r-format
225+
name: R formatting (styler)
226+
entry: task r:format
227227
language: system
228-
files: ^packages/r/R/.*\.R$
228+
files: \.R$
229229
pass_filenames: false
230230
require_serial: true
231231
stages: [commit]
232232

233-
- id: r-lint-check
234-
name: Check R linting (lintr)
235-
entry: task r:lint:check
233+
- id: r-lint
234+
name: R linting (lintr)
235+
entry: task r:lint
236236
language: system
237-
files: ^packages/r/R/.*\.R$
237+
files: \.R$
238238
pass_filenames: false
239239
require_serial: true
240240
stages: [commit]
241241

242-
# TypeScript - type checking across all projects
242+
# TypeScript - type checking across all projects (builds WASM + Node first)
243243
- id: typescript-typecheck
244244
name: Check TypeScript types
245-
entry: npx -y tsc-files
245+
entry: task typescript:typecheck
246246
language: system
247-
files: ^*\.(ts|tsx)$
247+
files: \.(ts|tsx)$
248248
pass_filenames: false
249249
require_serial: true
250250
stages: [commit]

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
<a href="https://github.com/kreuzberg-dev/kreuzberg/pkgs/container/kreuzberg">
4040
<img src="https://img.shields.io/badge/Docker-007ec6?logo=docker&logoColor=white" alt="Docker">
4141
</a>
42+
<a href="https://github.com/kreuzberg-dev/kreuzberg/releases">
43+
<img src="https://img.shields.io/badge/C-FFI-007ec6" alt="C">
44+
</a>
4245

4346
<!-- Project Info -->
4447
<a href="https://github.com/kreuzberg-dev/kreuzberg/blob/main/LICENSE">

crates/kreuzberg-ffi/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,65 @@
11
# kreuzberg-ffi
22

3+
<div align="center" style="display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 20px 0;">
4+
<!-- Language Bindings -->
5+
<a href="https://crates.io/crates/kreuzberg">
6+
<img src="https://img.shields.io/crates/v/kreuzberg?label=Rust&color=007ec6" alt="Rust">
7+
</a>
8+
<a href="https://hex.pm/packages/kreuzberg">
9+
<img src="https://img.shields.io/hexpm/v/kreuzberg?label=Elixir&color=007ec6" alt="Elixir">
10+
</a>
11+
<a href="https://pypi.org/project/kreuzberg/">
12+
<img src="https://img.shields.io/pypi/v/kreuzberg?label=Python&color=007ec6" alt="Python">
13+
</a>
14+
<a href="https://www.npmjs.com/package/@kreuzberg/node">
15+
<img src="https://img.shields.io/npm/v/@kreuzberg/node?label=Node.js&color=007ec6" alt="Node.js">
16+
</a>
17+
<a href="https://www.npmjs.com/package/@kreuzberg/wasm">
18+
<img src="https://img.shields.io/npm/v/@kreuzberg/wasm?label=WASM&color=007ec6" alt="WASM">
19+
</a>
20+
21+
<a href="https://central.sonatype.com/artifact/dev.kreuzberg/kreuzberg">
22+
<img src="https://img.shields.io/maven-central/v/dev.kreuzberg/kreuzberg?label=Java&color=007ec6" alt="Java">
23+
</a>
24+
<a href="https://github.com/kreuzberg-dev/kreuzberg/releases">
25+
<img src="https://img.shields.io/github/v/tag/kreuzberg-dev/kreuzberg?label=Go&color=007ec6&filter=v4.3.8" alt="Go">
26+
</a>
27+
<a href="https://www.nuget.org/packages/Kreuzberg/">
28+
<img src="https://img.shields.io/nuget/v/Kreuzberg?label=C%23&color=007ec6" alt="C#">
29+
</a>
30+
<a href="https://packagist.org/packages/kreuzberg/kreuzberg">
31+
<img src="https://img.shields.io/packagist/v/kreuzberg/kreuzberg?label=PHP&color=007ec6" alt="PHP">
32+
</a>
33+
<a href="https://rubygems.org/gems/kreuzberg">
34+
<img src="https://img.shields.io/gem/v/kreuzberg?label=Ruby&color=007ec6" alt="Ruby">
35+
</a>
36+
<a href="https://kreuzberg-dev.r-universe.dev/kreuzberg">
37+
<img src="https://img.shields.io/badge/R-kreuzberg-007ec6" alt="R">
38+
</a>
39+
<a href="https://github.com/kreuzberg-dev/kreuzberg/pkgs/container/kreuzberg">
40+
<img src="https://img.shields.io/badge/Docker-007ec6?logo=docker&logoColor=white" alt="Docker">
41+
</a>
42+
<a href="https://github.com/kreuzberg-dev/kreuzberg/releases">
43+
<img src="https://img.shields.io/badge/C-FFI-007ec6" alt="C">
44+
</a>
45+
46+
<!-- Project Info -->
47+
<a href="https://github.com/kreuzberg-dev/kreuzberg/blob/main/LICENSE">
48+
<img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License">
49+
</a>
50+
<a href="https://docs.kreuzberg.dev">
51+
<img src="https://img.shields.io/badge/docs-kreuzberg.dev-blue" alt="Documentation">
52+
</a>
53+
</div>
54+
55+
<img width="1128" height="191" alt="Banner2" src="https://github.com/user-attachments/assets/419fc06c-8313-4324-b159-4b4d3cfce5c0" />
56+
57+
<div align="center" style="margin-top: 20px;">
58+
<a href="https://discord.gg/xt9WY3GnKR">
59+
<img height="22" src="https://img.shields.io/badge/Discord-Join%20our%20community-7289da?logo=discord&logoColor=white" alt="Discord">
60+
</a>
61+
</div>
62+
363
C Foreign Function Interface (FFI) bindings for the Kreuzberg document intelligence library.
464

565
## Overview

crates/kreuzberg-ffi/tests/c/Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ endif
2121

2222
TESTS = test_version test_error test_extraction test_mime \
2323
test_config test_config_builder test_html_options test_validation test_string_intern \
24-
test_result_pool test_result_inspect test_plugins test_batch test_error_extended
24+
test_result_pool test_result_inspect test_plugins test_batch test_error_extended \
25+
test_plugins_errors test_concurrent
2526

2627
.PHONY: all clean test
2728

2829
all: $(TESTS)
2930

31+
test: all
32+
@for t in $(TESTS); do echo "Running $$t..."; ./$$t || exit 1; done
33+
3034
test_version: test_version.c
3135
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(RPATH)
3236

@@ -69,5 +73,11 @@ test_batch: test_batch.c
6973
test_error_extended: test_error_extended.c
7074
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(RPATH)
7175

76+
test_plugins_errors: test_plugins_errors.c
77+
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(RPATH)
78+
79+
test_concurrent: test_concurrent.c
80+
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(RPATH) -lpthread
81+
7282
clean:
7383
rm -f $(TESTS)

0 commit comments

Comments
 (0)