Coder Social home page Coder Social logo

peej / phpdoctor Goto Github PK

View Code? Open in Web Editor NEW
134.0 8.0 30.0 2.87 MB

PHPDoctor is an attempt to create a simpler and faster PHPDoc (Javadoc style comment parser for PHP) that produces standards compliant HTML.

Home Page: http://peej.github.com/phpdoctor/

License: GNU General Public License v2.0

PHP 98.92% CSS 1.08%

phpdoctor's Issues

Participate in DocSpec

Hi,

I currently worked out a specification to make results of DocTools interoperable. This is completely new and the spec is just one day old. The idea of this spec is, that doctools deliver their output in this interoperable format and generating the output can be done by others, that don't want to work on the parsing part.

The benefits would be:

  • End users can choose whatever doctool they want and which output generator they want.
  • Doctool developers can focus on parsing the code, generate a standardised output and leave the output generation to the end users (doesn't that sound like less work for you?)

My blog post with my motivation for creating this: http://gos.si/blog/docspec-as-interoperable-file-format-between-doctools

As I said the DocSpec is not older than a day, you are invited to join here. Also if you feel like this idea suits your doctool, feel free to jump over to express your interesst in participating as an implementor.

The DocSpec is on github, ready to fork: https://github.com/gossi/docspec

Thank you
gossi

Include and link annotated source files

phpdoctor should include the original source code (optionally) in the output, annotated via e.g. GeSHi.

This would allow to link there from various places, e.g. from the all the places in the class documentation referring to the file.
Of course, this should include anchors for each line and those should get used where appropriate.

New Bugs

First of all, the generation does not work properly for me because of a problem in inheritDocTag.php on line 73...

PHP Fatal error: Call to a member function text() on a non-object in ...\phpdoctor\classes\inheritDocTag.php on line 73
PHP Stack trace:
PHP 1. {main}() D:\Downloads\phpdoctor\phpdoc.php:0
PHP 2. PHPDoctor->execute() D:\Downloads\phpdoctor\phpdoc.php:55
PHP 3. Standard->standard() D:\Downloads\phpdoctor\classes\phpDoctor.php:1139
PHP 4. ClassWriter->classWriter() D:\Downloads\phpdoctor\doclets\standard\standard.php:166
PHP 5. HTMLWriter->_processInlineTags() D:\Downloads\phpdoctor\doclets\standard\classWriter.php:190
PHP 6. InheritDocTag->text() D:\Downloads\phpdoctor\doclets\standard\htmlWriter.php:302

After this, I get a lot of HTML output and then the error again.

Fatal error: Call to a member function text() on a non-object in ...\phpdoctor\classes\inheritDocTag.php on line 73

Call Stack:
0.0006 335016 1. {main}() D:\Downloads\phpdoctor\phpdoc.php:0
59.7188 58986512 2. PHPDoctor->execute() D:\Downloads\phpdoctor\phpdoc.php:55
59.7291 59869920 3. Standard->standard() D:\Downloads\phpdoctor\classes\phpDoctor.php:1139
71.0484 59962832 4. ClassWriter->classWriter() D:\Downloads\phpdoctor\doclets\standard\standard.php:166
76.7687 60155936 5. HTMLWriter->_processInlineTags() D:\Downloads\phpdoctor\doclets\standard\classWriter.php:190
76.7692 60157608 6. InheritDocTag->text() D:\Downloads\phpdoctor\doclets\standard\htmlWriter.php:302

Not every class or interface is documented, some files are missing.
There are also some other problems i just noticed. If a class/interface is used somewhere, with the fact that it is not imported with the use-keyword because it is in the same package, and somewhere else a class/interface with the same name exists, then it can cause problems. This means in my special case, that there are two interfaces, blabla\cache\Cache and blublu\cache\Cache which are both used like that:

namespace blabla\cache;
class A implements Cache{...}

namespace blublu\cache;
class B implements Cache{...}

Now is the problem that the documentation site of class B is using blabla\cache\Cache and not the right one.

The next thing is, that when I allow different return/parameter types like a simple string and an OOP String like that:

@param \oop\String|string $value The string

Then it does not create a link to the class.

If a classes implement more that one interface, then only one is shown in the doc. Also the methods which these interfaces offer are not included.
If the inheritance is like that:

interface A{}

abstract class B implements A{}

class C extends B{}

Then in C is no documentatino about the interface A!

The field summary is formatted wrong, the left column gets about 50% of the width and this looks strange. I don't know if a link is created to the class doc for throws annotations but in the old version it is not.

A nice feature would be if classes which implement interfaces are mentioned in the doc of the interfaces, this would be more java like with links:

Direct Known Subclasses/Implementations ...

Interface implementations not shown

Interfaces are recognized during the doc generation and shown in the navigation, which is fine. They are not connected from the classes that implement them and vice versa. So:
class A implements MyInterface
In Javadoc this connection is shown on the class page. Saying this class implements these interfaces.
On the other side, Javadoc displays "All known implementing Classes" on each Interface.

Multiple @todo in single method breaks todoWriter

  /**
   * Set totals for order
   *
   * @todo data validation
   * @todo filter data
   * @param App_Order_Totals $totals
   * @return App_Order
   */
  public function setTotals($totals) { /* snip */ }
 [exec] <tr>
 [exec] <td class="name"><a href="globalnamespace/app_order.html#setTotals()">GlobalNamespace\App_Order\setTotals</a></td>
 [exec] <td class="description">
 [exec] Fatal error: Call to a member function firstSentenceTags() on a non-object in /var/www/App/vendor/phpdoctor/doclets/standard/htmlWriter.php on line 295
 [exec] 
 [exec] Call Stack:
 [exec]     0.0008     633176   1. {main}() /var/www/App/vendor/phpdoctor/phpdoc.php:0
 [exec]     2.2237   16905464   2. PHPDoctor->execute() /var/www/App/vendor/phpdoctor/phpdoc.php:55
 [exec]     2.2281   17750048   3. Standard->standard() /var/www/App/vendor/phpdoctor/classes/phpDoctor.php:1140
 [exec]     3.5026   17976704   4. TodoWriter->todoWriter() /var/www/App/vendor/phpdoctor/doclets/standard/standard.php:182
 [exec]     3.5075   18026288   5. HTMLWriter->_processInlineTags() /var/www/App/vendor/phpdoctor/doclets/standard/todoWriter.php:160

index parses html tags

In CodeIgniter there is a function named set_select which has the following docblock:

 /**
  * Set Select
  *
  * Let's you set the selected value of a <select> menu via data in the POST array.
  * If Form Validation is active it retrieves the info from the validation class
  *
  * @access public
  * @param  string
  * @param  string
  * @param  bool
  * @return string
  */

When I view the index for my documentation, I can only get to elements that alphabetically precede set_select, because phpdoctor parses that select tag and then stops output. This is all I see:

  set_select() - Function in package GiftFlow
     Set Select Let's you set the selected value of a  [[ DISPLAYS SELECT DROPDOWN HERE]]

Show Known Subclasses/Subinterfaces

Would be cool to see in the generated docs, which classes resp. interfaces are descendents of my currently viewed class/interface (similar to javadoc)

class constant handling

class constants are "documented" as final variables - which at least as of php 5.3 (static binding) is not correct...

class constants of type boolean get documented as "mixed" (always wrong for constants), while integer constants get "int" (correct).

Some constants - I didn't find a pattern yet - get documented with a preceding dollar sign; although NO instance with dollar sign is found in the sources.

Notice: undefined property PHPDoctor::$_pearCompat

With current Git I'm getting a lot of the following notices:

[...]
Writing "source/blogs/htsrv/async.php.html"
PHP Fatal error: Call to a member function containingPackage() on a non-object in /path/to/phpdoctor/classes/seeTag.php on line 79
PHP Stack trace:
PHP 1. {main}() /path/to/phpdoctor/phpdoc.php:0
PHP 2. PHPDoctor->execute() /path/to/phpdoctor/phpdoc.php:53
PHP 3. Standard->standard() /path/to/phpdoctor/classes/phpDoctor.php:1040
PHP 4. SourceWriter->sourceWriter() /path/to/phpdoctor/doclets/standard/standard.php:179
PHP 5. HTMLWriter->_processInlineTags() /path/to/phpdoctor/doclets/standard/sourceWriter.php:100
PHP 6. LinkTag->text() /path/to/phpdoctor/doclets/standard/htmlWriter.php:298
PHP 7. SeeTag->text() /path/to/phpdoctor/classes/linkTag.php:49

Does not escape HTML in code

When included code contains HTML (eg in global variable), it is not properly escaped.

For example following HTML is generated:

<code class="signature">public  mixed <strong>str_export1</strong> = '<select name="export_type"><option value="sqldumpfile">' . __('SQL dump (file download)'

Documentation of special behaviour of magic methods

Because of the possibility to use __callStatic or __call, there should be a @method annotation which allows the developer to document these things.
In addition to that, @Property(-read/-write) should be included into the fields table with the keyword final if only read access is allowed and for write only something else. Write only for a property is bad practise, but PHP offers you that possibility...

Feature Request

Here is a short list of features I am missing in phpdoctor:

  • General: Allow source path to be relative to the ini path
  • General: Allow @access to overwrite the given modifier -> check if $currentData['access'] is already set(~near at line 655)
  • Class Doc: Show all implemented interfaces
  • Class Doc: Show direct known subclasses
  • Class Doc: Link to the class in the "Methods inherited from class ..."-table
  • Interface Doc: Show all known implementing classes
  • Interface Doc: All known subinterfaces
  • Interface Doc: All superinterfaces

Support for page-level doc blocks

PHPDocumentor supports page-level documentation blocks, which describe the file itself, not the element following it.
In recent PHPDocumentor versions the logic to detect those is: first comment containing a @Package tag documents the file.

I would like to see support for this with phpdoctor, too.
At least it should be possible to not have those page-level blocks get assigned/used for the first var following it.

Running out of memory

On Fedora Linux, I'm trying to run PHPDoctor on a very large code base. It's hitting a fatal error when it runs out of memory at 1GB. This is odd, because I've given it 5GB in php.ini and with an inline set_ini('memory_limit','5120M'), and if I add phpinfo() to the top of phpdoc.php, it claims it has 5120M available. I don't see anything in its own .ini file that sets a limit.

It may turn out that I don't have enough RAM to throw at it to run on our whole code base, but first I want to see what it can do with 5GB. Any ideas?

Create todo list based on @todo tag

Hello,

I also have come from PhpDocumentor and I like to use the @todo tag in my code for reminding myself what to do. In PhpDocumentor this creates a single todo page but phpdoctor doesn't seem to support it yet. I would think to create an HTML file like readme.html that would show up under the All Items link will be perfect.

Thanks.

Document class member variables

Small feature request, document class member variables:

class Class1
{
    /** Documentation on member variable */
    string var;
};

Create PEAR package

PHPDoctor needs a PEAR package for easy installation. I think this would help the adoption of PHPDoctor.

Adding phpdoc.php to execution path does not work

Steps to reproduce (Unix):

  1. clone phpdoctor somewhere on your maching.
  2. cd /path/to/phpdoctor
  3. chmod +x phpdoc.php
  4. Add phpdoc.php to the environment path variable
    (I have a private bin directory from which I've created a symlink to /path/to/phpdoc.php
  5. cd /path/to/project
  6. Execute: phpdoc.php phpdoc.ini

Expected results:
phpdoctor should run

Actual results:

The following error is encountered:

PHP Warning:  require(classes/doc.php): failed to open stream: No such file or directory in /home/pgraham/projects/phpdoctor/classes/phpDoctor.php on line 40
PHP Fatal error:  require(): Failed opening required 'classes/doc.php' (include_path='.:/usr/share/php:/usr/share/pear:/home/pgraham/bin') in /home/pgraham/projects/phpdoctor/classes/phpDoctor.php on line 40

Patch:

The fix is pretty simple so I've included the diff here but if you prefer I can fork and make a Pull Request.

--- a/phpdoc.php
+++ b/phpdoc.php
@@ -32,7 +32,7 @@
 if (!isset($argv[0])) {
 }

 // include PHPDoctor class
-set_include_path(get_include_path() . PATH_SEPARATOR . dirname($argv[0]));
+set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__));
 require('classes'.DIRECTORY_SEPARATOR.'phpDoctor.php');

 // get name of config file to use

Treat overrode __construct taking different arguments

Hi,

I use __construct method for my constructors.
If arguments of a constructor defined in sub class are different from parent class,
the parent's constructor still gets documented in the sub class.
Could you change that please?

Thanks

@access private Should exclude methods

@access private Should exclude methods, this currently only works on fields.

This is very usefull if I want to exclude something as: __uglyPrivateFunctionName($with, $to, $much, $parameters)

file level comment feature results in each file being processed twice

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)

