src/cultusrego.php
private function parse_match($match) {
    $match = trim($match);
    $docblock = new Docblock($match);
    $tags = $docblock->getTags();
    $element_values = array();

    if ($title = $docblock->getShortDescription()) {
      // Skip text strings that start with #
      // (e.g. source map comment)
      if (strpos($title, '#') === 0) {
        return $element_values;
      }
      
      $element_values['title'] = $title;
    }

    if ($description = $docblock->getLongDescription()) {
      $element_values['description'] = $description;
    }

    foreach ($tags as $tag) {
      $tag_name = $tag->getTagName();
      $tag_description = $this->clean_description($tag->getDescription());
      switch ($tag_name) {
        case 'code':
        case 'markup':
          // Default code language is markup
          $element_values['code_language'] = 'markup';
          // Hide rendered output by default
          $element_values['code_render'] = FALSE;
          // If tag name is markup render by default
          if ($tag_name == 'markup') {
            $element_values['code_render'] = TRUE;
          }
          // Look if a other code language is defined
          if (preg_match("#^\[(.*?)\]\n#s", $tag_description, $code_language_match)) {
            $element_values['code_language'] = $code_language_match[1];
            $tag_description = str_replace('[' . $code_language_match[1] . ']', '', $tag_description);
          }
          $element_values['code'] = trim($tag_description);
          break;

        case 'color':
          $colorsets = array();
          $colorset_elements = explode("\n", $tag_description);
          foreach ($colorset_elements as $colorset) {
            $color_elements = explode('|', $colorset);
            $colors = array();
            foreach ($color_elements as $color) {
              $color_arr = explode(':', $color);
              if (count($color_arr) > 1) {
                $colors[] = array(
                  'name' => trim($color_arr[0]),
                  'value' => trim($color_arr[1]),
                );
              }
              else {
                $colors[] = array('value' => $color_arr[0]);
              }
            }
            $colorsets[] = $colors;
          }
          $element_values['color'] = $colorsets;
          break;

        case 'variable':
          $variables = explode('|', $tag_description);
          $element_values['variable'] = '- ' . implode(";\n- ", $variables) . ';';
          break;

        default:
          $element_values[$tag_name] = $tag_description;
          break;
      }
    }
    return $element_values;
  }
private function parse_match($match) {
    $match = trim($match);
    $docblock = new Docblock($match);
    $tags = $docblock->getTags();
    $element_values = array();

    if ($title = $docblock->getShortDescription()) {
      // Skip text strings that start with #
      // (e.g. source map comment)
      if (strpos($title, '#') === 0) {
        return $element_values;
      }
      
      $element_values['title'] = $title;
    }

    if ($description = $docblock->getLongDescription()) {
      $element_values['description'] = $description;
    }

    foreach ($tags as $tag) {
      $tag_name = $tag->getTagName();
      $tag_description = $this->clean_description($tag->getDescription());
      switch ($tag_name) {
        case 'code':
        case 'markup':
          // Default code language is markup
          $element_values['code_language'] = 'markup';
          // Hide rendered output by default
          $element_values['code_render'] = FALSE;
          // If tag name is markup render by default
          if ($tag_name == 'markup') {
            $element_values['code_render'] = TRUE;
          }
          // Look if a other code language is defined
          if (preg_match("#^\[(.*?)\]\n#s", $tag_description, $code_language_match)) {
            $element_values['code_language'] = $code_language_match[1];
            $tag_description = str_replace('[' . $code_language_match[1] . ']', '', $tag_description);
          }
          $element_values['code'] = trim($tag_description);
          break;

        case 'color':
          $colorsets = array();
          $colorset_elements = explode("\n", $tag_description);
          foreach ($colorset_elements as $colorset) {
            $color_elements = explode('|', $colorset);
            $colors = array();
            foreach ($color_elements as $color) {
              $color_arr = explode(':', $color);
              if (count($color_arr) > 1) {
                $colors[] = array(
                  'name' => trim($color_arr[0]),
                  'value' => trim($color_arr[1]),
                );
              }
              else {
                $colors[] = array('value' => $color_arr[0]);
              }
            }
            $colorsets[] = $colors;
          }
          $element_values['color'] = $colorsets;
          break;

        case 'variable':
          $variables = explode('|', $tag_description);
          $element_values['variable'] = '- ' . implode(";\n- ", $variables) . ';';
          break;

        default:
          $element_values[$tag_name] = $tag_description;
          break;
      }
    }
    return $element_values;
  }
private function parse_match ( $ match ) { $ match = trim ( $ match ) ; $ docblock = new Docblock ( $ match ) ; $ tags = $ docblock -> getTags ( ) ; $ element_values = array ( ) ; if ( $ title = $ docblock -> getShortDescription ( ) ) { // Skip text strings that start with # // (e.g. source map comment) if ( strpos ( $ title , '#' ) === 0 ) { return $ element_values ; } $ element_values [ 'title' ] = $ title ; } if ( $ description = $ docblock -> getLongDescription ( ) ) { $ element_values [ 'description' ] = $ description ; } foreach ( $ tags as $ tag ) { $ tag_name = $ tag -> getTagName ( ) ; $ tag_description = $ this -> clean_description ( $ tag -> getDescription ( ) ) ; switch ( $ tag_name ) { case 'code' : case 'markup' : // Default code language is markup $ element_values [ 'code_language' ] = 'markup' ; // Hide rendered output by default $ element_values [ 'code_render' ] = FALSE ; // If tag name is markup render by default if ( $ tag_name == 'markup' ) { $ element_values [ 'code_render' ] = TRUE ; } // Look if a other code language is defined if ( preg_match ( "#^\[(.*?)\]\n#s" , $ tag_description , $ code_language_match ) ) { $ element_values [ 'code_language' ] = $ code_language_match [ 1 ] ; $ tag_description = str_replace ( '[' . $ code_language_match [ 1 ] . ']' , '' , $ tag_description ) ; } $ element_values [ 'code' ] = trim ( $ tag_description ) ; break ; case 'color' : $ colorsets = array ( ) ; $ colorset_elements = explode ( "\n" , $ tag_description ) ; foreach ( $ colorset_elements as $ colorset ) { $ color_elements = explode ( '|' , $ colorset ) ; $ colors = array ( ) ; foreach ( $ color_elements as $ color ) { $ color_arr = explode ( ':' , $ color ) ; if ( count ( $ color_arr ) > 1 ) { $ colors [ ] = array ( 'name' => trim ( $ color_arr [ 0 ] ) , 'value' => trim ( $ color_arr [ 1 ] ) , ) ; } else { $ colors [ ] = array ( 'value' => $ color_arr [ 0 ] ) ; } } $ colorsets [ ] = $ colors ; } $ element_values [ 'color' ] = $ colorsets ; break ; case 'variable' : $ variables = explode ( '|' , $ tag_description ) ; $ element_values [ 'variable' ] = '- ' . implode ( ";\n- " , $ variables ) . ';' ; break ; default : $ element_values [ $ tag_name ] = $ tag_description ; break ; } } return $ element_values ; }
Find styleguide elements and their values in a comment section
@param  string $match The contents of a matched comment section
@return array         Values of the found styleguide elements
Find styleguide elements and their values in a comment section