Skip to content

Commit fd18c3e

Browse files
authored
Strip hard line break in method summaries (#19)
1 parent a62efa0 commit fd18c3e

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

docs/BasicClass.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ various PHPDoc tags are used.
1414

1515
| Name | Description |
1616
|------|-------------|
17-
|[__construct](#basicclass__construct)|Constructs an object|
17+
|[__construct](#basicclass__construct)|Constructs an object of some specific type with certain unspoken defaults.|
1818
|[addValues](#basicclassaddvalues)|Adds two arguments|
1919
|[one](#basicclassone)|Returns one|
2020

@@ -29,14 +29,15 @@ various PHPDoc tags are used.
2929
public __construct (array $options)
3030
```
3131

32-
Constructs an object
32+
Constructs an object of some specific type with certain unspoken defaults.
3333

3434

3535

3636
**Parameters**
3737

3838
* `(array) $options`
39-
: options
39+
: the user's desired settings for the object being
40+
created.
4041

4142
**Return Values**
4243

example/BasicClass.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ class BasicClass
1717
public $config;
1818

1919
/**
20-
* Constructs an object
20+
* Constructs an object of some specific type with certain unspoken
21+
* defaults.
2122
*
22-
* @param array $options options
23+
* @param array $options the user's desired settings for the object being
24+
* created.
2325
*
2426
* @return void
2527
*/

src/Markdown/ClassInfo.php

+15-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ abstract public function getFormatName();
2929
public function render()
3030
{
3131
$parser = new ClassParser($this->reflectionClass);
32-
$methods = $parser->getMethodsDetails();
32+
$methods = [];
33+
foreach ($parser->getMethodsDetails() as $methodName => $methodDetails) {
34+
$methodDetails->shortDescription = $this
35+
->removeHardLineBreaks($methodDetails->shortDescription);
36+
$methods[$methodName] = $methodDetails;
37+
}
3338
ksort($methods);
3439

3540
$this->setData(
@@ -45,4 +50,13 @@ public function render()
4550
);
4651
return parent::render();
4752
}
53+
54+
/** Strip hard line wraps from string */
55+
private function removeHardLineBreaks($text) {
56+
return preg_replace(
57+
['(\n)', '( +)'],
58+
[' ', ' '],
59+
$text
60+
);
61+
}
4862
}

0 commit comments

Comments
 (0)