Skip to content

Commit fb55d1b

Browse files
mwildehahnfredemmott
authored andcommitted
Support rendering doc block for no signature files (#110)
1 parent 7f4f1af commit fb55d1b

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/CodegenFile.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,19 @@ public function render(): string {
309309

310310
$content = $this->getContent();
311311

312+
$doc_block = $this->docBlock;
313+
$gen_from = $this->generatedFrom;
314+
if ($gen_from !== null) {
315+
if ($doc_block !== null && !Str\ends_with($doc_block, "\n")) {
316+
$doc_block .= "\n";
317+
}
318+
$doc_block = $doc_block.$gen_from->render()."\n";
319+
}
320+
312321
$formatter = $this->config->getFormatter();
313322

314323
if (!$this->isSignedFile) {
324+
$builder->addDocBlock($doc_block);
315325
$builder->add($content);
316326
$content = $builder->getCode();
317327
if ($formatter !== null) {
@@ -322,15 +332,6 @@ public function render(): string {
322332

323333
$old_content = $this->loadExistingFiles();
324334

325-
$doc_block = $this->docBlock;
326-
$gen_from = $this->generatedFrom;
327-
if ($gen_from !== null) {
328-
if ($doc_block !== null && !Str\ends_with($doc_block, "\n")) {
329-
$doc_block .= "\n";
330-
}
331-
$doc_block = $doc_block.$gen_from->render()."\n";
332-
}
333-
334335
if (PartiallyGeneratedCode::containsManualSection($content)) {
335336
$builder->addDocBlock(
336337
PartiallyGeneratedSignedSource::getDocBlock($doc_block),

tests/CodegenFileTest.codegen

+3
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ class Foo {
170170
!@#$%codegentest:testNoSignature
171171
<?hh // strict
172172
// Codegen Tests
173+
/**
174+
* Completely autogenerated!
175+
*/
173176

174177
class NoSignature {
175178

0 commit comments

Comments
 (0)