peej/phpdoctor

file level comment feature results in each file being processed twice

DerManoMann opened this issue · 7 comments

Hi there,

I think it would be good to be able to enable/disable file level comments.
All of my source files do have a licence text as first comment. That means it will be taken as file level commment.
The result is that phpdoc tries to process each file twice - once with the package as per @Package on the actual code and then again with a package based on the file path.
Beside being annoying the second run fails as the path is not created and this the htmlWriter fails to write and phpdoc exists with error.

Actually, this happens even if I remove the special code that looks at the first comment ($commentNumner == 1)

Actuallly, actually...
Just realized that this might really be the view source feature. The files phpdoctor tries to create are located under source.
In this case it is probably just a question to add code that ensures the path exists - similar to the code for creating the html doc files

peej commented

Can you post the error msg you get here, presumably if PHPDoctor can read the file to process it, it should be able to read it to output its source.

Yeah, sorry, should have thought about that myself..

Here's a cut&paste version of the relevant bits. I later found that I can disable the whole feature with include_source = off in the ini file - my ini file comes from the repository and I didn't check for changes/additions...

So, what happens is that the code wants to write the source file to be used for the source file links in the docs. However, it doesn't check / ensure the directory exists it wants to write to...

 [exec] PHP Warning:  fopen(C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zenmagick\docs\apidocs\0.9.9+.20100726/source/build\zmlibrarypacker.php.html): failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\doclets\standard\htmlWriter.php on line 226
 [exec] PHP Stack trace:
 [exec] PHP   1. {main}() C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\phpdoc.php:0
 [exec] PHP   2. PHPDoctor->execute() C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\phpdoc.php:53
 [exec] PHP   3. Standard->standard() C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\classes\phpDoctor.php:1072
 [exec] PHP   4. SourceWriter->sourceWriter() C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\doclets\standard\standard.php:179
 [exec] PHP   5. HTMLWriter->_write() C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\doclets\standard\sourceWriter.php:112
 [exec] 
 [exec] Warning: fopen(C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zenmagick\docs\apidocs\0.9.9+.20100726/source/build\zmlibrarypacker.php.html): failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\doclets\standard\htmlWriter.php on line 226
 [exec] 
 [exec] Call Stack:
 [exec]     0.0004     334240   1. {main}() C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\phpdoc.php:0
 [exec]     4.5616    8615664   2. PHPDoctor->execute() C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\phpdoc.php:53
 [exec]     4.5758    9400632   3. Standard->standard() C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\classes\phpDoctor.php:1072
 [exec]    16.5741    9745896   4. SourceWriter->sourceWriter() C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\doclets\standard\standard.php:179
 [exec]    16.5765    9752840   5. HTMLWriter->_write() C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\doclets\standard\sourceWriter.php:112
 [exec]    16.5767    9753448   6. fopen() C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\doclets\standard\htmlWriter.php:226
 [exec] 
 [exec] PHP   6. fopen() C:\Program FiERROR: Could not write "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\zenmagick\docs\apidocs\0.9.9+.20100726/source/build\zmlibrarypacker.php.html"
 [exec] les\Apache Software Foundation\Apache2.2\htdocs\phpdoctor\doclets\standard\htmlWriter.php:226
peej commented

I think this may have been due to the way the HTML writer creates directories that don't exist and it getting confused by Windows directory separators. I've adjusted the HTML writer so it shouldn't trip up on these any more. Can you please update and give it a test for me since I don't have a Windows machine to test it on.

yep, that's better - thanks.

BTW: Are you goging to drop PHP4 support any time soon? It would be nice to get rid of the deprecated warnings about using references...

peej commented

There's still loads of PHP4 code out there, dropping PHP4 support would stop that code from being documented, so it's not something I'm looking at doing. Obviously I want to support PHP5 and 6 as much as possible, would turning off E_STRICT stop the deprecated warnings from showing up?

I think you might have to tinker with that - did switched off error reporting, but still got some deprecated warnings. I can never remember off the top of my head how to apply those flags properly...