From 740757fd9b7ad48d1f4b0dd2af209c842b7b8899 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Tue, 11 Mar 2014 15:52:16 -0700 Subject: [PATCH] Diffusion - add ToC for readme files Summary: see title. Fixes T4549. Test Plan: made a readme that had some headers and observed a nice ToC Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: aran, epriestley, Korvin Maniphest Tasks: T4549 Differential Revision: https://secure.phabricator.com/D8490 --- .../ConduitAPI_diffusion_readmequery_Method.php | 15 +++++++++++++-- .../markup/PhabricatorMarkupEngine.php | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/applications/diffusion/conduit/ConduitAPI_diffusion_readmequery_Method.php b/src/applications/diffusion/conduit/ConduitAPI_diffusion_readmequery_Method.php index 57967ddc7d..23f18b544d 100644 --- a/src/applications/diffusion/conduit/ConduitAPI_diffusion_readmequery_Method.php +++ b/src/applications/diffusion/conduit/ConduitAPI_diffusion_readmequery_Method.php @@ -8,8 +8,8 @@ final class ConduitAPI_diffusion_readmequery_Method public function getMethodDescription() { return - 'Retrieve any "readme" that can be found for a set of paths in '. - 'repository.'; + pht('Retrieve any "readme" that can be found for a set of paths in '. + 'repository.'); } public function defineReturnType() { @@ -89,6 +89,17 @@ final class ConduitAPI_diffusion_readmequery_Method $engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine(); $engine->setConfig('viewer', $request->getUser()); $readme_content = $engine->markupText($readme_content); + $toc = PhutilRemarkupEngineRemarkupHeaderBlockRule::renderTableOfContents( + $engine); + if ($toc) { + $toc = phutil_tag_div('phabricator-remarkup-toc', array( + phutil_tag_div( + 'phabricator-remarkup-toc-header', + pht('Table of Contents')), + $toc, + )); + $readme_content = array($toc, $readme_content); + } $class = 'phabricator-remarkup'; } diff --git a/src/infrastructure/markup/PhabricatorMarkupEngine.php b/src/infrastructure/markup/PhabricatorMarkupEngine.php index bb1ef76d09..20a211177d 100644 --- a/src/infrastructure/markup/PhabricatorMarkupEngine.php +++ b/src/infrastructure/markup/PhabricatorMarkupEngine.php @@ -352,6 +352,7 @@ final class PhabricatorMarkupEngine { */ public static function newDiffusionMarkupEngine(array $options = array()) { return self::newMarkupEngine(array( + 'header.generate-toc' => true, )); }