Patchwork [4,of,4] json: implement {help} template

login
register
mail settings
Submitter Gregory Szorc
Date April 2, 2015, 5:42 a.m.
Message ID <55772966391b9a46d077.1427953321@gps-mbp.local>
Download mbox | patch
Permalink /patch/8449/
State Accepted
Headers show

Comments

Gregory Szorc - April 2, 2015, 5:42 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1427952243 25200
#      Wed Apr 01 22:24:03 2015 -0700
# Node ID 55772966391b9a46d0776bd5d63f5c74f48f2ce0
# Parent  3628b37009759831113fb8905baea4c27d048e07
json: implement {help} template

We should consider add HTML rendering of the RST into the response as a
follow-up. I attempted to do this, but there was an empty array
returned by the rstdoc() template function. Not sure what's going on.
Will deal with it later.
Matt Mackall - April 2, 2015, 9:47 p.m.
On Wed, 2015-04-01 at 22:42 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1427952243 25200
> #      Wed Apr 01 22:24:03 2015 -0700
> # Node ID 55772966391b9a46d0776bd5d63f5c74f48f2ce0
> # Parent  3628b37009759831113fb8905baea4c27d048e07
> json: implement {help} template

Ok, these help ones are queued for default. I'm not really sure what the
use case is, but I bet you have one in mind.
Gregory Szorc - April 3, 2015, 3:05 a.m.
On Thu, Apr 2, 2015 at 2:47 PM, Matt Mackall <mpm@selenic.com> wrote:

> On Wed, 2015-04-01 at 22:42 -0700, Gregory Szorc wrote:
> > # HG changeset patch
> > # User Gregory Szorc <gregory.szorc@gmail.com>
> > # Date 1427952243 25200
> > #      Wed Apr 01 22:24:03 2015 -0700
> > # Node ID 55772966391b9a46d0776bd5d63f5c74f48f2ce0
> > # Parent  3628b37009759831113fb8905baea4c27d048e07
> > json: implement {help} template
>
> Ok, these help ones are queued for default. I'm not really sure what the
> use case is, but I bet you have one in mind.
>

I didn't have a use case in mind other than having full JSON coverage. I
concede these are probably the least important of all the APIs.
Matt Mackall - April 3, 2015, 3:57 p.m.
On Thu, 2015-04-02 at 20:05 -0700, Gregory Szorc wrote:
> On Thu, Apr 2, 2015 at 2:47 PM, Matt Mackall <mpm@selenic.com> wrote:
> 
> > On Wed, 2015-04-01 at 22:42 -0700, Gregory Szorc wrote:
> > > # HG changeset patch
> > > # User Gregory Szorc <gregory.szorc@gmail.com>
> > > # Date 1427952243 25200
> > > #      Wed Apr 01 22:24:03 2015 -0700
> > > # Node ID 55772966391b9a46d0776bd5d63f5c74f48f2ce0
> > > # Parent  3628b37009759831113fb8905baea4c27d048e07
> > > json: implement {help} template
> >
> > Ok, these help ones are queued for default. I'm not really sure what the
> > use case is, but I bet you have one in mind.
> >
> 
> I didn't have a use case in mind other than having full JSON coverage. I
> concede these are probably the least important of all the APIs.

Somewhere down the road, there's something that uses it to do fancy
instant help search.

Patch

diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
--- a/mercurial/templates/json/map
+++ b/mercurial/templates/json/map
@@ -91,7 +91,10 @@  helptopics = '\{
 helptopicentry = '\{
   "topic": {topic|json},
   "summary": {summary|json}
   }'
-help = '"not yet implemented"'
+help = '\{
+  "topic": {topic|json},
+  "rawdoc": {doc|json}
+  }'
 filenodelink = ''
 filenolink = ''
diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -1002,5 +1002,8 @@  help/{topic} shows an individual help to
 
   $ request json-help/phases
   200 Script output follows
   
-  "not yet implemented"
+  {
+    "rawdoc": "Working with Phases\n*", (glob)
+    "topic": "phases"
+  }