theseer / phpdox

Documentation generator for PHP Code using standard technology (SRC, DOCBLOCK, XML and XSLT)
http://phpdox.de
Other
600 stars 121 forks source link

exclude directory #293

Closed Snoozerworks closed 7 years ago

Snoozerworks commented 7 years ago

Hi, I cannot exclude directory using the tag. I have a file structure like \ \dir1 \dir2 \extras

My configuration files is located in extras and looks like below with some of the patterns I have tried (one at a time). None works.

<?xml version="1.0" encoding="utf-8" ?>
<phpdox xmlns="http://xml.phpdox.net/config">
  <project name="WebSys" source="${basedir}/.." workdir="${basedir}/build/api/xml">
    <collector backend="parser" >
        <include mask="*.php" />    
        <include mask="*.class.inc" />
        <exclude mask="_*" />
        <exclude mask="extras/" />  <!-- Directory still included -->       
        <exclude mask="extras\" />  <!-- Directory still included -->       
        <exclude mask="**/*extras*" />  <!-- Inspired by issue #124 but dosen't work for me. Excludes _all_ files. -->
        <exclude mask="*extras" />  <!-- Directory extras still included -->        
        <exclude mask="extras\\" /> <!-- Directory included -->     
        <exclude mask="extras" />   <!-- Directory still included -->       
        <exclude mask="**extras**" />   <!-- Excludes _all_ files. -->
    </collector>
    <generator output="${basedir}/../admin_access/doc">
      <build engine="html" output="html"/>
    </generator>

  </project>
</phpdox>

I cannot find anything that excludes the "extras" directory from being parsed. Problem seems similar to issue #124 although the solution does not work for me. What pattern is supposed to work? I am on a Win 7 machine running PHP 5.6.24.

theseer commented 7 years ago

Sorry for the long time in answering. In case you still are looking for an answer, here it goes:

The exclude works by use of PHP's function fnmatch(). The problem why it's not working as expected lies in the fact the source path given is relative to the directory you try to exclude. Your source directory is set to ${basedir}/... After resolving the variable the path reads: /extras/...

For example on a file /extras/../dir1/foo.php:

<exclude mask="extras/" />  <!-- Directory still included -->       
<exclude mask="extras\" />  <!-- Directory still included -->       
<exclude mask="extras" />   <!-- Directory still included -->       
<exclude mask="extras\\" /> <!-- Directory included -->     

Makes sense, since neither mask is an exact match for the file-path. As it doesn't contain any wildcard, it's not even technically a mask.

<exclude mask="**/*extras*" />  <!-- Inspired by issue #124 but dosen't work for me. Excludes _all_ files. -->
<exclude mask="**extras**" />   <!-- Excludes _all_ files. -->

Given the above explanation, this is also expected as it will match for every file.

The interesting question is: Should the path from the configuration resolve relative definitions like .. before returning it?

theseer commented 7 years ago

No feedback. Closing for now.