Internal linking

Although the website mentions the @see parameter phpdoctor seems to completely ignore it. I would expect this parameters to be parsed in such a way that I can click it in the documentation to go to the related method / class. The same goes for @return.

Is this still a planned feature, am I missing a configuration directive or is this simply not being implemented?

Thanks

support for {@inheritDoc}

I think we've discussed this a long time ago, but I can't find the docs any more.
My project uses @inheritdoc quite a lot (which looks not that great in the docs right now), so I think it's time to give that a go again.
From what I can gather the tag is supposed to be replaced by the parent class doc. In addition, there can be new comments/doc beside the @inheritdoc tag.
If yo could give me a few pointers where to start I'd be happy to give that a go

underscore as 1st char in methods name

It seems that methods that have an underscore as the 1st character of its name doesn't appear in the generated doc.

I used tho named some of my methods like that :

public function _redirect_to($destination)
{
}

but phpdoctor doesn't generate the documentation for them.

Is it a bug or am I missing something ?

Regards,
Steph.

Feature request - regenerate docs only for modified files

We are now running PHPDoctor as a nightly cron job on our code base. Since it's large, this takes several hours.

One neat feature would be the ability to say "only regenerate documentation for files that git shows as changed."

I realize this would be complicated - you'd have to store a record of parent-child class relationships on disk, I imagine - but I thought I'd mention the idea.

