API displays not indenting @code segments properly
kiamlaluno - November 10, 2009 - 13:09
| Project: | API |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
The code that appears in the API pages is not indented.
To make an example, in the reported page (http://api.drupal.org/api/group/database/7), the following code is not shown indented, when the original code (embedded in a comment) was indented.
<?php
* @code
* function my_transaction_function() {
* // The transaction opens here.
* $txn = db_transaction();
*
* try {
* $id = db_insert('example')
* ->fields(array(
* 'field1' => 'mystring',
* 'field2' => 5,
* ))
* ->execute();
*
* my_other_function($id);
*
* return $id;
* }
* catch (Exception $e) {
* // Something went wrong somewhere, so flag the entire transaction to
* // roll back instead of getting committed. It doesn't actually roll back
* // yet, just gets flagged to do so.
* $txn->rollback();
* }
*
* // $txn goes out of scope here. If there was a problem, it rolls back
* // automatically. If not, it commits automatically.
* }
*
* function my_other_function($id) {
* // The transaction is still open here.
*
* if ($id % 2 == 0) {
* db_update('example')
* ->condition('id', $id)
* ->fields(array('field2' => 10))
* ->execute();
* }
* }
* @endcode
?>
#1
This is an issue with the API module (which generates api.drupal.org), not with what is inside the documentation headers, I think? The code in the doc header is perfectly fine. It is just not being displayed well.
#2
That is correct. What I reported is the code as seen in the documentation comment.
#3
I thought that could be a problem with the filter that renders PHP code between $lt;?php ?>, but the filter indents correctly the code.
<?phpfunction test() {
print 'test ' . variable_get('dev_test', 10);
?>