1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 16:30:59 +01:00

Clean up some more Diviner stuff

Summary:
Ref T988.

  - Render "Implements:" as tags, too.
  - Minor CSS tweak to tags in property lists.
  - Add a bunch of group patterns to the Phabricator book.
  - Fix some stuff with how hashes are computed and cached.
  - Minor tweak to reuse the Diviner engine for slightly improved performance.

Test Plan: Regenerated and looked at documentation.

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T3811, T988

Differential Revision: https://secure.phabricator.com/D6912
This commit is contained in:
epriestley 2013-09-08 09:16:55 -07:00
parent f1dc56a687
commit 194245ed62
9 changed files with 349 additions and 63 deletions

View file

@ -1149,7 +1149,7 @@ celerity_register_resource_map(array(
),
'diviner-shared-css' =>
array(
'uri' => '/res/4237d999/rsrc/css/diviner/diviner-shared.css',
'uri' => '/res/bcc425bb/rsrc/css/diviner/diviner-shared.css',
'type' => 'css',
'requires' =>
array(
@ -3385,7 +3385,7 @@ celerity_register_resource_map(array(
),
'phabricator-property-list-view-css' =>
array(
'uri' => '/res/145d1f9a/rsrc/css/layout/phabricator-property-list-view.css',
'uri' => '/res/fdcbf4ab/rsrc/css/layout/phabricator-property-list-view.css',
'type' => 'css',
'requires' =>
array(
@ -4171,7 +4171,7 @@ celerity_register_resource_map(array(
), array(
'packages' =>
array(
'471e18ad' =>
'3806f0da' =>
array(
'name' => 'core.pkg.css',
'symbols' =>
@ -4218,7 +4218,7 @@ celerity_register_resource_map(array(
39 => 'phabricator-property-list-view-css',
40 => 'phabricator-tag-view-css',
),
'uri' => '/res/pkg/471e18ad/core.pkg.css',
'uri' => '/res/pkg/3806f0da/core.pkg.css',
'type' => 'css',
),
'8977e356' =>
@ -4409,15 +4409,15 @@ celerity_register_resource_map(array(
),
'reverse' =>
array(
'aphront-dialog-view-css' => '471e18ad',
'aphront-error-view-css' => '471e18ad',
'aphront-list-filter-view-css' => '471e18ad',
'aphront-pager-view-css' => '471e18ad',
'aphront-panel-view-css' => '471e18ad',
'aphront-table-view-css' => '471e18ad',
'aphront-tokenizer-control-css' => '471e18ad',
'aphront-tooltip-css' => '471e18ad',
'aphront-typeahead-control-css' => '471e18ad',
'aphront-dialog-view-css' => '3806f0da',
'aphront-error-view-css' => '3806f0da',
'aphront-list-filter-view-css' => '3806f0da',
'aphront-pager-view-css' => '3806f0da',
'aphront-panel-view-css' => '3806f0da',
'aphront-table-view-css' => '3806f0da',
'aphront-tokenizer-control-css' => '3806f0da',
'aphront-tooltip-css' => '3806f0da',
'aphront-typeahead-control-css' => '3806f0da',
'differential-changeset-view-css' => '44bfe40c',
'differential-core-view-css' => '44bfe40c',
'differential-inline-comment-editor' => 'd07a3bc2',
@ -4431,7 +4431,7 @@ celerity_register_resource_map(array(
'differential-table-of-contents-css' => '44bfe40c',
'diffusion-commit-view-css' => 'c8ce2d88',
'diffusion-icons-css' => 'c8ce2d88',
'global-drag-and-drop-css' => '471e18ad',
'global-drag-and-drop-css' => '3806f0da',
'inline-comment-summary-css' => '44bfe40c',
'javelin-aphlict' => '8977e356',
'javelin-behavior' => '2dbbb7d1',
@ -4504,55 +4504,55 @@ celerity_register_resource_map(array(
'javelin-util' => '2dbbb7d1',
'javelin-vector' => '2dbbb7d1',
'javelin-workflow' => '2dbbb7d1',
'lightbox-attachment-css' => '471e18ad',
'lightbox-attachment-css' => '3806f0da',
'maniphest-task-summary-css' => '0a9e494f',
'maniphest-transaction-detail-css' => '0a9e494f',
'phabricator-action-list-view-css' => '471e18ad',
'phabricator-application-launch-view-css' => '471e18ad',
'phabricator-action-list-view-css' => '3806f0da',
'phabricator-application-launch-view-css' => '3806f0da',
'phabricator-busy' => '8977e356',
'phabricator-content-source-view-css' => '44bfe40c',
'phabricator-core-css' => '471e18ad',
'phabricator-crumbs-view-css' => '471e18ad',
'phabricator-core-css' => '3806f0da',
'phabricator-crumbs-view-css' => '3806f0da',
'phabricator-drag-and-drop-file-upload' => 'd07a3bc2',
'phabricator-dropdown-menu' => '8977e356',
'phabricator-file-upload' => '8977e356',
'phabricator-filetree-view-css' => '471e18ad',
'phabricator-flag-css' => '471e18ad',
'phabricator-header-view-css' => '471e18ad',
'phabricator-filetree-view-css' => '3806f0da',
'phabricator-flag-css' => '3806f0da',
'phabricator-header-view-css' => '3806f0da',
'phabricator-hovercard' => '8977e356',
'phabricator-jump-nav' => '471e18ad',
'phabricator-jump-nav' => '3806f0da',
'phabricator-keyboard-shortcut' => '8977e356',
'phabricator-keyboard-shortcut-manager' => '8977e356',
'phabricator-main-menu-view' => '471e18ad',
'phabricator-main-menu-view' => '3806f0da',
'phabricator-menu-item' => '8977e356',
'phabricator-nav-view-css' => '471e18ad',
'phabricator-nav-view-css' => '3806f0da',
'phabricator-notification' => '8977e356',
'phabricator-notification-css' => '471e18ad',
'phabricator-notification-menu-css' => '471e18ad',
'phabricator-object-item-list-view-css' => '471e18ad',
'phabricator-notification-css' => '3806f0da',
'phabricator-notification-menu-css' => '3806f0da',
'phabricator-object-item-list-view-css' => '3806f0da',
'phabricator-object-selector-css' => '44bfe40c',
'phabricator-phtize' => '8977e356',
'phabricator-prefab' => '8977e356',
'phabricator-project-tag-css' => '0a9e494f',
'phabricator-property-list-view-css' => '471e18ad',
'phabricator-remarkup-css' => '471e18ad',
'phabricator-property-list-view-css' => '3806f0da',
'phabricator-remarkup-css' => '3806f0da',
'phabricator-shaped-request' => 'd07a3bc2',
'phabricator-side-menu-view-css' => '471e18ad',
'phabricator-standard-page-view' => '471e18ad',
'phabricator-tag-view-css' => '471e18ad',
'phabricator-side-menu-view-css' => '3806f0da',
'phabricator-standard-page-view' => '3806f0da',
'phabricator-tag-view-css' => '3806f0da',
'phabricator-textareautils' => '8977e356',
'phabricator-tooltip' => '8977e356',
'phabricator-transaction-view-css' => '471e18ad',
'phabricator-zindex-css' => '471e18ad',
'phui-button-css' => '471e18ad',
'phui-form-css' => '471e18ad',
'phui-form-view-css' => '471e18ad',
'phui-icon-view-css' => '471e18ad',
'phui-spacing-css' => '471e18ad',
'sprite-apps-large-css' => '471e18ad',
'sprite-gradient-css' => '471e18ad',
'sprite-icons-css' => '471e18ad',
'sprite-menu-css' => '471e18ad',
'syntax-highlighting-css' => '471e18ad',
'phabricator-transaction-view-css' => '3806f0da',
'phabricator-zindex-css' => '3806f0da',
'phui-button-css' => '3806f0da',
'phui-form-css' => '3806f0da',
'phui-form-view-css' => '3806f0da',
'phui-icon-view-css' => '3806f0da',
'phui-spacing-css' => '3806f0da',
'sprite-apps-large-css' => '3806f0da',
'sprite-gradient-css' => '3806f0da',
'sprite-icons-css' => '3806f0da',
'sprite-menu-css' => '3806f0da',
'syntax-highlighting-css' => '3806f0da',
),
));

View file

@ -21,7 +21,9 @@ final class DivinerAtom {
private $docblockText;
private $docblockMeta;
private $warnings = array();
private $parent;
private $parentHash;
private $children = array();
private $childHashes = array();
private $context;
private $extends = array();
@ -209,7 +211,8 @@ final class DivinerAtom {
mpull($this->links, 'toHash'),
);
return md5(serialize($parts)).'N';
$this->hash = md5(serialize($parts)).'N';
return $this->hash;
}
public function setLength($length) {
@ -236,6 +239,9 @@ final class DivinerAtom {
}
public function getChildHashes() {
if (!$this->childHashes && $this->children) {
$this->childHashes = mpull($this->children, 'getHash');
}
return $this->childHashes;
}
@ -247,13 +253,32 @@ final class DivinerAtom {
return $this;
}
public function hasParent() {
return $this->parent || $this->parentHash;
}
public function setParent(DivinerAtom $atom) {
if ($this->parentHash) {
throw new Exception("Parent hash has already been computed!");
}
$this->parent = $atom;
return $this;
}
public function getParentHash() {
if ($this->parent && !$this->parentHash) {
$this->parentHash = $this->parent->getHash();
}
return $this->parentHash;
}
public function addChild(DivinerAtom $atom) {
$atom->setParentHash($this->getHash());
$this->addChildHash($atom->getHash());
if ($this->childHashes) {
throw new Exception("Child hashes have already been computed!");
}
$atom->setParent($this);
$this->children[] = $atom;
return $this;
}

View file

@ -24,6 +24,8 @@ final class DivinerAtomController extends DivinerController {
$request = $this->getRequest();
$viewer = $request->getUser();
require_celerity_resource('diviner-shared-css');
$book = id(new DivinerBookQuery())
->setViewer($viewer)
->withNames(array($this->bookName))
@ -260,10 +262,7 @@ final class DivinerAtomController extends DivinerController {
if ($lineage) {
$tags = array();
foreach ($lineage as $item) {
$tags[] = id(new PhabricatorTagView())
->setType(PhabricatorTagView::TYPE_OBJECT)
->setName($item->getName())
->setHref($item->getURI());
$tags[] = $this->renderAtomTag($item);
}
$tags = phutil_implode_html(" \xE2\x96\xB6 ", $tags);
@ -277,9 +276,12 @@ final class DivinerAtomController extends DivinerController {
$via = $spec['via'];
$iface = $spec['interface'];
if ($via == $symbol) {
$items[] = $iface->getName();
$items[] = $this->renderAtomTag($iface);
} else {
$items[] = $iface->getName().' (via '.$via->getName().')';
$items[] = array(
$this->renderAtomTag($iface),
" \xE2\x97\x80 ",
$this->renderAtomTag($via));
}
}
@ -290,6 +292,13 @@ final class DivinerAtomController extends DivinerController {
}
private function renderAtomTag(DivinerLiveSymbol $symbol) {
return id(new PhabricatorTagView())
->setType(PhabricatorTagView::TYPE_OBJECT)
->setName($symbol->getName())
->setHref($symbol->getURI());
}
private function getExtendsLineage(DivinerLiveSymbol $symbol) {
foreach ($symbol->getExtends() as $extends) {
if ($extends->getType() == 'class') {
@ -521,7 +530,7 @@ final class DivinerAtomController extends DivinerController {
if ($parameters !== null) {
$pout = array();
foreach ($parameters as $parameter) {
$pout[] = $parameter['name'];
$pout[] = idx($parameter, 'name', '...');
}
$out = array($out, '('.implode(', ', $pout).')');
}

View file

@ -153,13 +153,7 @@ final class DivinerLiveSymbol extends DivinerDAO
public function newMarkupEngine($field) {
$engine = PhabricatorMarkupEngine::newMarkupEngine(array());
$engine->setConfig('preserve-linebreaks', false);
// $engine->setConfig('diviner.renderer', new DivinerDefaultRenderer());
$engine->setConfig('header.generate-toc', true);
return $engine;
return PhabricatorMarkupEngine::getEngine('diviner');
}

View file

@ -105,7 +105,7 @@ final class DivinerAtomizeWorkflow extends DivinerWorkflow {
$atoms = $atomizer->atomize($file, $data, $context);
foreach ($atoms as $atom) {
if (!$atom->getParentHash()) {
if (!$atom->hasParent()) {
$file_atom->addChild($atom);
}
}

View file

@ -11,15 +11,260 @@
},
"exclude" : [
"(^externals/)",
"(^webroot/rsrc/externals/)",
"(^scripts/)",
"(^support/)",
"(^resources/)",
"(^src/docs/user/)"
],
"groups" : {
"arcanist" : {
"name" : "Arcanist Integration",
"include" : "(^src/applications/arcanist/)"
},
"audit" : {
"name" : "Audit",
"include" : "(^src/applications/audit/)"
},
"auth" : {
"name" : "Auth",
"include" : "(^src/applications/auth/)"
},
"baseapp" : {
"name" : "Application Basics",
"include" : "(^src/applications/base/)"
},
"cache" : {
"name" : "Cache",
"include" : "(^src/applications/cache/)"
},
"calendar" : {
"name" : "Calendar",
"include" : "(^src/applications/calendar/)"
},
"chatlog" : {
"name" : "Chatlog",
"include" : "(^src/applications/chatlog/)"
},
"conduit" : {
"name" : "Conduit",
"include" : "(^src/applications/conduit/)"
},
"config" : {
"name" : "Config",
"include" : "(^src/applications/config/)"
},
"conpherence" : {
"name" : "Conpherence",
"include" : "(^src/applications/conpherence/)"
},
"countdown" : {
"name" : "Countdown",
"include" : "(^src/applications/countdown/)"
},
"daemon" : {
"name" : "Daemons",
"include" : "(^src/applications/daemon/)"
},
"differential" : {
"name" : "Differential",
"include" : "(^src/applications/differential/)"
},
"diffusion" : {
"name" : "Diffusion",
"include" : "(^src/applications/diffusion/)"
},
"directory" : {
"name" : "Directory",
"include" : "(^src/applications/directory/)"
},
"diviner" : {
"name" : "Diviner",
"include" : "(^src/applications/diviner/)"
},
"doorkeeper" : {
"name" : "Doorkeeper",
"include" : "(^src/applications/doorkeeper/)"
},
"draft" : {
"name" : "Draft",
"include" : "(^src/applications/draft/)"
},
"drydock" : {
"name" : "Drydock",
"include" : "(^src/applications/drydock/)"
},
"fact" : {
"name" : "Fact",
"include" : "(^src/applications/fact/)"
},
"feed" : {
"name" : "Feed",
"include" : "(^src/applications/feed/)"
},
"files" : {
"name" : "Files",
"include" : "(^src/applications/files/)"
},
"flag" : {
"name" : "Flags",
"include" : "(^src/applications/flag/)"
},
"harbormaster" : {
"name" : "Harbormaster",
"include" : "(^src/applications/harbormaster/)"
},
"help" : {
"name" : "Help",
"include" : "(^src/applications/help/)"
},
"herald" : {
"name" : "Herald",
"include" : "(^src/applications/herald/)"
},
"legalpad" : {
"name" : "Legalpad",
"include" : "(^src/applications/legalpad/)"
},
"lipsum" : {
"name" : "Lipsum",
"include" : "(^src/applications/lipsum/)"
},
"macro" : {
"name" : "Macro",
"include" : "(^src/applications/macro/)"
},
"mailinglists" : {
"name" : "Mailing Lists",
"include" : "(^src/applications/mailinglists/)"
},
"maniphest" : {
"name" : "Maniphest",
"include" : "(^src/applications/maniphest/)"
},
"meta" : {
"name" : "Meta",
"include" : "(^src/applications/meta/)"
},
"metamta" : {
"name" : "MetaMTA",
"include" : "(^src/applications/metamta/)"
},
"notification" : {
"name" : "Notifications",
"include" : "(^src/applications/notification/)"
},
"oauthserver" : {
"name" : "OAuth Server",
"include" : "(^src/applications/oauthserver/)"
},
"owners" : {
"name" : "Owners",
"include" : "(^src/applications/owners/)"
},
"paste" : {
"name" : "Paste",
"include" : "(^src/applications/paste/)"
},
"people" : {
"name" : "People",
"include" : "(^src/applications/people/)"
},
"phame" : {
"name" : "Phame",
"include" : "(^src/applications/phame/)"
},
"phid" : {
"name" : "PHIDs",
"include" : "(^src/applications/phid/)"
},
"phlux" : {
"name" : "Phlux",
"include" : "(^src/applications/phlux/)"
},
"pholio" : {
"name" : "Pholio",
"include" : "(^src/applications/pholio/)"
},
"phortune" : {
"name" : "Phortune",
"include" : "(^src/applications/phortune/)"
},
"phpast" : {
"name" : "PHPAST",
"include" : "(^src/applications/phpast/)"
},
"phrequent" : {
"name" : "Phrequent",
"include" : "(^src/applications/phrequent/)"
},
"phriction" : {
"name" : "Phriction",
"include" : "(^src/applications/phriction/)"
},
"policy" : {
"name" : "Policy",
"include" : "(^src/applications/policy/)"
},
"ponder" : {
"name" : "Ponder",
"include" : "(^src/applications/ponder/)"
},
"project" : {
"name" : "Projects",
"include" : "(^src/applications/project/)"
},
"releeph" : {
"name" : "Releeph",
"include" : "(^src/applications/releeph/)"
},
"remarkup" : {
"name" : "Remarkup",
"include" : "(^src/applications/remarkup/)"
},
"repository" : {
"name" : "Repositories",
"include" : "(^src/applications/repository/)"
},
"search" : {
"name" : "Search",
"include" : "(^src/applications/search/)"
},
"settings" : {
"name" : "Settings",
"include" : "(^src/applications/settings/)"
},
"slowvote" : {
"name" : "Slowvote",
"include" : "(^src/applications/slowvote/)"
},
"subscriptions" : {
"name" : "Subscriptions",
"include" : "(^src/applications/subscriptions/)"
},
"system" : {
"name" : "System",
"include" : "(^src/applications/system/)"
},
"tokens" : {
"name" : "Tokens",
"include" : "(^src/applications/tokens/)"
},
"transactions" : {
"name" : "Transactions",
"include" : "(^src/applications/transactions/)"
},
"typeahead" : {
"name" : "Typeahead",
"include" : "(^src/applications/typeahead/)"
},
"uiexample" : {
"name" : "UI Examples",
"include" : "(^src/applications/uiexample/)"
},
"xhprof" : {
"name" : "XHProf",
"include" : "(^src/applications/xhprof/)"
}
}
}

View file

@ -359,6 +359,12 @@ final class PhabricatorMarkupEngine {
case 'default':
$engine = self::newMarkupEngine(array());
break;
case 'diviner':
$engine = self::newMarkupEngine(array());
$engine->setConfig('preserve-linebreaks', false);
// $engine->setConfig('diviner.renderer', new DivinerDefaultRenderer());
$engine->setConfig('header.generate-toc', true);
break;
default:
throw new Exception("Unknown engine ruleset: {$ruleset}!");
}

View file

@ -107,3 +107,4 @@
.diviner-document-section .phabricator-header-shell + .phabricator-remarkup {
padding-top: 0;
}

View file

@ -114,3 +114,9 @@
margin: auto;
max-width: 95%;
}
/* When tags appear in property lists, give them a little more vertical
spacing. */
.phabricator-property-list-view .phabricator-tag-view {
margin: 2px 0;
}