-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from Aeliot-Tm/inline_config
Implement inline config EXTRAS
- Loading branch information
Showing
44 changed files
with
1,931 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Configuration file | ||
|
||
It expects that file `.todo-registrar.php` or `.todo-registrar.dist.php` added in the root directory of project. | ||
It may be put in any other place, but you have to define path to it when call the script with option `--config=/path/to/cofig`. | ||
|
||
Config file is php-file which returns instance of class `\Aeliot\TodoRegistrar\Config`. See [example](../.todo-registrar.dist.php). | ||
|
||
## Methods | ||
|
||
| Method | Is Required | | ||
|------------------------|-------------| | ||
| setFinder | yes | | ||
| setInlineConfigFactory | no | | ||
| setInlineConfigReader | no | | ||
| setRegistrar | yes | | ||
| setTags | no | | ||
|
||
|
||
### setFinder | ||
|
||
Accepts instance of configured finder (`\Aeliot\TodoRegistrar\Service\File\Finder`) responsible for finding of php-files. | ||
Very similar to configuration of Finder for "PHP CS Fixer". | ||
|
||
### setInlineConfigFactory | ||
|
||
Accepts instance of `\Aeliot\TodoRegistrar\InlineConfigFactoryInterface` | ||
|
||
You can implement and expects instance of your custom inline config in your registrar. | ||
This method permits to provide factory for it. | ||
|
||
### setInlineConfigReader | ||
|
||
Accepts instance of `\Aeliot\TodoRegistrar\InlineConfigReaderInterface`. | ||
|
||
So, you can use your own reader of inline config which support your preferred format or relay on build-in. | ||
|
||
### setRegistrar | ||
|
||
Responsible for configuration of registrar factory. | ||
|
||
It accepts two arguments: | ||
1. First one is registrar type (`\Aeliot\TodoRegistrar\Enum\RegistrarType`) | ||
or instance of registrar factory (`\Aeliot\TodoRegistrar\Service\Registrar\RegistrarFactoryInterface`). | ||
2. Second one is array of config for registrar. See [example for JIRA](registrar/jira/config.md). | ||
|
||
So, you can use build-in registrar or pass your own. | ||
|
||
### setTags | ||
|
||
Permit to define array of tags to be detected. | ||
|
||
Script supports `TODO` and `FIXME` by default. | ||
You don't need to configure it when you want to use only this tags. Nevertheless, you have to set them | ||
when you want to use them together with your custom tags. | ||
|
||
Don't wary about case of tags. They will be found in case-insensitive mode. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
## Inline Configuration | ||
|
||
Script supports inline configuration of each TODO-comment. It helps flexibly configure different aspects of created issues. | ||
Like relations to other issues, labels, components and so on. | ||
|
||
Very flexible tool. A format similar to js objects or JSON, only without quotes. | ||
It is so-called "EXTRAS" case they started with `{EXTRAS: ...`. It should be a part of multi-line commit | ||
and indented a description ([see supported formats](supported_patters_of_comments.md)). | ||
The system expects no more than one inline config per TODO. And it would be nice to keep them as last part of TODO-commit. | ||
|
||
It may be split to multiple lines. But don't forget about indents of each line. | ||
|
||
```php | ||
/** | ||
* [email protected]: summary of issue (title) | ||
* And some complex description on second line and below. | ||
* Fell you free to add any complex description as you wish. | ||
* But don't forget to start each line on same column as summary (title) or later. | ||
* And suit same rule for EXTRAS, which can be split to multiple lines with any spaces. | ||
* See below. | ||
* {EXTRAS: { | ||
* someKey: [value1, value2], | ||
* moreComplexData: {key1: [v3], key2: { | ||
* neverMindHowManyLevels: [v4] | ||
* }} | ||
* }} | ||
*/ | ||
``` | ||
|
||
### Example | ||
|
||
Below are examples of settings supported by the implemented JIRA-registrar. | ||
|
||
1. Do you need to provide a related ticket? Easily. | ||
``` | ||
{EXTRAS: {linkedIssues: XX-123}} | ||
``` | ||
2. Do you need to link multiple tickets? So: | ||
``` | ||
{EXTRAS: {linkedIssues: [XX-123, XX-234]}} | ||
``` | ||
3. Do you need to link tickets with different link types? Easily. | ||
``` | ||
{EXTRAS: {linkedIssues: {child_of: XX-123, is_blocked_by: [XX-234, YY-567]}}} | ||
``` | ||
4. Labels and components can be provided in the same way. | ||
``` | ||
{EXTRAS: {labels: [label-a, label-b], components: [component-a, component-b]}} | ||
``` | ||
|
||
## The order of applying of configs | ||
1. `@assignee` joined to TODO-tag. | ||
2. `EXTRAS` | ||
3. Then the [general config](config.md) of the JIRA registrar. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Supported formats and patterns of comments | ||
|
||
It detects TODO-tags in single-line comments started with both `//` and `#` symbols | ||
and multiple-line comments `/* ... */` and phpDoc `/** ... **/`. | ||
|
||
1. Tag and comment separated by colon | ||
```php | ||
// TODO: comment summary | ||
``` | ||
2. Tag and comment does not separated by colon | ||
```php | ||
// TODO comment summary | ||
``` | ||
3. Tag with assignee and comment separated by colon | ||
```php | ||
// TODO@assigne: comment summary | ||
``` | ||
4. Tag with assignee and comment does not separated by colon | ||
```php | ||
// TODO@assigne comment summary | ||
``` | ||
5. Multiline comment with complex description. All lines after the first one with tag MUST have indentation | ||
same to the text of the first line. So, all af them will be detected af part of description of TODO. | ||
Multiple line comments may have assignee and colon same as single-line comments/. | ||
```php | ||
/** | ||
* TODO: comment summary | ||
* and some complex description | ||
* which must have indentation same as end of one presented: | ||
* - colon | ||
* - assignee | ||
* - tag | ||
* So, all this text will be passed to registrar as description | ||
* without not meaning indentations (" * " in this case). | ||
* This line (and all after) will not be detected as part (description) of "TODO" | ||
* case they don't have expected indentation. | ||
*/ | ||
``` | ||
|
||
As a result of processing of such comments, ID of ISSUE will be injected before comment summary | ||
and after colon and assignee when they are presented. For example: | ||
1. Tag and comment separated by colon | ||
```php | ||
// TODO: XX-001 comment summary | ||
``` | ||
2. Tag and comment does not separated by colon | ||
```php | ||
// TODO XX-001 comment summary | ||
``` | ||
3. Tag with assignee and comment separated by colon | ||
```php | ||
// TODO@assigne: XX-001 comment summary | ||
``` | ||
4. Tag with assignee and comment does not separated by colon | ||
```php | ||
// TODO@assigne XX-001 comment summary | ||
``` | ||
5. Multiline comment with complex description. All lines after the first one with tag MUST have indentation | ||
same to the text of the first line. So, all af them will be detected af part of description of TODO. | ||
Multiple line comments may have assignee and colon same as single-line comments/. | ||
```php | ||
/** | ||
* TODO: XX-001 comment summary | ||
* and some complex description | ||
*/ | ||
``` | ||
|
||
### Assignee-part | ||
|
||
It is some "username" which separated of tag by symbol "@". It sticks to pattern `/[a-z0-9._-]+/i`. | ||
System pass it in payload to registrar with aim to be used as "identifier" of assignee in issue tracker. | ||
|
||
## Compatibility | ||
|
||
Script implemented to support formats of "comments with expiration" provided by [staabm/phpstan-todo-by](https://github.com/staabm/phpstan-todo-by). | ||
On my point of view, it is cool feature which I'd like to use in my projects. | ||
|
||
So, script ignores comments which already have mark of "expiration". |
Oops, something went wrong.