1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Link and summarize methods in the "Tasks" view of a Diviner class

Summary: Ref T988. Make this more useful, and link it to the methods it describes.

Test Plan:
Before:

{F57553}

After:

{F57554}

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T988

Differential Revision: https://secure.phabricator.com/D6909
This commit is contained in:
epriestley 2013-09-08 09:12:33 -07:00
parent 2367b64229
commit c280634a7a
7 changed files with 57 additions and 22 deletions

View file

@ -1149,7 +1149,7 @@ celerity_register_resource_map(array(
), ),
'diviner-shared-css' => 'diviner-shared-css' =>
array( array(
'uri' => '/res/1f75ab71/rsrc/css/diviner/diviner-shared.css', 'uri' => '/res/9c11bf88/rsrc/css/diviner/diviner-shared.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(

View file

@ -204,6 +204,7 @@ final class DivinerAtom {
$this->getContentRaw(), $this->getContentRaw(),
$this->getDocblockRaw(), $this->getDocblockRaw(),
$this->getProperties(), $this->getProperties(),
$this->getChildHashes(),
mpull($this->extends, 'toHash'), mpull($this->extends, 'toHash'),
mpull($this->links, 'toHash'), mpull($this->links, 'toHash'),
); );

View file

@ -156,18 +156,37 @@ final class DivinerAtomController extends DivinerController {
->addPadding(PHUI::PADDING_LARGE_LEFT) ->addPadding(PHUI::PADDING_LARGE_LEFT)
->addPadding(PHUI::PADDING_LARGE_RIGHT) ->addPadding(PHUI::PADDING_LARGE_RIGHT)
->addPadding(PHUI::PADDING_LARGE_BOTTOM); ->addPadding(PHUI::PADDING_LARGE_BOTTOM);
$box_content = array();
if ($task_methods) { if ($task_methods) {
$inner_box->appendChild(hsprintf('<ul class="diviner-list">')); $list_items = array();
foreach ($task_methods as $task_method) { foreach ($task_methods as $task_method) {
$atom = last($task_method['atoms']); $atom = last($task_method['atoms']);
$inner_box->appendChild(
hsprintf('<li>%s()</li>', $atom->getName())); $item = $this->renderFullSignature($atom, true);
if (strlen($atom->getSummary())) {
$item = array(
$item,
" \xE2\x80\x94 ",
phutil_safe_html($atom->getSummary()));
} }
$inner_box->appendChild(hsprintf('</ul>'));
$list_items[] = phutil_tag('li', array(), $item);
}
$box_content[] = phutil_tag(
'ul',
array(
'class' => 'diviner-list',
),
$list_items);
} else { } else {
$no_methods = pht('No methods for this task.'); $no_methods = pht('No methods for this task.');
$inner_box->appendChild(hsprintf('<em>%s</em>', $no_methods)); $box_content = phutil_tag('em', array(), $no_methods);
} }
$inner_box->appendChild($box_content);
$section->addContent($inner_box); $section->addContent($inner_box);
} }
$document->appendChild($section); $document->appendChild($section);
@ -406,7 +425,9 @@ final class DivinerAtomController extends DivinerController {
return $task_specs + $extends_task_specs; return $task_specs + $extends_task_specs;
} }
private function renderFullSignature(DivinerLiveSymbol $symbol) { private function renderFullSignature(
DivinerLiveSymbol $symbol,
$is_link = false) {
switch ($symbol->getType()) { switch ($symbol->getType()) {
case DivinerAtom::TYPE_CLASS: case DivinerAtom::TYPE_CLASS:
case DivinerAtom::TYPE_INTERFACE: case DivinerAtom::TYPE_INTERFACE:
@ -471,7 +492,7 @@ final class DivinerAtomController extends DivinerController {
array( array(
'class' => 'diviner-atom-signature-name', 'class' => 'diviner-atom-signature-name',
'href' => $anchor ? '#'.$anchor : null, 'href' => $anchor ? '#'.$anchor : null,
'name' => $anchor, 'name' => $is_link ? null : $anchor,
), ),
$symbol->getName()); $symbol->getName());

View file

@ -38,7 +38,7 @@ abstract class DivinerController extends PhabricatorController {
DivinerAtom::getAtomTypeNameString( DivinerAtom::getAtomTypeNameString(
$symbol->getType())); $symbol->getType()));
$item->addAttribute(phutil_safe_html($symbol->getSummary())); $item->addAttribute($symbol->getSummary());
$list->addItem($item); $list->addItem($item);
} }

View file

@ -117,11 +117,12 @@ final class DivinerLivePublisher extends DivinerPublisher {
->setGroupName($ref->getGroup()) ->setGroupName($ref->getGroup())
->setNodeHash($atom->getHash()); ->setNodeHash($atom->getHash());
if ($is_documentable) { if ($atom->getType() !== DivinerAtom::TYPE_FILE) {
$renderer = $this->getRenderer(); $renderer = $this->getRenderer();
$summary = $renderer->renderAtomSummary($atom); $summary = $renderer->getAtomSummary($atom);
$summary = (string)phutil_safe_html($summary);
$symbol->setSummary($summary); $symbol->setSummary($summary);
} else {
$symbol->setSummary('');
} }
$symbol->save(); $symbol->save();
@ -134,12 +135,16 @@ final class DivinerLivePublisher extends DivinerPublisher {
// documentation, we insert them here. This also means we insert files, // documentation, we insert them here. This also means we insert files,
// which are unnecessary and unused. Make sure this makes sense, but then // which are unnecessary and unused. Make sure this makes sense, but then
// probably introduce separate "isTopLevel" and "isDocumentable" flags? // probably introduce separate "isTopLevel" and "isDocumentable" flags?
// TODO: Yeah do that soon ^^^
if ($atom->getType() !== DivinerAtom::TYPE_FILE) {
$storage = $this->loadAtomStorageForSymbol($symbol) $storage = $this->loadAtomStorageForSymbol($symbol)
->setAtomData($atom->toDictionary()) ->setAtomData($atom->toDictionary())
->setContent(null) ->setContent(null)
->save(); ->save();
} }
}
} }
public function findAtomByRef(DivinerAtomRef $ref) { public function findAtomByRef(DivinerAtomRef $ref) {

View file

@ -124,7 +124,7 @@ final class DivinerDefaultRenderer extends DivinerRenderer {
$summary); $summary);
} }
protected function getAtomSummary(DivinerAtom $atom) { public function getAtomSummary(DivinerAtom $atom) {
if ($atom->getDocblockMetaValue('summary')) { if ($atom->getDocblockMetaValue('summary')) {
return $atom->getDocblockMetaValue('summary'); return $atom->getDocblockMetaValue('summary');
} }

View file

@ -81,3 +81,11 @@
.diviner-atom-signature-name { .diviner-atom-signature-name {
font-weight: bold; font-weight: bold;
} }
.diviner-list .diviner-atom-signature {
color: {$greytext};
}
.diviner-list a {
font-weight: bold;
}