Skip to content

Commit a96582c

Browse files
author
epriestley
committed
Standardize rendering of atom type names like "Article" and "Class"
Summary: Ref T988. This was sort of hard-coded in one place and not done properly in another. Do it consistently. Test Plan: Looked at atom list; looked at atom view. Saw "Article", "Class" rendered correctly. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T988 Differential Revision: https://secure.phabricator.com/D6821
1 parent a799a05 commit a96582c

File tree

3 files changed

+35
-10
lines changed

3 files changed

+35
-10
lines changed

src/applications/diviner/atom/DivinerAtom.php

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ final class DivinerAtom {
55
const TYPE_FILE = 'file';
66
const TYPE_ARTICLE = 'article';
77
const TYPE_METHOD = 'method';
8+
const TYPE_CLASS = 'class';
9+
const TYPE_FUNCTION = 'function';
10+
const TYPE_INTERFACE = 'interface';
811

912
private $type;
1013
private $name;
@@ -357,18 +360,42 @@ public function setProperties(array $properties) {
357360

358361
public static function getThisAtomIsNotDocumentedString($type) {
359362
switch ($type) {
360-
case 'function':
363+
case self::TYPE_FILE:
364+
return pht('This file is not documented.');
365+
case self::TYPE_FUNCTION:
361366
return pht('This function is not documented.');
362-
case 'class':
367+
case self::TYPE_CLASS:
363368
return pht('This class is not documented.');
364-
case 'article':
369+
case self::TYPE_ARTICLE:
365370
return pht('This article is not documented.');
366-
case 'method':
371+
case self::TYPE_METHOD:
367372
return pht('This method is not documented.');
373+
case self::TYPE_INTERFACE:
374+
return pht('This interface is not documented.');
368375
default:
369376
phlog("Need translation for '{$type}'.");
370377
return pht('This %s is not documented.', $type);
371378
}
372379
}
373380

381+
public static function getAtomTypeNameString($type) {
382+
switch ($type) {
383+
case self::TYPE_FILE:
384+
return pht('File');
385+
case self::TYPE_FUNCTION:
386+
return pht('Function');
387+
case self::TYPE_CLASS:
388+
return pht('Class');
389+
case self::TYPE_ARTICLE:
390+
return pht('Article');
391+
case self::TYPE_METHOD:
392+
return pht('Method');
393+
case self::TYPE_INTERFACE:
394+
return pht('Interface');
395+
default:
396+
phlog("Need translation for '{$type}'.");
397+
return ucwords($type);
398+
}
399+
}
400+
374401
}

src/applications/diviner/controller/DivinerAtomController.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function processRequest() {
8989
id(new PhabricatorTagView())
9090
->setType(PhabricatorTagView::TYPE_STATE)
9191
->setBackgroundColor(PhabricatorTagView::COLOR_BLUE)
92-
->setName($this->renderAtomTypeName($atom->getType())));
92+
->setName(DivinerAtom::getAtomTypeNameString($atom->getType())));
9393

9494
$properties = id(new PhabricatorPropertyListView());
9595

@@ -208,10 +208,6 @@ public function processRequest() {
208208
));
209209
}
210210

211-
private function renderAtomTypeName($name) {
212-
return phutil_utf8_ucwords($name);
213-
}
214-
215211
private function buildExtendsAndImplements(
216212
PhabricatorPropertyListView $view,
217213
DivinerLiveSymbol $symbol) {

src/applications/diviner/controller/DivinerController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ protected function renderAtomList(array $symbols) {
3434
$item = id(new PhabricatorObjectItemView())
3535
->setHeader($symbol->getTitle())
3636
->setHref($symbol->getURI())
37-
->addIcon('none', $symbol->getType());
37+
->addIcon('none',
38+
DivinerAtom::getAtomTypeNameString(
39+
$symbol->getType()));
3840

3941
$item->addAttribute(phutil_safe_html($symbol->getSummary()));
4042

0 commit comments

Comments
 (0)