mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 17:02:41 +01:00
Allow ghost atoms to be rendered
Summary: Ref T4558. Allow ghost atoms to be rendered in #diviner. This functionality didn't exist previously, but was hinted at by the TODO comments. Test Plan: Generated #diviner documentation for rARC and then removed a class (before re-generating the documentation). Navigated to the documentation for the removed class and saw "This atom no longer exists". Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley Maniphest Tasks: T4558 Differential Revision: https://secure.phabricator.com/D13114
This commit is contained in:
parent
c1c897b961
commit
006a877996
3 changed files with 102 additions and 59 deletions
|
@ -35,11 +35,6 @@ final class DivinerAtomController extends DivinerController {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This query won't load ghosts, because they'll fail `needAtoms()`.
|
|
||||||
// Instead, we might want to load ghosts and render a message like
|
|
||||||
// "this thing existed in an older version, but no longer does", especially
|
|
||||||
// if we add content like comments.
|
|
||||||
|
|
||||||
$symbol = id(new DivinerAtomQuery())
|
$symbol = id(new DivinerAtomQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withBookPHIDs(array($book->getPHID()))
|
->withBookPHIDs(array($book->getPHID()))
|
||||||
|
@ -47,7 +42,6 @@ final class DivinerAtomController extends DivinerController {
|
||||||
->withNames(array($this->atomName))
|
->withNames(array($this->atomName))
|
||||||
->withContexts(array($this->atomContext))
|
->withContexts(array($this->atomContext))
|
||||||
->withIndexes(array($this->atomIndex))
|
->withIndexes(array($this->atomIndex))
|
||||||
->withGhosts(false)
|
|
||||||
->withIsDocumentable(true)
|
->withIsDocumentable(true)
|
||||||
->needAtoms(true)
|
->needAtoms(true)
|
||||||
->needExtends(true)
|
->needExtends(true)
|
||||||
|
@ -66,9 +60,9 @@ final class DivinerAtomController extends DivinerController {
|
||||||
$book->getShortTitle(),
|
$book->getShortTitle(),
|
||||||
'/book/'.$book->getName().'/');
|
'/book/'.$book->getName().'/');
|
||||||
|
|
||||||
$atom_short_title = $atom->getDocblockMetaValue(
|
$atom_short_title = $atom
|
||||||
'short',
|
? $atom->getDocblockMetaValue('short', $symbol->getTitle())
|
||||||
$symbol->getTitle());
|
: $symbol->getTitle();
|
||||||
|
|
||||||
$crumbs->addTextCrumb($atom_short_title);
|
$crumbs->addTextCrumb($atom_short_title);
|
||||||
|
|
||||||
|
@ -78,26 +72,38 @@ final class DivinerAtomController extends DivinerController {
|
||||||
id(new PHUITagView())
|
id(new PHUITagView())
|
||||||
->setType(PHUITagView::TYPE_STATE)
|
->setType(PHUITagView::TYPE_STATE)
|
||||||
->setBackgroundColor(PHUITagView::COLOR_BLUE)
|
->setBackgroundColor(PHUITagView::COLOR_BLUE)
|
||||||
->setName(DivinerAtom::getAtomTypeNameString($atom->getType())));
|
->setName(DivinerAtom::getAtomTypeNameString(
|
||||||
|
$atom ? $atom->getType() : $symbol->getType())));
|
||||||
|
|
||||||
$properties = id(new PHUIPropertyListView());
|
$properties = id(new PHUIPropertyListView());
|
||||||
|
|
||||||
$group = $atom->getProperty('group');
|
$group = $atom ? $atom->getProperty('group') : $symbol->getGroupName();
|
||||||
if ($group) {
|
if ($group) {
|
||||||
$group_name = $book->getGroupName($group);
|
$group_name = $book->getGroupName($group);
|
||||||
} else {
|
} else {
|
||||||
$group_name = null;
|
$group_name = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->buildDefined($properties, $symbol);
|
$document = id(new PHUIDocumentView())
|
||||||
$this->buildExtendsAndImplements($properties, $symbol);
|
->setBook($book->getTitle(), $group_name)
|
||||||
|
->setHeader($header)
|
||||||
|
->addClass('diviner-view')
|
||||||
|
->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS)
|
||||||
|
->appendChild($properties);
|
||||||
|
|
||||||
$warnings = $atom->getWarnings();
|
if ($atom) {
|
||||||
if ($warnings) {
|
$this->buildDefined($properties, $symbol);
|
||||||
$warnings = id(new PHUIInfoView())
|
$this->buildExtendsAndImplements($properties, $symbol);
|
||||||
->setErrors($warnings)
|
|
||||||
->setTitle(pht('Documentation Warnings'))
|
$warnings = $atom->getWarnings();
|
||||||
->setSeverity(PHUIInfoView::SEVERITY_WARNING);
|
if ($warnings) {
|
||||||
|
$warnings = id(new PHUIInfoView())
|
||||||
|
->setErrors($warnings)
|
||||||
|
->setTitle(pht('Documentation Warnings'))
|
||||||
|
->setSeverity(PHUIInfoView::SEVERITY_WARNING);
|
||||||
|
}
|
||||||
|
|
||||||
|
$document->appendChild($warnings);
|
||||||
}
|
}
|
||||||
|
|
||||||
$methods = $this->composeMethods($symbol);
|
$methods = $this->composeMethods($symbol);
|
||||||
|
@ -113,7 +119,10 @@ final class DivinerAtomController extends DivinerController {
|
||||||
}
|
}
|
||||||
$engine->process();
|
$engine->process();
|
||||||
|
|
||||||
$content = $this->renderDocumentationText($symbol, $engine);
|
if ($atom) {
|
||||||
|
$content = $this->renderDocumentationText($symbol, $engine);
|
||||||
|
$document->appendChild($content);
|
||||||
|
}
|
||||||
|
|
||||||
$toc = $engine->getEngineMetadata(
|
$toc = $engine->getEngineMetadata(
|
||||||
$symbol,
|
$symbol,
|
||||||
|
@ -121,16 +130,18 @@ final class DivinerAtomController extends DivinerController {
|
||||||
PhutilRemarkupHeaderBlockRule::KEY_HEADER_TOC,
|
PhutilRemarkupHeaderBlockRule::KEY_HEADER_TOC,
|
||||||
array());
|
array());
|
||||||
|
|
||||||
$document = id(new PHUIDocumentView())
|
if (!$atom) {
|
||||||
->setBook($book->getTitle(), $group_name)
|
$document->appendChild(
|
||||||
->setHeader($header)
|
id(new PHUIInfoView())
|
||||||
->addClass('diviner-view')
|
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
|
||||||
->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS)
|
->appendChild(
|
||||||
->appendChild($properties)
|
pht(
|
||||||
->appendChild($warnings)
|
'This atom no longer exists.')));
|
||||||
->appendChild($content);
|
}
|
||||||
|
|
||||||
$document->appendChild($this->buildParametersAndReturn(array($symbol)));
|
if ($atom) {
|
||||||
|
$document->appendChild($this->buildParametersAndReturn(array($symbol)));
|
||||||
|
}
|
||||||
|
|
||||||
if ($methods) {
|
if ($methods) {
|
||||||
$tasks = $this->composeTasks($symbol);
|
$tasks = $this->composeTasks($symbol);
|
||||||
|
@ -202,7 +213,7 @@ final class DivinerAtomController extends DivinerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
$section = id(new DivinerSectionView())
|
$section = id(new DivinerSectionView())
|
||||||
->setHeader(pht('Methods'));
|
->setHeader(pht('Methods'));
|
||||||
|
|
||||||
foreach ($methods as $spec) {
|
foreach ($methods as $spec) {
|
||||||
$matom = last($spec['atoms']);
|
$matom = last($spec['atoms']);
|
||||||
|
@ -473,20 +484,23 @@ final class DivinerAtomController extends DivinerController {
|
||||||
$atom = $symbol->getAtom();
|
$atom = $symbol->getAtom();
|
||||||
|
|
||||||
$out = array();
|
$out = array();
|
||||||
if ($atom->getProperty('final')) {
|
|
||||||
$out[] = 'final';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($atom->getProperty('abstract')) {
|
if ($atom) {
|
||||||
$out[] = 'abstract';
|
if ($atom->getProperty('final')) {
|
||||||
}
|
$out[] = 'final';
|
||||||
|
}
|
||||||
|
|
||||||
if ($atom->getProperty('access')) {
|
if ($atom->getProperty('abstract')) {
|
||||||
$out[] = $atom->getProperty('access');
|
$out[] = 'abstract';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($atom->getProperty('static')) {
|
if ($atom->getProperty('access')) {
|
||||||
$out[] = 'static';
|
$out[] = $atom->getProperty('access');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($atom->getProperty('static')) {
|
||||||
|
$out[] = 'static';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($symbol->getType()) {
|
switch ($symbol->getType()) {
|
||||||
|
@ -530,13 +544,15 @@ final class DivinerAtomController extends DivinerController {
|
||||||
|
|
||||||
$out = phutil_implode_html(' ', $out);
|
$out = phutil_implode_html(' ', $out);
|
||||||
|
|
||||||
$parameters = $atom->getProperty('parameters');
|
if ($atom) {
|
||||||
if ($parameters !== null) {
|
$parameters = $atom->getProperty('parameters');
|
||||||
$pout = array();
|
if ($parameters !== null) {
|
||||||
foreach ($parameters as $parameter) {
|
$pout = array();
|
||||||
$pout[] = idx($parameter, 'name', '...');
|
foreach ($parameters as $parameter) {
|
||||||
|
$pout[] = idx($parameter, 'name', '...');
|
||||||
|
}
|
||||||
|
$out = array($out, '('.implode(', ', $pout).')');
|
||||||
}
|
}
|
||||||
$out = array($out, '('.implode(', ', $pout).')');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return phutil_tag(
|
return phutil_tag(
|
||||||
|
|
|
@ -151,10 +151,6 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
|
|
||||||
foreach ($atoms as $key => $atom) {
|
foreach ($atoms as $key => $atom) {
|
||||||
$data = idx($atom_data, $atom->getPHID());
|
$data = idx($atom_data, $atom->getPHID());
|
||||||
if (!$data) {
|
|
||||||
unset($atoms[$key]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$atom->attachAtom($data);
|
$atom->attachAtom($data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,6 +166,10 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
|
|
||||||
$names = array();
|
$names = array();
|
||||||
foreach ($atoms as $atom) {
|
foreach ($atoms as $atom) {
|
||||||
|
if (!$atom->getAtom()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($atom->getAtom()->getExtends() as $xref) {
|
foreach ($atom->getAtom()->getExtends() as $xref) {
|
||||||
$names[] = $xref->getName();
|
$names[] = $xref->getName();
|
||||||
}
|
}
|
||||||
|
@ -189,10 +189,17 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($atoms as $atom) {
|
foreach ($atoms as $atom) {
|
||||||
$alang = $atom->getAtom()->getLanguage();
|
$atom_lang = null;
|
||||||
$extends = array();
|
$atom_extends = array();
|
||||||
foreach ($atom->getAtom()->getExtends() as $xref) {
|
|
||||||
|
|
||||||
|
if ($atom->getAtom()) {
|
||||||
|
$atom_lang = $atom->getAtom()->getLanguage();
|
||||||
|
$atom_extends = $atom->getAtom()->getExtends();
|
||||||
|
}
|
||||||
|
|
||||||
|
$extends = array();
|
||||||
|
|
||||||
|
foreach ($atom_extends as $xref) {
|
||||||
// If there are no symbols of the matching name and type, we can't
|
// If there are no symbols of the matching name and type, we can't
|
||||||
// resolve this.
|
// resolve this.
|
||||||
if (empty($xatoms[$xref->getName()][$xref->getType()])) {
|
if (empty($xatoms[$xref->getName()][$xref->getType()])) {
|
||||||
|
@ -216,7 +223,7 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
// classes can not implement JS classes.
|
// classes can not implement JS classes.
|
||||||
$same_lang = array();
|
$same_lang = array();
|
||||||
foreach ($maybe as $xatom) {
|
foreach ($maybe as $xatom) {
|
||||||
if ($xatom->getAtom()->getLanguage() == $alang) {
|
if ($xatom->getAtom()->getLanguage() == $atom_lang) {
|
||||||
$same_lang[] = $xatom;
|
$same_lang[] = $xatom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -396,7 +403,13 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
|
|
||||||
$hashes = array();
|
$hashes = array();
|
||||||
foreach ($symbols as $symbol) {
|
foreach ($symbols as $symbol) {
|
||||||
foreach ($symbol->getAtom()->getChildHashes() as $hash) {
|
$child_hashes = array();
|
||||||
|
|
||||||
|
if ($symbol->getAtom()) {
|
||||||
|
$child_hashes = $symbol->getAtom()->getChildHashes();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($child_hashes as $hash) {
|
||||||
$hashes[$hash] = $hash;
|
$hashes[$hash] = $hash;
|
||||||
}
|
}
|
||||||
if ($recurse_up) {
|
if ($recurse_up) {
|
||||||
|
@ -426,8 +439,14 @@ final class DivinerAtomQuery extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||||
assert_instances_of($children, 'DivinerLiveSymbol');
|
assert_instances_of($children, 'DivinerLiveSymbol');
|
||||||
|
|
||||||
foreach ($symbols as $symbol) {
|
foreach ($symbols as $symbol) {
|
||||||
|
$child_hashes = array();
|
||||||
$symbol_children = array();
|
$symbol_children = array();
|
||||||
foreach ($symbol->getAtom()->getChildHashes() as $hash) {
|
|
||||||
|
if ($symbol->getAtom()) {
|
||||||
|
$child_hashes = $symbol->getAtom()->getChildHashes();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($child_hashes as $hash) {
|
||||||
if (isset($children[$hash])) {
|
if (isset($children[$hash])) {
|
||||||
$symbol_children[] = $children[$hash];
|
$symbol_children[] = $children[$hash];
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,12 @@ final class DivinerLiveSymbol extends DivinerDAO
|
||||||
return $this->assertAttached($this->atom);
|
return $this->assertAttached($this->atom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attachAtom(DivinerLiveAtom $atom) {
|
public function attachAtom(DivinerLiveAtom $atom = null) {
|
||||||
$this->atom = DivinerAtom::newFromDictionary($atom->getAtomData());
|
if ($atom === null) {
|
||||||
|
$this->atom = null;
|
||||||
|
} else {
|
||||||
|
$this->atom = DivinerAtom::newFromDictionary($atom->getAtomData());
|
||||||
|
}
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,6 +233,10 @@ final class DivinerLiveSymbol extends DivinerDAO
|
||||||
|
|
||||||
|
|
||||||
public function getMarkupText($field) {
|
public function getMarkupText($field) {
|
||||||
|
if (!$this->getAtom()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->getAtom()->getDocblockText();
|
return $this->getAtom()->getDocblockText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue