Skip to content

Commit 0fac9af

Browse files
committed
Docblock summary is the first lines before a empty line, the description is the rest.
1 parent 372fb97 commit 0fac9af

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/class-file-reflector.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,12 +572,17 @@ protected function convertPhpDocToArray( PhpDocNode $phpdoc_node ) {
572572
}
573573

574574
// Split into summary and description
575-
$text_lines = array_filter( explode( "\n", trim( $text_content ) ) );
575+
$text_lines = explode( "\n", trim( $text_content ) );
576576
if ( ! empty( $text_lines ) ) {
577-
$docblock_data['summary'] = trim( $text_lines[0] );
578-
if ( count( $text_lines ) > 1 ) {
579-
$docblock_data['description'] = trim( implode( "\n", array_slice( $text_lines, 1 ) ) );
577+
// Summary is the first lines before a blank line
578+
$summary = '';
579+
while ( ( $line = array_shift( $text_lines ) ) && $line ) {
580+
$summary .= $line . ' ';
580581
}
582+
$docblock_data['summary'] = trim( $summary );
583+
584+
// The rest is the description.
585+
$docblock_data['description'] = trim( implode( "\n", $text_lines ) );
581586
}
582587

583588
// Extract tags

lib/runner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ function export_docblock_from_data( $docblock_data ) {
355355

356356
// Format descriptions according to legacy expectations:
357357
// - description (summary) should be plain text
358-
// - long_description should be wrapped in HTML paragraphs with linebreaks removed
358+
// - long_description should be wrapped in HTML paragraphs with linebreaks removed. TODO: Convert with markdown, ` and >.
359359
$description = $docblock_data['summary'] ?? '';
360360
$long_description = $docblock_data['description'] ?? '';
361361

0 commit comments

Comments
 (0)