Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Initial commit
  • Loading branch information
markuspoerschke committed Nov 9, 2019
0 parents commit c739994
Show file tree
Hide file tree
Showing 22 changed files with 1,116 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
@@ -0,0 +1,11 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.{yaml,yml}]
indent_size = 2
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
/.phpunit.result.cache
/composer.lock
/vendor/
40 changes: 40 additions & 0 deletions .php_cs.dist
@@ -0,0 +1,40 @@
<?php

$headerComment = <<<DOC
This file is part of the cvc/twig-documentor package.
(c) CARL von CHIARI GmbH <opensource@cvc.digital>
This source file is subject to the MIT license that is bundled
with this source code in the file LICENSE.
DOC;

return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'general_phpdoc_annotation_remove' => ['@author', '@package', '@subpackage'],
'heredoc_to_nowdoc' => true,
'linebreak_after_opening_tag' => true,
'mb_str_functions' => true,
'no_php4_constructor' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'php_unit_strict' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'semicolon_after_instruction' => true,
'simplified_null_return' => true,
'header_comment' => [
'header' => $headerComment,
],
'yoda_style' => false,
])
->setRiskyAllowed(true)
->setFinder(PhpCsFixer\Finder::create()->in('.'))
->setUsingCache(true)
;
74 changes: 74 additions & 0 deletions .travis.yml
@@ -0,0 +1,74 @@
language: php

addons:
apt:
packages:
- parallel

cache:
directories:
- $HOME/.composer/cache

stages:
- static_analysis
- test

.Unit Tests Template: &unit_tests
stage: test
install:
- composer install
script:
- php vendor/bin/phpunit -c ./phpunit.xml --coverage-clover=coverage.xml
- bash <(curl -s https://codecov.io/bash)

.Lint PHP: &lint_php
stage: static_analysis
script:
- find . -name \*.php ! -path "./.Build/*" ! -path "./vendor/*" | parallel --gnu php -d display_errors=stderr -l {} > /dev/null \;;

.Lint Editorconfig: &editor_config
stage: static_analysis
install:
- npm install -g editorconfig-checker@^2.0
script:
- editorconfig-checker

.Psalm: &psalm
stage: static_analysis
install:
- if [ -z "$dependencies" ]; then composer update --prefer-dist --no-progress; fi;
- if [ "$dependencies" = "lowest" ]; then composer update --prefer-dist --no-progress --prefer-lowest -n; fi;
script:
- php ./vendor/bin/psalm --shepherd

jobs:
include:
- <<: *lint_php
name: Lint PHP 7.3
php: 7.3
- <<: *lint_php
name: Lint PHP 7.2
php: 7.2
- <<: *editor_config
name: Lint Editorconfig
php: 7.3
- <<: *psalm
name: Psalm (PHP 7.3)
php: 7.3
- <<: *psalm
name: Psalm (PHP 7.2)
php: 7.2
- <<: *unit_tests
name: Unit Tests (PHP 7.3, highest)
php: 7.3
- <<: *unit_tests
name: Unit Tests (PHP 7.2, highest)
php: 7.2
- <<: *unit_tests
name: Unit Tests (PHP 7.3, lowest)
php: 7.3
env: dependencies=lowest
- <<: *unit_tests
name: Unit Tests (PHP 7.2, lowest)
php: 7.2
env: dependencies=lowest
10 changes: 10 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.0.0

### Added
* Initial release of the Twig Documentor package
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 CARL von CHIARI GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
36 changes: 36 additions & 0 deletions README.md
@@ -0,0 +1,36 @@
# Twig Documentor

Automatically generates documentation for Twig extensions.

## Installation

```
composer require --dev cvc/twig-documentor
```

## Usage

```php
<?php

$environment = new \Twig\Environment(new \Twig\Loader\ArrayLoader());
$environmentDescriber = new \Cvc\TwigDocumentor\Describer\EnvironmentDescriber(
new \Cvc\TwigDocumentor\Describer\FunctionDescriber(\phpDocumentor\Reflection\DocBlockFactory::createInstance()),
new \Cvc\TwigDocumentor\Describer\FilterDescriber(\phpDocumentor\Reflection\DocBlockFactory::createInstance())
);
$documentation = $environmentDescriber->describe($environment);
$documentation = $documentation->withSource(__DIR__.'/*');
```

## Development Team

<table>
<tr>
<td align="center" valign="top">
<img width="150" height="150" src="https://github.com/markuspoerschke.png?s=150">
<br>
<a href="https://github.com/markuspoerschke">Markus Poerschke</a>
<p>Developer</p>
</td>
</tr>
</table>
46 changes: 46 additions & 0 deletions composer.json
@@ -0,0 +1,46 @@
{
"type": "library",
"name": "cvc/twig-documentor",
"description": "Automatically generates documentation for Twig extensions.",
"homepage": "https://cvc.digital",
"support": {
"issues": "https://github.com/cvc-digital/twig-documentor/issues",
"source": "https://github.com/cvc-digital/twig-documentor"
},
"license": "MIT",
"authors": [
{
"name": "Markus Poerschke",
"email": "poerschke@cvc.digital",
"homepage": "https://cvc.digital",
"role": "Developer"
},
{
"name": "CARL von CHIARI GmbH",
"email": "opensource@cvc.digital",
"homepage": "https://cvc.digital",
"role": "Maintainer"
}
],
"require": {
"php": ">=7.2,<7.4",
"twig/twig": "^2.0",
"phpdocumentor/reflection-docblock": "^4.3"
},
"require-dev": {
"phpunit/phpunit": "^8",
"friendsofphp/php-cs-fixer": "^2.3",
"vimeo/psalm": "^3.6",
"symfony/var-dumper": "^3|^4"
},
"autoload": {
"psr-4": {
"Cvc\\TwigDocumentor\\": "src"
}
},
"extra": {
"branch-alias": {
"dev-master": "0.x-dev"
}
}
}
25 changes: 25 additions & 0 deletions phpunit.xml
@@ -0,0 +1,25 @@
<phpunit
backupGlobals="true"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="false"
beStrictAboutTestsThatDoNotTestAnything="false">
<testsuites>
<testsuite name="Unit tests">
<directory>tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
55 changes: 55 additions & 0 deletions psalm.xml
@@ -0,0 +1,55 @@
<?xml version="1.0"?>
<psalm
totallyTyped="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<LessSpecificReturnType errorLevel="info" />

<!-- level 3 issues - slightly lazy code writing, but provably low false-negatives -->

<DeprecatedMethod errorLevel="info" />
<DeprecatedProperty errorLevel="info" />
<DeprecatedClass errorLevel="info" />
<DeprecatedConstant errorLevel="info" />
<DeprecatedFunction errorLevel="info" />
<DeprecatedInterface errorLevel="info" />
<DeprecatedTrait errorLevel="info" />

<InternalMethod errorLevel="info" />
<InternalProperty errorLevel="info" />
<InternalClass errorLevel="info" />

<MissingClosureReturnType errorLevel="info" />
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
<MissingClosureParamType errorLevel="info" />
<MissingParamType errorLevel="info" />

<RedundantCondition errorLevel="info" />

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />

<UnresolvableInclude errorLevel="info" />

<RawObjectIteration errorLevel="info" />

<InvalidStringClass errorLevel="info" />
</issueHandlers>
</psalm>

0 comments on commit c739994

Please sign in to comment.