mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +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:
parent
2367b64229
commit
c280634a7a
7 changed files with 57 additions and 22 deletions
|
@ -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(
|
||||||
|
|
|
@ -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'),
|
||||||
);
|
);
|
||||||
|
|
|
@ -152,22 +152,41 @@ final class DivinerAtomController extends DivinerController {
|
||||||
->setHeader($spec['title']));
|
->setHeader($spec['title']));
|
||||||
|
|
||||||
$task_methods = idx($methods_by_task, $spec['name'], array());
|
$task_methods = idx($methods_by_task, $spec['name'], array());
|
||||||
$inner_box = id(new PHUIBoxView())
|
$inner_box = id(new PHUIBoxView())
|
||||||
->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);
|
||||||
if ($task_methods) {
|
|
||||||
$inner_box->appendChild(hsprintf('<ul class="diviner-list">'));
|
$box_content = array();
|
||||||
|
if ($task_methods) {
|
||||||
|
$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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
$list_items[] = phutil_tag('li', array(), $item);
|
||||||
}
|
}
|
||||||
$inner_box->appendChild(hsprintf('</ul>'));
|
|
||||||
|
$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());
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,11 +135,15 @@ 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)
|
||||||
|
->setAtomData($atom->toDictionary())
|
||||||
|
->setContent(null)
|
||||||
|
->save();
|
||||||
|
}
|
||||||
|
|
||||||
$storage = $this->loadAtomStorageForSymbol($symbol)
|
|
||||||
->setAtomData($atom->toDictionary())
|
|
||||||
->setContent(null)
|
|
||||||
->save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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');
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue