From 2367b6422945822d4ca564b31e864125c8d4822a Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 8 Sep 2013 09:11:59 -0700 Subject: [PATCH] Render Diviner atom signatures on one line Summary: Ref T988. Instead of rendering this: ClassName final class ClassName methodName final public function methodName(...) ...just render this: final class ClassName final public function methodName(...) Also link and anchor the method names. Test Plan: Before: {F57536} {F57537} After: {F57538} {F57539} Reviewers: chad Reviewed By: chad CC: aran Maniphest Tasks: T988 Differential Revision: https://secure.phabricator.com/D6908 --- src/__celerity_resource_map__.php | 2 +- .../controller/DivinerAtomController.php | 40 ++++++++++++++----- webroot/rsrc/css/diviner/diviner-shared.css | 8 ++++ 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/__celerity_resource_map__.php b/src/__celerity_resource_map__.php index 0aced7210d..196e0daa59 100644 --- a/src/__celerity_resource_map__.php +++ b/src/__celerity_resource_map__.php @@ -1149,7 +1149,7 @@ celerity_register_resource_map(array( ), 'diviner-shared-css' => array( - 'uri' => '/res/cf15b860/rsrc/css/diviner/diviner-shared.css', + 'uri' => '/res/1f75ab71/rsrc/css/diviner/diviner-shared.css', 'type' => 'css', 'requires' => array( diff --git a/src/applications/diviner/controller/DivinerAtomController.php b/src/applications/diviner/controller/DivinerAtomController.php index 33bf9cba99..074e400bde 100644 --- a/src/applications/diviner/controller/DivinerAtomController.php +++ b/src/applications/diviner/controller/DivinerAtomController.php @@ -71,13 +71,12 @@ final class DivinerAtomController extends DivinerController { ->setName($atom_short_title)); $header = id(new PhabricatorHeaderView()) - ->setHeader($symbol->getTitle()) + ->setHeader($this->renderFullSignature($symbol)) ->addTag( id(new PhabricatorTagView()) ->setType(PhabricatorTagView::TYPE_STATE) ->setBackgroundColor(PhabricatorTagView::COLOR_BLUE) - ->setName(DivinerAtom::getAtomTypeNameString($atom->getType()))) - ->setSubheader($this->renderFullSignature($symbol)); + ->setName(DivinerAtom::getAtomTypeNameString($atom->getType()))); $properties = id(new PhabricatorPropertyListView()); @@ -180,8 +179,7 @@ final class DivinerAtomController extends DivinerController { foreach ($methods as $spec) { $matom = last($spec['atoms']); $method_header = id(new PhabricatorHeaderView()) - ->setNoBackground(true) - ->setHeader($matom->getName()); + ->setNoBackground(true); $inherited = $spec['inherited']; if ($inherited) { @@ -192,8 +190,7 @@ final class DivinerAtomController extends DivinerController { ->setName(pht('Inherited'))); } - $method_header->setSubheader( - $this->renderFullSignature($matom)); + $method_header->setHeader($this->renderFullSignature($matom)); $section->addContent( array( @@ -460,9 +457,25 @@ final class DivinerAtomController extends DivinerController { break; } - $out[] = $symbol->getName(); + $anchor = null; + switch ($symbol->getType()) { + case DivinerAtom::TYPE_METHOD: + $anchor = $symbol->getType().'/'.$symbol->getName(); + break; + default: + break; + } - $out = implode(' ', $out); + $out[] = phutil_tag( + $anchor ? 'a' : 'span', + array( + 'class' => 'diviner-atom-signature-name', + 'href' => $anchor ? '#'.$anchor : null, + 'name' => $anchor, + ), + $symbol->getName()); + + $out = phutil_implode_html(' ', $out); $parameters = $atom->getProperty('parameters'); if ($parameters !== null) { @@ -470,10 +483,15 @@ final class DivinerAtomController extends DivinerController { foreach ($parameters as $parameter) { $pout[] = $parameter['name']; } - $out .= '('.implode(', ', $pout).')'; + $out = array($out, '('.implode(', ', $pout).')'); } - return $out; + return phutil_tag( + 'span', + array( + 'class' => 'diviner-atom-signature', + ), + $out); } private function buildParametersAndReturn(array $symbols) { diff --git a/webroot/rsrc/css/diviner/diviner-shared.css b/webroot/rsrc/css/diviner/diviner-shared.css index b07decb535..4479ae6019 100644 --- a/webroot/rsrc/css/diviner/diviner-shared.css +++ b/webroot/rsrc/css/diviner/diviner-shared.css @@ -73,3 +73,11 @@ .diviner-method-implementation-header { color: {$lightgreytext}; } + +.diviner-atom-signature { + font-weight: normal; +} + +.diviner-atom-signature-name { + font-weight: bold; +}