Parse the given documentation blocks with a Markdown parser and return
the resulting formatted blocks as HTML snippets.

@param  array $rawDocBlocks The raw documentation blocks to parse.

@return array
519381
protected function parseDocblocks($rawDocBlocks)
    {
        $parsedDocBlocks = array();
        $docBlockParser = new MarkdownParser();

        foreach ($rawDocBlocks as $docBlock) {
            $docBlock = preg_replace(self::REGEX_DOCBLOCK_TYPE, '$1$2 `$4` ', $docBlock);
            $docBlock = preg_replace(self::REGEX_DOCBLOCK_VAR, '$1`$2`', $docBlock);
            $docBlock = preg_replace(self::REGEX_DOCBLOCK_ARG, "\n<em class=\"docparam\">$1</em>", $docBlock);

            $parsedDocBlocks[] = $docBlockParser->transformMarkdown($docBlock);
        }

        return $parsedDocBlocks;
    }
164226
protected function toDocuments(array $docs = array())
    {
        if (isset($docs['rows'])) {
            $rtn = array();

            foreach ($docs['rows'] as $row) {
                $rtn[] = $this->toDocument($row['value']);
            }

            return $rtn;
        } else {
            return array();
        }
    }
399961
protected function extractReturnType(array $tokens, $docBlockOpenTagIndex, $docBlockCloseTagIndex) {
		for ($i = $docBlockOpenTagIndex + 1; $i < $docBlockCloseTagIndex; $i++) {

			if ($tokens[$i]['type'] !== 'T_DOC_COMMENT_TAG') {
				continue;
			}
			if ($tokens[$i]['content'] !== '@return') {
				continue;
			}

			$classNameIndex = $i + 2;

			if ($tokens[$classNameIndex]['type'] !== 'T_DOC_COMMENT_STRING') {
				continue;
			}

			$content = $tokens[$classNameIndex]['content'];

			//$appendix = '';
			$spaceIndex = strpos($content, ' ');
			if ($spaceIndex) {
				//$appendix = substr($content, $spaceIndex);
				$content = substr($content, 0, $spaceIndex);
			}

			return $content;
		}

		return 'mixed';
	}
664266
protected function getDocblockTagsSection($docblock)
    {
        $docblock = $this->sanitizeDocblock($docblock);
        preg_match('/^\s*\\'.self::TOKEN_ANNOTATION_IDENTIFIER.'/m', $docblock, $matches, PREG_OFFSET_CAPTURE);

        // return found docblock tag section or empty string
        return isset($matches[0]) ? substr($docblock, $matches[0][1]) : '';
    }
661030
function captureJsDoc(comments) {
  let doc

  // capture XSDoc
  comments.forEach(comment => {
    // skip non-block comments
    if (comment.type !== 'Block') return
    try {
      doc = doctrine.parse(comment.value, { unwrap: true })
    } catch (err) {
      /* don't care, for now? maybe add to `errors?` */
    }
  })

  return doc
}
630572
private function getDocument(string $rawHTML): Document {
        $doc = new Document();
        $doc->html($rawHTML);

        return $doc;
    }
1362802
public function getBlockEndToken(): array
    {
        if (!$this->hasDocBlock()) {
            throw new DomainException(
                sprintf('Missing doc block for position %s of file %s.', $this->stackPos, $this->file->getFilename())
            );
        }

        return $this->tokens[$this->getBlockEndPosition()];
    }
