--- parser.inc.1.16.2.1 2006-09-08 12:55:43.781710400 -0400
+++ parser.inc 2006-09-08 13:31:35.565824000 -0400
@@ -220,16 +220,7 @@ function api_parse_php_file($file_path,
$docblock['start_line'] = substr_count(substr($source, 0, $code_start), "\n");
- // Find parameter definitions.
- $param_match = array();
- $offset = 0;
- $docblock['parameters'] = '';
- while (preg_match('!@param(.*?)(?=\n@|\n\n|$)!s', substr($docblock['content'], $offset), $param_match, PREG_OFFSET_CAPTURE)) {
- $docblock['content'] = str_replace($param_match[0][0], '', $docblock['content']);
- $docblock['parameters'] .= "\n\n". $param_match[1][0];
- $offset = $param_match[0][1];
- }
- $docblock['parameters'] = api_format_documentation($docblock['parameters'], $branch_name);
+ _api_parse_parameters($docblock);
// Find return value definitions.
$return_matches = array();
@@ -409,6 +400,30 @@ function api_parse_php_file($file_path,
}
/**
+ * Parse parameter defintions
+ *
+ * @param &$docblock
+ * The docblock being built.
+ */
+function _api_parse_parameters(&$docblock){
+ $param_match = array();
+ $offset = 0;
+ $docblock['parameters'] = '';
+ while (preg_match('!@param\s*(&?[$@]?\w*)(.*?)(?=\n@|\n\n|$)!s', substr($docblock['content'], $offset), $param_match, PREG_OFFSET_CAPTURE)) {
+ $docblock['content'] = str_replace($param_match[0][0], '', $docblock['content']);
+ //$docblock['parameters'] .= "\n\n". $param_match[1][0];
+ $docblock['parameters'] .= "\n\n
". $param_match[1][0] . '' . check_plain($param_match[2][0]) . "";
+ $offset = $param_match[0][1];
+ }
+ if (!empty($docblock['parameters'])) {
+ $docblock['parameters'] =
+ '' . $docblock['parameters'] .'
';
+ $docblock['parameters'] = api_format_documentation($docblock['parameters'], $branch_name, FALSE);
+ }
+
+}
+
+/**
* Save a documentation block into the database.
*
* @param &$docblock
@@ -456,15 +471,28 @@ function api_save_documentation(&$docblo
/**
* Format a documentation block as HTML.
+ *
+ * @param $documentation
+ * The documentation block to format
+ *
+ * @param $branch_name
+ * The branch name. This is needed to generate the paths for links.
+ *
+ * @param $do_clean
+ * If true, then first run check_plain over the documentation text to
+ * escape HTML tags; if false, don't filter out HTML. Defualt: TRUE
+ *
*/
-function api_format_documentation($documentation, $branch_name) {
+function api_format_documentation($documentation, $branch_name, $do_clean = TRUE) {
// Don't do processing on empty text (so we don't end up with empty paragraphs).
$documentation = trim($documentation);
if (empty($documentation)) {
return '';
}
- $documentation = check_plain($documentation);
+ if ($do_clean) {
+ $documentation = check_plain($documentation);
+ }
// Process the @link tag.
$documentation = preg_replace('!@link ([a-zA-Z0-9_/]+\.[a-zA-Z0-9_]+) (.*?) @endlink!', str_replace('%24', '$', l('$2', 'api/'. $branch_name .'/file/$1')), $documentation);