1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 18:22:41 +01:00

Muck around with Diviner method documentation display

Summary:
Ref T988. Not sure about this, feel free to push back or tweak it or whatever, but I want to reduce the amount of meta-text in the method documentation. Primarily this:

  - Shortens "From parent implementation in ClassName:" to "ClassName".
  - Tries to tweak the styles a bit so that it's relatively obvious what that means (hopefully?).
  - Fixes an issue with tasks where some methods could be ignored.

Test Plan: {F57565}

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T988

Differential Revision: https://secure.phabricator.com/D6911
This commit is contained in:
epriestley 2013-09-08 09:15:22 -07:00
parent 0c95c6c4b8
commit f1dc56a687
5 changed files with 78 additions and 41 deletions

View file

@ -1149,7 +1149,7 @@ celerity_register_resource_map(array(
), ),
'diviner-shared-css' => 'diviner-shared-css' =>
array( array(
'uri' => '/res/686727d1/rsrc/css/diviner/diviner-shared.css', 'uri' => '/res/4237d999/rsrc/css/diviner/diviner-shared.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(

View file

@ -134,17 +134,21 @@ final class DivinerAtomController extends DivinerController {
if ($tasks) { if ($tasks) {
$methods_by_task = igroup($methods, 'task'); $methods_by_task = igroup($methods, 'task');
// Add phantom tasks for methods which have a "@task" name that isn't
// documented anywhere, or methods that have no "@task" name.
foreach ($methods_by_task as $task => $ignored) {
if (empty($tasks[$task])) {
$tasks[$task] = array(
'name' => $task,
'title' => $task ? $task : pht('Other Methods'),
'defined' => $symbol,
);
}
}
$section = id(new DivinerSectionView()) $section = id(new DivinerSectionView())
->setHeader(pht('Tasks')); ->setHeader(pht('Tasks'));
if (isset($methods_by_task[''])) {
$tasks[''] = array(
'name' => '',
'title' => pht('Other Methods'),
'defined' => $symbol,
);
}
foreach ($tasks as $spec) { foreach ($tasks as $spec) {
$section->addContent( $section->addContent(
id(new PhabricatorHeaderView()) id(new PhabricatorHeaderView())
@ -169,7 +173,7 @@ final class DivinerAtomController extends DivinerController {
$item = array( $item = array(
$item, $item,
" \xE2\x80\x94 ", " \xE2\x80\x94 ",
phutil_safe_html($atom->getSummary())); $atom->getSummary());
} }
$list_items[] = phutil_tag('li', array(), $item); $list_items[] = phutil_tag('li', array(), $item);
@ -429,7 +433,15 @@ final class DivinerAtomController extends DivinerController {
} }
} }
return $task_specs + $extends_task_specs; $specs = $task_specs + $extends_task_specs;
// Reorder "@tasks" in original declaration order. Basically, we want to
// use the documentation of the closest subclass, but put tasks which
// were declared by parents first.
$keys = array_keys($extends_task_specs);
$specs = array_select_keys($specs, $keys) + $specs;
return $specs;
} }
private function renderFullSignature( private function renderFullSignature(
@ -616,21 +628,29 @@ final class DivinerAtomController extends DivinerController {
if (!strlen(trim($symbol->getMarkupText($field)))) { if (!strlen(trim($symbol->getMarkupText($field)))) {
continue; continue;
} }
$out[] = id(new PHUIBoxView())
->addPadding(PHUI::PADDING_LARGE_LEFT)
->addPadding(PHUI::PADDING_LARGE_RIGHT)
->addClass('diviner-method-implementation-header')
->appendChild(
pht('From parent implementation in %s:', $impl->getName()));
} else if ($out) {
$out[] = id(new PHUIBoxView())
->addPadding(PHUI::PADDING_LARGE_LEFT)
->addPadding(PHUI::PADDING_LARGE_RIGHT)
->addClass('diviner-method-implementation-header')
->appendChild(
pht('From this implementation:'));
} }
$out[] = $this->renderDocumentationText($symbol, $engine);
$doc = $this->renderDocumentationText($symbol, $engine);
if (($impl !== $parent) || $out) {
$where = id(new PHUIBoxView())
->addPadding(PHUI::PADDING_MEDIUM_LEFT)
->addPadding(PHUI::PADDING_MEDIUM_RIGHT)
->addClass('diviner-method-implementation-header')
->appendChild($impl->getName());
$doc = array($where, $doc);
if ($impl !== $parent) {
$doc = phutil_tag(
'div',
array(
'class' => 'diviner-method-implementation-inherited',
),
$doc);
}
}
$out[] = $doc;
} }
// If we only have inherited implementations but none have documentation, // If we only have inherited implementations but none have documentation,

View file

@ -9,12 +9,18 @@
* *
* For more information, see @{article:File Storage Technical Documentation}. * For more information, see @{article:File Storage Technical Documentation}.
* *
* @task construct Constructing an Engine
* @task meta Engine Metadata * @task meta Engine Metadata
* @task file Managing File Data * @task file Managing File Data
* @group filestorage * @group filestorage
*/ */
abstract class PhabricatorFileStorageEngine { abstract class PhabricatorFileStorageEngine {
/**
* Construct a new storage engine.
*
* @task construct
*/
final public function __construct() { final public function __construct() {
// <empty> // <empty>
} }

View file

@ -4,20 +4,17 @@
* Amazon S3 file storage engine. This engine scales well but is relatively * Amazon S3 file storage engine. This engine scales well but is relatively
* high-latency since data has to be pulled off S3. * high-latency since data has to be pulled off S3.
* *
* @task impl Implementation * @task internal Internals
* @task internal Internals
* @group filestorage
*/ */
final class PhabricatorS3FileStorageEngine final class PhabricatorS3FileStorageEngine
extends PhabricatorFileStorageEngine { extends PhabricatorFileStorageEngine {
/* -( Implementation )----------------------------------------------------- */ /* -( Implementation )----------------------------------------------------- */
/** /**
* This engine identifies as "amazon-s3". * This engine identifies as `amazon-s3`.
*
* @task impl
*/ */
public function getEngineIdentifier() { public function getEngineIdentifier() {
return 'amazon-s3'; return 'amazon-s3';
@ -25,8 +22,7 @@ final class PhabricatorS3FileStorageEngine
/** /**
* Write file data into S3. * Writes file data into Amazon S3.
* @task impl
*/ */
public function writeFile($data, array $params) { public function writeFile($data, array $params) {
$s3 = $this->newS3API(); $s3 = $this->newS3API();
@ -55,8 +51,7 @@ final class PhabricatorS3FileStorageEngine
/** /**
* Load a stored blob from S3. * Load a stored blob from Amazon S3.
* @task impl
*/ */
public function readFile($handle) { public function readFile($handle) {
$result = $this->newS3API()->getObject( $result = $this->newS3API()->getObject(
@ -74,8 +69,7 @@ final class PhabricatorS3FileStorageEngine
/** /**
* Delete a blob from S3. * Delete a blob from Amazon S3.
* @task impl
*/ */
public function deleteFile($handle) { public function deleteFile($handle) {
AphrontWriteGuard::willWrite(); AphrontWriteGuard::willWrite();

View file

@ -71,10 +71,6 @@
margin: 16px; margin: 16px;
} }
.diviner-method-implementation-header {
color: {$lightgreytext};
}
.diviner-atom-signature { .diviner-atom-signature {
font-weight: normal; font-weight: normal;
} }
@ -90,3 +86,24 @@
.diviner-list a { .diviner-list a {
font-weight: bold; font-weight: bold;
} }
.diviner-method-implementation-header {
color: {$greytext};
margin-bottom: -8px;
}
.diviner-method-implementation-inherited {
color: {$darkgreytext};
}
.diviner-method-implementation-inherited .diviner-method-implementation-header {
color: {$lightgreytext};
}
/**
* Fix excessive padding between method headers and method documentation for
* methods with no inherited context.
*/
.diviner-document-section .phabricator-header-shell + .phabricator-remarkup {
padding-top: 0;
}