297403
public static function parse($doc)
    {
        $block = new DocBlock();
        $lines = explode("\n", $doc);

        // remove first line
        unset($lines[0]);

        foreach ($lines as $line) {
            $line = trim($line);
            $line = substr($line, 2);

            if (isset($line[0]) && $line[0] == '@') {
                $line = substr($line, 1);
                $sp   = strpos($line, ' ');
                $bp   = strpos($line, '(');

                if ($sp !== false || $bp !== false) {
                    if ($sp !== false && $bp === false) {
                        $pos = $sp;
                    } elseif ($sp === false && $bp !== false) {
                        $pos = $bp;
                    } else {
                        $pos = $sp < $bp ? $sp : $bp;
                    }

                    $key   = substr($line, 0, $pos);
                    $value = substr($line, $pos);
                } else {
                    $key   = $line;
                    $value = null;
                }

                $key   = trim($key);
                $value = trim($value);

                if (!empty($key)) {
                    // if key contains backslashes its a namespace use only the
                    // short name
                    $pos = strrpos($key, '\\');
                    if ($pos !== false) {
                        $key = substr($key, $pos + 1);
                    }

                    $block->addAnnotation($key, $value);
                }
            }
        }

        return $block;
    }
481189
def __get_doc_block_parts_source(self):
        
        line1, line2 = self.__get_doc_block_lines()

        if line1 is not None and line2 is not None and line1 <= line2:
            doc_block = self._routine_source_code_lines[line1:line2 - line1 + 1]
        else:
            doc_block = list()

        reflection = DocBlockReflection(doc_block)

        self._doc_block_parts_source['description'] = reflection.get_description()

        self._doc_block_parts_source['parameters'] = list()
        for tag in reflection.get_tags('param'):
            parts = re.match(r'^(@param)\s+(\w+)\s*(.+)?', tag, re.DOTALL)
            if parts:
                self._doc_block_parts_source['parameters'].append({'name':        parts.group(2),
                                                                   'description': parts.group(3)})
351556
public function outputDocBlock($docblock, $replaceTab = true)
    {
        $code = '';
        $docblock = '/'.$docblock.'/';

        foreach (explode("\n", $docblock) as $line) {
            if ($replaceTab) {
                $code .= str_repeat("\t", $this->level).preg_replace('/^[ \t]+/', ' ', $line).PHP_EOL;
            } else {
                $code .= $line.PHP_EOL;
            }
        }

        $this->lastLine = $code;
        $this->code .= $code;
        ++$this->currentPrints;
    }
157111
public function getDocumentation(): string
    {
        $block = strstr($this->property->getDocComment(), '@', true);
        $block = preg_replace('/\/\*\*\n/m', '', $block);
        $block = preg_replace('/\n[ \t]*[ ]?\*\/$/', '', $block);
        $block = preg_replace('/\n\n/', '', $block);
        $block = preg_replace('/^[ \t]*\*[ ]?/m', '', $block);
        $block = preg_replace('/\n[ \t]*$/', '', $block);

        return $block;
    }
107048
public function parseFactoryAnnotations($docBlock)
    {
        return $this->parseAnnotations(
            $docBlock,
            '/@factory\("(?P<className>[\/\\\\A-Za-z0-9_-]+?)"(, params={(?P<params>[, \"\n\t*A-Za-z0-9_-]*)})?\)?[ \t]*\r?$/m',
            function (array $matches) {
                if (1 != count($matches[0])) {
                    throw new \InvalidArgumentException();
                }
                current($matches);

                // clean params
                $params = null;
                if (!empty($matches['params'][0])) {
                    $params = $matches['params'][0];
                    foreach (['*', ' ', "\n", "\t", "\r", '"'] as $char) {
                        $params = str_replace($char, '', $params);
                    }
                }

                return [
                    'className' => $matches['className'][0],
                    'params'    => !empty($params)? explode(',', $params):[],
                ];
            }
        );
    }