phpDoctor->makeAbsolutePath mangles any path containing a directory ending in '.'

My code repository is located at:

/usr/local/www/domain.com/subdomain./htdocs/mycode/

The issue occurs in that when phpDoctor attempts to resolve this path, it ends up mangling it and errors out as the directory no longer exists (and my account does not have permission to write to the generated one).

The issue seems to occur with line 471 in classes/phpDoctor.php:

$absPath = str_replace('./', '', $absPath);

Which causes the folder to resolve to:

/usr/local/www/domain.com/subdomainhtdocs/mycode/

I have commented the line out and it is working for me just fine, but I'm not sure why it was there in the first place, so I do not know exactly what side-effects this would have, or what the line was trying to accomplish in the first place (to attempt to resolve the issue in a way that does not cause issues with some other type of path) - otherwise I'd just submit a patch.

Other than that everything seems to be working for me! :)

Wrong stripping of @package

The @Package tag should IMHO consume just one line and not follow to next lines.

Sample:

/**
* @package JAMA
* 
* Error handling
* @author Michael Bommarito
* @version 01292005
*/

This should create package JAMA with file comment Error handling.

Option not to use packages in class URLs?

Many of our classes do not yet have packages assigned, but all of them have unique names based on the code's directory structure, like "class Somedir_Subdir_Classname". For us, it would be ideal if the documentation fell into the same directory structure instead of "packagename/classname." Besides which, using the package name in the URL means that the URL will change as we add @Package information in the future.

  1. Would customizing this require changing code in many places, or just classWriter?
  2. Would you consider making URL path a config option, or would we have to branch the code to do this?

more of a question: code formatting

Hi there,
I've tried various ways of formatting code examples (

, ), but none seem to be working really well.

seems to be somewhat ok, however lines seem to be getting trimmed somewhere, so indentation gets lost.
is there a recommended way or would that be a new feature?

Exception documentation

@exception/@throws should be synonymous

@throws AException if condition b is met
is translated to
if condition b is met
whereas
AException if condition b is met
seems more appropriate ;)

PHPDoctor sees no difference between objects with the same name in different namespaces

Do the following code

namespace A {

    class Foo {}
    class Bar extends Foo{}

    class Bar_A extends Foo{}

}

namespace B {

    class Foo {}
    class Bar extends Foo{}

    class Bar_B extends Foo{}
}

namespace A\C{

    class Foo {}
    class Bar extends Foo{}

    class Bar_C extends Foo{}

}

And it will result in several errors - only a few will show up in the class trees, all versions of Foo will show as being parent of all versions of Bar and all versions of Bar will be shown as extending from A\Foo

Fatal error: Call to a member function containingPackage() on a non-object

Current Git (a620a89) fails with the following fatal error:
PHP Fatal error: Call to a member function containingPackage() on a non-object in /path/to/phpdoctor/classes/seeTag.php on line 79
PHP Stack trace:
PHP 1. {main}() /path/to/phpdoctor/phpdoc.php:0
PHP 2. PHPDoctor->execute() /path/to/phpdoctor/phpdoc.php:53
PHP 3. Standard->standard() /path/to/phpdoctor/classes/phpDoctor.php:1033
PHP 4. SourceWriter->sourceWriter() /path/to/phpdoctor/doclets/standard/standard.php:179
PHP 5. HTMLWriter->_processInlineTags() /path/to/phpdoctor/doclets/standard/sourceWriter.php:100
PHP 6. LinkTag->text() /path/to/phpdoctor/doclets/standard/htmlWriter.php:298
PHP 7. SeeTag->text() /path/to/phpdoctor/classes/linkTag.php:49

