comparison mercurial/templater.py @ 18747:f5db3092790f

hgweb: generate HTML documentation It's generated from the raw ReST source, as returned from help.help_().
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Sat, 09 Feb 2013 21:51:21 +0000
parents ef78450c8df6
children 0615b22da148
comparison
equal deleted inserted replaced
18746:c0087d48ec3a 18747:f5db3092790f
7 7
8 from i18n import _ 8 from i18n import _
9 import sys, os, re 9 import sys, os, re
10 import util, config, templatefilters, parser, error 10 import util, config, templatefilters, parser, error
11 import types 11 import types
12 import minirst
12 13
13 # template parsing 14 # template parsing
14 15
15 elements = { 16 elements = {
16 "(": (20, ("group", 1, ")"), ("func", 1, ")")), 17 "(": (20, ("group", 1, ")"), ("func", 1, ")")),
285 286
286 # ignore args[0] (the label string) since this is supposed to be a a no-op 287 # ignore args[0] (the label string) since this is supposed to be a a no-op
287 t = stringify(args[1][0](context, mapping, args[1][1])) 288 t = stringify(args[1][0](context, mapping, args[1][1]))
288 yield runtemplate(context, mapping, compiletemplate(t, context)) 289 yield runtemplate(context, mapping, compiletemplate(t, context))
289 290
291 def rstdoc(context, mapping, args):
292 if len(args) != 2:
293 # i18n: "rstdoc" is a keyword
294 raise error.ParseError(_("rstdoc expects two arguments"))
295
296 text = stringify(args[0][0](context, mapping, args[0][1]))
297 style = stringify(args[1][0](context, mapping, args[1][1]))
298
299 return minirst.format(text, style=style)
300
290 methods = { 301 methods = {
291 "string": lambda e, c: (runstring, e[1]), 302 "string": lambda e, c: (runstring, e[1]),
292 "symbol": lambda e, c: (runsymbol, e[1]), 303 "symbol": lambda e, c: (runsymbol, e[1]),
293 "group": lambda e, c: compileexp(e[1], c), 304 "group": lambda e, c: compileexp(e[1], c),
294 # ".": buildmember, 305 # ".": buildmember,
301 "get": get, 312 "get": get,
302 "if": if_, 313 "if": if_,
303 "ifeq": ifeq, 314 "ifeq": ifeq,
304 "join": join, 315 "join": join,
305 "label": label, 316 "label": label,
317 "rstdoc": rstdoc,
306 "sub": sub, 318 "sub": sub,
307 } 319 }
308 320
309 # template engine 321 # template engine
310 322