====== The Akelos PHP Framework Documentation System ======
Example:
= $url_helper->url_for('Show posts', array('controller'=>'blog', 'action'=>'listing')); ?>
Produces:
Show posts
That is all we need to have at the inline documentation, and what is going to be rendered on the XHTML version (using syntax highlighting). The documentation system will detect that the example is PHP code and if it does not exist yet, it will generate the following test for us at tests/doc/lib/AkActionView/helpers/url_helper.php
class UrlHelperDocumentaionTestCase extends AkDocumentationTestCase{
function test_for_url_helper_example()
{
$this->assertEqual(
$url_helper->url_for('Show posts', array('controller'=>'blog', 'action'=>'listing')),
'Show posts'
);
}
}
So our only task to make this test pass is to instantiate the UrlHelper at $url_for.
This tests will be generated automatically, but they are not compulsory at this very first stage, where documenting undocumented features should be the priority number one.
If someone finds a bug in one of the examples we should allow users to help us correcting the errors by allowing them to send us an alternative unit tested example.
Only PHP blocks are considered automatically for unit testing.
=== Adding more than one example ===
Should be as simple as
Example 2:
$Post->collect($Post->find('first'), array('name','email'));
Returns:
array(‘Jane’ => ‘jane@example.com’)
==== Using inline HTML ====
Follow the instructions at the [[http://daringfireball.net/projects/markdown/syntax#html|Markdown Syntax reference]] on how to use inline HTML.
==== Conventions on return values, and parameters ====
We should not need to implicitly declare an input/return attribute types if the variable/function uses is self describing and this can be done programatically taking into account established naming conventions.
Having a method like isValid() does not need an an explanation on the return value unless there is a default return value worth documenting.
For more ambiguous cases when conventions are not sufficient we can always use JavaDoc type attributes like @param, @return….
Remember the [[http://akelos.org/Akelos_Framework_Developer_Coding_Style_Guide.pdf|Akelos PHP Framework coding style]] guide… ObjectsCamelCased, $_private_vars and so on.
==== Syntax highlighting ====
Syntax highlighting will take place automatically in these cases
* PHP: Starts with `, <%`
* HTML: starts with `<[a-zA-Z]`
If your need to specify a Syntax for an example you can do it like
Javascript Example:
Ajax.request();
The parser will automatically for mat the code as Javascript.
FIXME work in progress…
===== Todo =====
* Complete this document as new conventions are being discovered
* Prepare a web based environment for editing documentation. (closed to trusted collaborators until versioning is ready).
* Reformat existing documentation and test documentation examples.
* Add versioning, Askimet spam protection and open the API to the public.
* Implement generators for creating different versions of the documentation (Offline documentation HTML/PDF, TexMate bundles, Zend IDE XML files...)
* Add support for comments and trackback support for liking to other sources with information about the subject.