@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class DivinerArticleAtomizer extends DivinerAtomizer {
4
5 protected function executeAtomize($file_name, $file_data) {
6 $atom = $this->newAtom(DivinerAtom::TYPE_ARTICLE)
7 ->setLine(1)
8 ->setLength(count(explode("\n", $file_data)))
9 ->setLanguage('human');
10
11 $block = "/**\n".str_replace("\n", "\n * ", $file_data)."\n */";
12 $atom->setDocblockRaw($block);
13
14 $meta = $atom->getDocblockMeta();
15
16 $title = idx($meta, 'title');
17 if (!phutil_nonempty_string($title)) {
18 $title = pht('Untitled Article "%s"', basename($file_name));
19 $atom->addWarning(pht('Article has no %s!', '@title'));
20 $atom->setDocblockMetaValue('title', $title);
21 }
22
23 // If the article has no `@name`, use the filename after stripping any
24 // extension.
25 $name = idx($meta, 'name');
26 if (!$name) {
27 $name = basename($file_name);
28 $name = preg_replace('/\\.[^.]+$/', '', $name);
29 }
30 $atom->setName($name);
31
32 return array($atom);
33 }
34
35}