Skip to content

Commit

Permalink
Update snippet and doc gen parsers
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbausor committed Jun 16, 2017
1 parent a518c92 commit 9c4b04b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions dev/src/DocGenerator/Parser/CodeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ private function buildMagicMethod($magicMethod)
$docText = '';
$examples = null;

$parts = explode('Example:', $fullDescription);
$parts = explode('Sample Code:', $fullDescription);

$docText = $parts[0];

if (strpos($fullDescription, 'Example:') !== false) {
if (strpos($fullDescription, 'Sample Code:' . PHP_EOL) !== false) {
$examples = $parts[1];
}

Expand Down Expand Up @@ -600,10 +600,10 @@ private function buildLink($content)

private function splitDescription($description)
{
$parts = explode('Example:', $description);
$parts = explode('Sample Code:', $description);
$examples = null;

if (strpos($description, 'Example:') !== false) {
if (strpos($description, 'Sample Code:' . PHP_EOL) !== false) {
$examples = $parts[1];
}

Expand Down
18 changes: 9 additions & 9 deletions dev/src/Snippet/Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/**
* A class for parsing code snippets from a class and its methods.
*
* Example:
* Sample Code:
* ```
* $parser = new Parser;
* ```
Expand All @@ -39,7 +39,7 @@ class Parser
/**
* Get a snippet from a class.
*
* Example:
* Sample Code:
* ```
* $snippet = $parser->classExample(Parser::class);
* ```
Expand Down Expand Up @@ -72,7 +72,7 @@ public function classExample($class, $index = 0)
/**
* Get a snippet from a method.
*
* Example:
* Sample Code:
* ```
* $snippet = $parser->methodExample(Parser::class, 'methodExample');
* ```
Expand Down Expand Up @@ -111,7 +111,7 @@ public function methodExample($class, $method, $index = 0)
/**
* Retrieve all examples from a class Doc Block.
*
* Example:
* Sample Code:
* ```
* $examples = $parser->examplesFromClass($parser);
* ```
Expand Down Expand Up @@ -160,7 +160,7 @@ public function examplesFromClass($class)
/**
* Retrieve all examples from a method's Doc Block.
*
* Example:
* Sample Code:
* ```
* $examples = $parser->examplesFromMethod($parser, 'examplesFromMethod');
* ```
Expand Down Expand Up @@ -196,7 +196,7 @@ public function examplesFromMethod($class, $method)
/**
* Retrieve all examples from a class and its methods.
*
* Example:
* Sample Code:
* ```
* $examples = $parser->allExamples($parser);
* ```
Expand Down Expand Up @@ -224,7 +224,7 @@ public function allExamples($class)
/**
* Parse examples from a DocBlock object.
*
* Example:
* Sample Code:
* ```
* // Yeah, this example is pretty useless.
* $examples = $parser->examples($docBlock);
Expand All @@ -243,9 +243,9 @@ public function examples(DocBlock $docBlock, $fullyQualifiedName, $file, $line,
// print_r($return[0]->getTypes());exit;
// }

$parts = explode('Example:', $text);
$parts = explode('Sample Code:', $text);

if (strpos($text, 'Example:') === false) {
if (strpos($text, 'Sample Code:' . PHP_EOL) === false) {
return [];
}

Expand Down

0 comments on commit 9c4b04b

Please sign in to comment.