def help(web, req, tmpl): """ /help[/{topic}] --------------- Render help documentation. This web command is roughly equivalent to :hg:`help`. If a ``topic`` is defined, that help topic will be rendered. If not, an index of available help topics will be rendered. The ``help`` template will be rendered when requesting help for a topic. ``helptopics`` will be rendered for the index of help topics. """ from mercurial import commands # avoid cycle from mercurial import help as helpmod # avoid cycle topicname = req.form.get('node', [None])[0] if not topicname: def topics(**map): for entries, summary, _doc in helpmod.helptable: yield {'topic': entries[0], 'summary': summary} early, other = [], [] primary = lambda s: s.split('|')[0] for c, e in commands.table.iteritems(): doc = _getdoc(e) if 'DEPRECATED' in doc or c.startswith('debug'): continue cmd = primary(c) if cmd.startswith('^'): early.append((cmd[1:], doc)) else: other.append((cmd, doc)) early.sort() other.sort() def earlycommands(**map): for c, doc in early: yield {'topic': c, 'summary': doc} def othercommands(**map): for c, doc in other: yield {'topic': c, 'summary': doc} return tmpl('helptopics', topics=topics, earlycommands=earlycommands, othercommands=othercommands, title='Index') u = webutil.wsgiui() u.verbose = True try: doc = helpmod.help_(u, topicname) except error.UnknownCommand: raise ErrorResponse(HTTP_NOT_FOUND) return tmpl('help', topic=topicname, doc=doc)
def help(web, req, tmpl): from my_mercurial import commands # avoid cycle topicname = req.form.get('node', [None])[0] if not topicname: topic = [] def topics(**map): for entries, summary, _ in helpmod.helptable: entries = sorted(entries, key=len) yield {'topic': entries[-1], 'summary': summary} early, other = [], [] primary = lambda s: s.split('|')[0] for c, e in commands.table.iteritems(): doc = _getdoc(e) if 'DEPRECATED' in doc or c.startswith('debug'): continue cmd = primary(c) if cmd.startswith('^'): early.append((cmd[1:], doc)) else: other.append((cmd, doc)) early.sort() other.sort() def earlycommands(**map): for c, doc in early: yield {'topic': c, 'summary': doc} def othercommands(**map): for c, doc in other: yield {'topic': c, 'summary': doc} return tmpl('helptopics', topics=topics, earlycommands=earlycommands, othercommands=othercommands, title='Index') u = webutil.wsgiui() u.pushbuffer() try: commands.help_(u, topicname) except error.UnknownCommand: raise ErrorResponse(HTTP_NOT_FOUND) doc = u.popbuffer() return tmpl('help', topic=topicname, doc=doc)
def help(web, req, tmpl): from mercurial import commands # avoid cycle topicname = req.form.get("node", [None])[0] if not topicname: def topics(**map): for entries, summary, _ in helpmod.helptable: entries = sorted(entries, key=len) yield {"topic": entries[-1], "summary": summary} early, other = [], [] primary = lambda s: s.split("|")[0] for c, e in commands.table.iteritems(): doc = _getdoc(e) if "DEPRECATED" in doc or c.startswith("debug"): continue cmd = primary(c) if cmd.startswith("^"): early.append((cmd[1:], doc)) else: other.append((cmd, doc)) early.sort() other.sort() def earlycommands(**map): for c, doc in early: yield {"topic": c, "summary": doc} def othercommands(**map): for c, doc in other: yield {"topic": c, "summary": doc} return tmpl( "helptopics", topics=topics, earlycommands=earlycommands, othercommands=othercommands, title="Index" ) u = webutil.wsgiui() u.pushbuffer() try: commands.help_(u, topicname) except error.UnknownCommand: raise ErrorResponse(HTTP_NOT_FOUND) doc = u.popbuffer() return tmpl("help", topic=topicname, doc=doc)
def help(web, req, tmpl): from mercurial import commands # avoid cycle topicname = req.form.get('node', [None])[0] if not topicname: def topics(**map): for entries, summary, _ in helpmod.helptable: yield {'topic': entries[0], 'summary': summary} early, other = [], [] primary = lambda s: s.split('|')[0] for c, e in commands.table.iteritems(): doc = _getdoc(e) if 'DEPRECATED' in doc or c.startswith('debug'): continue cmd = primary(c) if cmd.startswith('^'): early.append((cmd[1:], doc)) else: other.append((cmd, doc)) early.sort() other.sort() def earlycommands(**map): for c, doc in early: yield {'topic': c, 'summary': doc} def othercommands(**map): for c, doc in other: yield {'topic': c, 'summary': doc} return tmpl('helptopics', topics=topics, earlycommands=earlycommands, othercommands=othercommands, title='Index') u = webutil.wsgiui() u.verbose = True try: doc = helpmod.help_(u, topicname) except error.UnknownCommand: raise ErrorResponse(HTTP_NOT_FOUND) return tmpl('help', topic=topicname, doc=doc)