57109
protected function parseBlockCommentTags(array &$blockCommentLines)
    {
        $tags = array();
        $currentTagName = $currentTagContent = null;
        foreach ($blockCommentLines as $index => $blockCommentLine) {
            $isTagLine = preg_match(
                '~^@(\w+)(?:\s+(.*))?\s*$~',
                $blockCommentLine,
                $matches
            );
            $isEmptyLine = '' === trim($blockCommentLine);

            if (
                ($isTagLine || $isEmptyLine) &&
                null !== $currentTagName
            ) {
                if ('' === $currentTagContent) {
                    $currentTagContent = null;
                }
                $tags[] = new Element\DocumentationTag(
                    $currentTagName,
                    $currentTagContent
                );

                $currentTagName = $currentTagContent = null;
            }

            if ($isTagLine) {
                $currentTagName = $matches[1];
                $currentTagContent = '';
                if (array_key_exists(2, $matches)) {
                    $currentTagContent = $matches[2];
                }
            } elseif (!$isEmptyLine) {
                $currentTagContent .= ' ' . ltrim($blockCommentLine);
            }

            if (null !== $currentTagName || count($tags) > 0) {
                unset($blockCommentLines[$index]);
            }
        }
        if (null !== $currentTagName) {
            if ('' === $currentTagContent) {
                $currentTagContent = null;
            }
            $tags[] = new Element\DocumentationTag(
                $currentTagName,
                $currentTagContent
            );
        }

        return $tags;
    }
944487
public function parseSimpleAnnotations($docBlock)
    {
        return $this->parseAnnotations(
            $docBlock,
            '/@(?P<name>[A-Za-z_-]+)(?:[ \t]+(?P<value>.*?))?[ \t]*\r?$/m',
            function (array $matches) {
                $annotations = [];
                $numMatches = count($matches[0]);
                for ($i = 0; $i < $numMatches; ++$i) {
                    $annotations[$matches['name'][$i]][] = $matches['value'][$i];
                }

                return $annotations;
            }
        );
    }
1194905
private function extractDocBlockPartsWrapper(): void
  {
    // Get the DocBlock parts from the source of the stored routine.
    $this->extractDocBlockPartsSource();

    // Generate the parameters parts of the DocBlock to be used by the wrapper.
    $parameters = [];
    foreach ($this->parameters as $parameter_info)
    {
      $parameters[] = ['parameter_name'       => $parameter_info['parameter_name'],
                       'php_type'             => DataTypeHelper::columnTypeToPhpTypeHinting($parameter_info).'|null',
                       'data_type_descriptor' => $parameter_info['data_type_descriptor'],
                       'description'          => $this->getParameterDocDescription($parameter_info['parameter_name'])];
    }

    // Compose all the DocBlock parts to be used by the wrapper generator.
    $this->docBlockPartsWrapper = ['sort_description' => $this->docBlockPartsSource['sort_description'],
                                   'long_description' => $this->docBlockPartsSource['long_description'],
                                   'parameters'       => $parameters];
  }
883069
private function generateMultiArgumentDocblock(ClientMethodContext $context): DocBlockGenerator
    {
        $class = $context->getClass();
        $method = $context->getMethod();
        $description = ['MultiArgumentRequest with following params:'.PHP_EOL];
        foreach ($context->getMethod()->getParameters() as $parameter) {
            $description[] = $parameter->getType().' $'.$parameter->getName();
        }

        return DocBlockGeneratorFactory::fromArray(
            [
                'longdescription' => implode(PHP_EOL, $description),
                'tags' => [
                    ['name' => 'param', 'description' => MultiArgumentRequest::class],
                    [
                        'name' => 'return',
                        'description' => sprintf(
                            '%s|%s',
                            $this->generateClassNameAndAddImport(ResultInterface::class, $class),
                            $this->generateClassNameAndAddImport(
                                $method->getNamespacedReturnType(),
                                $class,
                                true
                            )
                        ),
                    ],
                ],
            ]
        );
    }
363649
public function getParsedDocBlock()
    {
        if (!$this->parsedDocblock) {
            if (\strlen($this->docBlock) > 0) {
                $parser = new DocblockParser('/'.$this->docBlock.'/');
                $this->parsedDocblock = $parser->parse();
            } else {
                return null;
            }
        }

        return $this->parsedDocblock;
    }