Skip to content
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

Merged
merged 5 commits into from
Sep 22, 2024

Conversation

pauljohnston2009
Copy link
Contributor

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

  • introduction
  • setup
  • how-to

Copy link
Collaborator

@DerManoMann DerManoMann left a 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 :)

@@ -15,6 +15,22 @@
*/
class AugmentTags implements ProcessorInterface
{

/** @var array<string> */
protected $unusedTagsToKeepWhitelist = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
protected $unusedTagsToKeepWhitelist = [];
protected $unusedTagsToKeepWhitelist;

I think the other processors only intialize in the constructor and that should be enough.

Copy link
Contributor Author

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.

/** @var array<string> */
protected $unusedTagsToKeepWhitelist = [];

public function __construct(array $unusedTagsToKeepWhitelist = [])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@@ -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);
Copy link
Collaborator

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?

$this->unusedTagsToKeepWhitelist = $unusedTagsToKeepWhitelist;
}

public function setUnusedTagsToKeepWhitelist(array $unusedTagsToKeepWhitelist): AugmentTags
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@DerManoMann DerManoMann merged commit 8e19141 into zircote:master Sep 22, 2024
21 checks passed
@DerManoMann
Copy link
Collaborator

Thanks @pauljohnston2009

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants