-
Notifications
You must be signed in to change notification settings - Fork 937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow unused tags to be kept #1647
allow unused tags to be kept #1647
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, just some nits and arguing about naming :)
src/Processors/AugmentTags.php
Outdated
@@ -15,6 +15,22 @@ | |||
*/ | |||
class AugmentTags implements ProcessorInterface | |||
{ | |||
|
|||
/** @var array<string> */ | |||
protected $unusedTagsToKeepWhitelist = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected $unusedTagsToKeepWhitelist = []; | |
protected $unusedTagsToKeepWhitelist; |
I think the other processors only intialize in the constructor and that should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based it off CleanUnusedComponents, makes sense to only do it in one spot though.
src/Processors/AugmentTags.php
Outdated
/** @var array<string> */ | ||
protected $unusedTagsToKeepWhitelist = []; | ||
|
||
public function __construct(array $unusedTagsToKeepWhitelist = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function __construct(array $unusedTagsToKeepWhitelist = []) | |
public function __construct(array $whitelist = []) |
It think this should be meaningful enough? This class is all about tags, after all.
src/Processors/AugmentTags.php
Outdated
@@ -48,8 +65,10 @@ public function __invoke(Analysis $analysis) | |||
} | |||
} | |||
|
|||
// remove tags that we don't want to keep (defaults to all unused tags) | |||
$tagsToKeep = array_merge($usedTagNames, $this->unusedTagsToKeepWhitelist); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could there be a special case of '*'
which would keep all tags?
src/Processors/AugmentTags.php
Outdated
$this->unusedTagsToKeepWhitelist = $unusedTagsToKeepWhitelist; | ||
} | ||
|
||
public function setUnusedTagsToKeepWhitelist(array $unusedTagsToKeepWhitelist): AugmentTags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function setUnusedTagsToKeepWhitelist(array $unusedTagsToKeepWhitelist): AugmentTags | |
/** | |
* Whitelist tags to keep even if not used. <code>*</code> may be used to keep all unused. | |
*/ | |
public function setUnusedTagsToKeepWhitelist(array $unusedTagsToKeepWhitelist): AugmentTags |
The docblock on the setXXX()
method is used to auto-generate the processor reference, so adding something here would be good.
Thanks @pauljohnston2009 |
The changes in #1625 mean that we cannot have descriptive tags that do not have a reference to them from an operation. It is nice to allow this so we can have pages dedicated to be informative only (and allow external links directly to that section in the page).
eg. tags like