Cannot exclude single file
smileBeda opened this issue · 3 comments
I have an issue trying to exclude single files, using the --exclude
argument
It works fine when I exclude a whole folder, yet I just want to exclude one file.
It seems to ignore the --exclude
statement, if I pass a valid filename, but it works when I pass a valid folder name.
Example:
--exclude=foldername
=> works (excludes whole foldername
folder)
--exclude=filename.php
=> fails (does not exclude that file)
I have also tried with foldername/filename
and different other syntax, inclusive brackets, and it just seems to ignore it when the name passed is not a folder.
According the description however it seems it should be possible to exclude single files?
Even better would be to exclude occurrences it cannot parse and just skip. I have a peculiar plugin that does something like this:
do_action( $atts['hook_name'] );
Of course, that hook fails in the parser with these errors:
Not supported hook tag expression `PhpParser\Node\Expr\ArrayDimFetch`: $att
s['hook_name'].
Could not convert tag argument value to a name in path/to/file/filename.php#N.
This is why I want to exclude that file, but of course if there's an easy way to just skip when failing, instead of halting, that would be the best!
Excluding files should be fixed in 3422b48.
We could introduce a --ignore-unsupported-tag-names
flag or introduce something like:
- https://phpstan.org/user-guide/ignoring-errors#ignoring-in-code-using-phpdocs
- https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file
/**
* Docblock.
*
* @pronamic-wp-documentor-ignore This action cannot be documented due to the dynamic tag name.
*/
do_action( $atts['hook_name'] );
Is excluding the file enough or do you lean more towards the above?
I’d love a more granular control, but in the end it depends on feasibility.
I have personally only one filter and one action in that file and it’s accidentally each the unsupported one.
But who knows this could be something useful actually to exclude by tags, because sometimes I also want to exclude filters or actions just because they shouldn’t be documented
perhaps listening to an @ignore tag would be better so the document block can control it instead of the hook tag?
(Honestly I’ve not even tried if this would actually already do the trick)
Add support for the @ignore
tag seems like a great solution to me, added a new issue for this: