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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ indent_style = tab
indent_size = tab
tab_width = 4

[{*.yaml, *.yml, *.md}]
[*.{json,yaml,yml,md}]
indent_style = space
indent_size = 2
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.docs export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
Makefile export-ignore
README.md export-ignore
phpstan.neon export-ignore
ruleset.xml export-ignore
tests export-ignore
10 changes: 0 additions & 10 deletions .github/.kodiak.toml

This file was deleted.

3 changes: 2 additions & 1 deletion .github/workflows/codesniffer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: "Codesniffer"

on:
pull_request:
workflow_dispatch:

push:
branches: ["*"]
Expand All @@ -12,6 +13,6 @@ on:
jobs:
codesniffer:
name: "Codesniffer"
uses: contributte/.github/.github/workflows/codesniffer.yml@v1
uses: contributte/.github/.github/workflows/codesniffer.yml@master
with:
php: "8.4"
5 changes: 3 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ name: "Coverage"

on:
pull_request:
workflow_dispatch:

push:
branches: ["*"]

schedule:
- cron: "0 8 * * 1"
- cron: "0 9 * * 1"

jobs:
coverage:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester-coverage.yml@v1
uses: contributte/.github/.github/workflows/nette-tester-coverage-v2.yml@master
with:
php: "8.4"
5 changes: 3 additions & 2 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ name: "Phpstan"

on:
pull_request:
workflow_dispatch:

push:
branches: ["*"]

schedule:
- cron: "0 8 * * 1"
- cron: "0 10 * * 1"

jobs:
phpstan:
name: "Phpstan"
uses: contributte/.github/.github/workflows/phpstan.yml@v1
uses: contributte/.github/.github/workflows/phpstan.yml@master
with:
php: "8.4"
29 changes: 18 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,42 @@ name: "Nette Tester"

on:
pull_request:
workflow_dispatch:

push:
branches: [ "*" ]

schedule:
- cron: "0 8 * * 1"
- cron: "0 10 * * 1"

jobs:
php85:
test85:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.5"

test82:
test84:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.2"
php: "8.4"

test83:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.3"

test81:
test82:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.1"
php: "8.2"

testlower:
name: "Nette Tester"
uses: contributte/.github/.github/workflows/nette-tester.yml@v1
uses: contributte/.github/.github/workflows/nette-tester.yml@master
with:
php: "8.1"
php: "8.2"
composer: "composer update --no-interaction --no-progress --prefer-dist --prefer-stable --prefer-lowest"
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
# IDE
/.idea

# Composer
/vendor
/composer.lock

# Tests
/tests/tmp
/coverage.*
/tests/**/*.log
/tests/**/*.html
/tests/**/*.expected
/tests/**/*.actual
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For details on how to use this package, check out our [documentation](.docs).

| State | Version | Branch | Nette | PHP |
|--------|---------|----------|--------|---------|
| dev | `^5.1` | `master` | `4.0+` | `>=8.1` |
| dev | `^5.1` | `master` | `4.0+` | `>=8.2` |
| stable | `^5.0` | `master` | `3.0+` | `>=8.1` |

## Development
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
},
"autoload-dev": {
"psr-4": {
"Contributte\\ApiDocu\\Tests\\": "tests"
"Tests\\": "tests"
}
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"nette/http": "^3.2.3",
"nette/application": "^3.1.14",
"nette/di": "^3.1.8",
Expand All @@ -45,7 +45,7 @@
"require-dev": {
"contributte/qa": "^0.4",
"contributte/tester": "^0.3",
"contributte/phpstan": "^0.1",
"contributte/phpstan": "^0.2",
"mockery/mockery": "^1.6.6",
"tracy/tracy": "^2.10.5"
},
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ includes:

parameters:
level: 9
phpVersion: 80100
phpVersion: 80200

scanDirectories:
- src
Expand Down
2 changes: 1 addition & 1 deletion ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Contributte" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<!-- Rulesets -->
<rule ref="./vendor/contributte/qa/ruleset-8.0.xml">
<rule ref="./vendor/contributte/qa/ruleset-8.2.xml">
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar"/>
</rule>

Expand Down
2 changes: 1 addition & 1 deletion src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function createTemplate(string $which): Template
$template = $this->templateFactory->createTemplate();
assert($template instanceof DefaultTemplate);

$template->getLatte()->addFilterLoader('Contributte\ApiDocu\TemplateFilters::common');
$template->getLatte()->addFilter('description', TemplateFilters::description(...));

$template->setFile(__DIR__ . '/templates/' . $which);

Expand Down
28 changes: 3 additions & 25 deletions src/TemplateFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,13 @@
class TemplateFilters
{

public static function common(string $filter): ?string
public static function description(string $text): string
{
if (method_exists(self::class, $filter)) {
$args = func_get_args();
array_shift($args);

$callback = [self::class, $filter];

if (!is_callable($callback)) {
throw new \UnexpectedValueException();
}

return ($callback)($args);
}

return null;
}

/**
* @param array<mixed> $text
*/
public static function description(array $text): string
{
$text = reset($text);
$text = nl2br($text); // @phpstan-ignore-line
$text = nl2br($text);
$text = str_replace(["\n", "\n\r", "\r\n", "\r"], '', $text);

$text = preg_replace_callback('/<json><br \/>(.*?)<\/json>/s', function ($item): string {
$s = '<br><pre class="apiDocu-json">' . str_replace('<br>', '', (string) end($item)) . '</pre>';
$s = '<br><pre class="apiDocu-json">' . str_replace('<br>', '', end($item)) . '</pre>';
$s = (string) preg_replace('/(\s)"([^"]+)"/', '$1<span class="apiDocu-string">"$2"</span>', $s);
$s = (string) preg_replace('/\/\/(.*?)<br \/>/', '<span class="apiDocu-comment">//$1</span><br>', $s);

Expand Down
4 changes: 0 additions & 4 deletions tests/.coveralls.yml

This file was deleted.

10 changes: 0 additions & 10 deletions tests/.gitignore

This file was deleted.