relative filename truncated using multiple source folder

When using multiple source folder the relative filename displayed is sometimes too short or too long, depending on the length difference of the various source folders configured.
[I guess that perhaps I should be fixing fix ;)]

Access html of source files via HTTP is broken

Verion: 2 RC4
OS: Windows 7
Problem: using Apache, the link to source files is broken because parts of the filename contain backslash '' character, rather than forwardslash '/'.

I am using the standard doclet, so two patches helped me as a workaround:
sourceWriter.php, line 62, add an str_replace: str_replace("", "/", strtolower($filename))
htmlWrite.php, line 195, add an sre_replace: str_replace("", "/", strtolower($doc->sourceFilename()))

I am not sure if that's a bug or a feature (for HTTP access to generated API doc it's a bug)...
thanks
Sven

Equal classnames in different namespaces result in endless loop

SPL class: \LogicException
my class: \HPO\XQP\LogicException extends \LogicException

debug doclet works, default servlet enters an endless loop in packageWriter.php:239 (_buildTree). Result is segfault if memory is exhausted.

Problem: From a quick glance at the code, it seems the function is called for \HPO\XQP\LogicException, looks for a superclass named 'LogicException' (note missing namespace) and finds \HPO\XQP\LogicException (itself) in that search.... This results in an endless tree to build.

enable phpDocumentor style "brief" descriptions

In order to "ease" the conversion from the now IMHO defunct phpDocumentor (and attract a lot of additional users ;) ), it would be great if phpDoctor would extend the possible break from brief to full/detailed description:

JavaDoc: First sentence (period plus whitespace)
phpDoctor: first double newline

Could also be limited to the first double newline, if the preceding paragraph does NOT end in punctuation (not strict, but phpDoc documentation does it that way)

For extra karma, this could be configurable ;)

missing namespace handling in DocBlock

As it is now, unqualified / relative class names in a DocBlock seem to be resolved relative to the namespace root:

namespace A;
...

PHPDoctor interprets this as \SomeClass. It would be more "intuitive" (and conforming to javadoc spec, IMHO) if it would be interpreted as \A\SomeClass. If the coder wanted to refer to \SomeClass, he could/should write so...

Also:
use some/namespace as b;

  • @return b/SomeClass
    should be resolved.

How should those be documented? I suppose, the full/absolute class name woud be best - but I'm not sure.

Treat __construct as Constructor

Hey there,

I use the magic php __construct method for my constructors. So, they are treated as methods. In my Index I have a bunch of __constrcut methods for each constructor I have. Could you change that please?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.