Path: blob/master/src/applications/diviner/atomizer/DivinerArticleAtomizer.php
12262 views
<?php12final class DivinerArticleAtomizer extends DivinerAtomizer {34protected function executeAtomize($file_name, $file_data) {5$atom = $this->newAtom(DivinerAtom::TYPE_ARTICLE)6->setLine(1)7->setLength(count(explode("\n", $file_data)))8->setLanguage('human');910$block = "/**\n".str_replace("\n", "\n * ", $file_data)."\n */";11$atom->setDocblockRaw($block);1213$meta = $atom->getDocblockMeta();1415$title = idx($meta, 'title');16if (!strlen($title)) {17$title = pht('Untitled Article "%s"', basename($file_name));18$atom->addWarning(pht('Article has no %s!', '@title'));19$atom->setDocblockMetaValue('title', $title);20}2122// If the article has no `@name`, use the filename after stripping any23// extension.24$name = idx($meta, 'name');25if (!$name) {26$name = basename($file_name);27$name = preg_replace('/\\.[^.]+$/', '', $name);28}29$atom->setName($name);3031return array($atom);32}3334}353637