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

How to format/mark code samples (in connection with Swagger) #338

Closed davidsneighbour closed 4 years ago

davidsneighbour commented 6 years ago

I am failing to add "code samples" to my documentation code. I have, eg., the following code in my doc:

    /**
     * retrieves data for datatables plugin
     *
     * <code><pre>
     * $columns = array(<br>
     *     array('db' => 'first_name', 'dt' => 'first_name'),<br>
     *     array('db' => 'last_name', 'dt' => 'last_name'),<br>
     *     array('db' => 'position', 'dt' => 'position'),<br>
     *     array('db' => 'office', 'dt' => 'office'),<br>
     *     array(<br>
     *         'db' => 'start_date',<br>
     *         'dt' => 'start_date',<br>
     *         'formatter' => function( $d, $row ) {<br>
     *             return date('jS M y', strtotime($d));<br>
     *         }<br>
     *     ),<br>
     *     array(<br>
     *         'db' => 'salary',<br>
     *         'dt' => 'salary',<br>
     *         'formatter' => function( $d, $row ) {<br>
     *             return '$'.number_format($d);<br>
     *         }<br>
     *     )<br>
     * );<br>
     * </pre></code>
     *
     * @url GET /tabledata
     * @return array
     */

The HTML is used in a Swagger interface - without HTML all code would be rendered as one line there.

However, the code created in phpdox is in one line and the HTML is printed out. I would expect it to be removed or used for specific formatting.

theseer commented 6 years ago

phpDox indeed does not handle HTML-markup in docblocks as of now. There's even a pre-existing ticket (#42) about that.

I still do not agree with having an output specific format in the documentation. I'm considering to add markdown support though to allow formatting of text.