Skip to content

Commit e2cbd6d

Browse files
committed
feat: github action
1 parent 0e0a96c commit e2cbd6d

File tree

4 files changed

+63
-6
lines changed

4 files changed

+63
-6
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Generate Markdown Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
generate:
14+
if: github.actor != 'github-actions[bot]'
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: '8.1'
26+
extensions: mbstring, intl
27+
coverage: none
28+
tools: composer:v2
29+
30+
- name: Install dependencies
31+
run: composer install --prefer-dist --no-interaction --no-progress
32+
33+
- name: Generate Markdown documentation
34+
run: vendor/bin/phpdoc --directory=src --target=docs --template="vendor/saggre/phpdocumentor-markdown/themes/markdown"
35+
36+
- name: Commit and push updates
37+
run: |
38+
STATUS=$(git status --short docs)
39+
if [ -z "$STATUS" ]; then
40+
echo "Documentation already up to date"
41+
exit 0
42+
fi
43+
44+
echo "Docs updated, committing changes"
45+
git config user.name "github-actions[bot]"
46+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
47+
git add docs
48+
git commit -m "docs: update markdown API reference [skip ci]"
49+
git push

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
.env
44
/demo/vendor/
55
/demo/composer.lock
6+
.phpdoc/cache

composer.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
"require": {
1313
"php": "^8.1",
1414
"guzzlehttp/guzzle": "^7.0",
15-
"respect/validation": "^2.0"
15+
"respect/validation": "^2.0",
16+
"phpdocumentor/shim": "^3.8"
1617
},
1718
"require-dev": {
18-
"phpunit/phpunit": "^9.0"
19+
"phpunit/phpunit": "^9.0",
20+
"saggre/phpdocumentor-markdown": "^1.0"
1921
},
2022
"autoload": {
2123
"psr-4": {
@@ -26,5 +28,10 @@
2628
"psr-4": {
2729
"LingoDotDev\\Sdk\\Tests\\": "tests/"
2830
}
31+
},
32+
"config": {
33+
"allow-plugins": {
34+
"phpdocumentor/shim": true
35+
}
2936
}
3037
}

src/LingoDotDevEngine.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function __construct(array $config = [])
9797
*
9898
* @param array<string, mixed> $payload Content to translate, structured as key-value pairs
9999
* @param array<string, mixed> $params Translation configuration options
100-
* @param callable(int, mixed, mixed): void|null $progressCallback Callback invoked with completion percentage (0-100), current chunk, and processed chunk
100+
* @param null|callable(int, mixed, mixed): void $progressCallback Callback invoked with completion percentage (0-100), current chunk, and processed chunk
101101
*
102102
* @return array<string, mixed> Translated content maintaining original structure
103103
*
@@ -300,7 +300,7 @@ private function _createId(): string
300300
* - 'sourceLocale' (string|null): Language code of original text, null for auto-detection
301301
* - 'fast' (bool): Trade translation quality for speed
302302
* - 'reference' (array): Context or glossary terms to guide translation
303-
* @param callable(int, mixed, mixed): void|null $progressCallback Invoked per batch with (percentage complete, current batch, translated batch)
303+
* @param null|callable(int, mixed, mixed): void $progressCallback Invoked per batch with (percentage complete, current batch, translated batch)
304304
*
305305
* @return array<string, mixed> Translated data preserving original structure and non-text values
306306
*
@@ -329,7 +329,7 @@ public function localizeObject(array $obj, array $params, ?callable $progressCal
329329
* - 'sourceLocale' (string|null): Language code of original text, null for auto-detection
330330
* - 'fast' (bool): Prioritize speed over translation quality
331331
* - 'reference' (array): Context, terminology, or style guidelines for translation
332-
* @param callable(int): void|null $progressCallback Called with completion percentage (0-100) during processing
332+
* @param null|callable(int): void $progressCallback Called with completion percentage (0-100) during processing
333333
*
334334
* @return string Translated text, or empty string if translation unavailable
335335
*
@@ -398,7 +398,7 @@ public function batchLocalizeText(string $text, array $params): array
398398
* - 'sourceLocale' (string|null): Language of original messages, null for auto-detection
399399
* - 'fast' (bool): Optimize for speed over translation quality
400400
* - 'reference' (array): Conversation context or domain-specific terminology
401-
* @param callable(int): void|null $progressCallback Called with completion percentage (0-100) during processing
401+
* @param null|callable(int): void $progressCallback Called with completion percentage (0-100) during processing
402402
*
403403
* @return array<int, array{name: string, text: string}> Translated messages keeping original speaker names unchanged
404404
*

0 commit comments

Comments
 (0)