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' =>
array(
'uri' => '/res/1f75ab71/rsrc/css/diviner/diviner-shared.css',
'uri' => '/res/9c11bf88/rsrc/css/diviner/diviner-shared.css',
'type' => 'css',
'requires' =>
array(

View file

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

View file

@ -152,22 +152,41 @@ final class DivinerAtomController extends DivinerController {
->setHeader($spec['title']));
$task_methods = idx($methods_by_task, $spec['name'], array());
$inner_box = id(new PHUIBoxView())
->addPadding(PHUI::PADDING_LARGE_LEFT)
->addPadding(PHUI::PADDING_LARGE_RIGHT)
->addPadding(PHUI::PADDING_LARGE_BOTTOM);
if ($task_methods) {
$inner_box->appendChild(hsprintf('<ul class="diviner-list">'));
$inner_box = id(new PHUIBoxView())
->addPadding(PHUI::PADDING_LARGE_LEFT)
->addPadding(PHUI::PADDING_LARGE_RIGHT)
->addPadding(PHUI::PADDING_LARGE_BOTTOM);
$box_content = array();
if ($task_methods) {
$list_items = array();
foreach ($task_methods as $task_method) {
$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()));
}
$list_items[] = phutil_tag('li', array(), $item);
}
$inner_box->appendChild(hsprintf('</ul>'));
$box_content[] = phutil_tag(
'ul',
array(
'class' => 'diviner-list',
),
$list_items);
} else {
$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);
}
$document->appendChild($section);
@ -406,7 +425,9 @@ final class DivinerAtomController extends DivinerController {
return $task_specs + $extends_task_specs;
}
private function renderFullSignature(DivinerLiveSymbol $symbol) {
private function renderFullSignature(
DivinerLiveSymbol $symbol,
$is_link = false) {
switch ($symbol->getType()) {
case DivinerAtom::TYPE_CLASS:
case DivinerAtom::TYPE_INTERFACE:
@ -471,7 +492,7 @@ final class DivinerAtomController extends DivinerController {
array(
'class' => 'diviner-atom-signature-name',
'href' => $anchor ? '#'.$anchor : null,
'name' => $anchor,
'name' => $is_link ? null : $anchor,
),
$symbol->getName());

View file

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

View file

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

View file

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

View file

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