Mercurial > hg
comparison doc/runrst @ 43691:47ef023d0165
black: blacken scripts
These scripts weren't blackened. I found these as part of adding
script checking to test-check-format.t.
# skip-blame black
Differential Revision: https://phab.mercurial-scm.org/D7446
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 16 Nov 2019 11:53:47 -0800 |
parents | 15cccbacd5ce |
children | c102b704edb5 |
comparison
equal
deleted
inserted
replaced
43690:15cccbacd5ce | 43691:47ef023d0165 |
---|---|
13 """ | 13 """ |
14 | 14 |
15 from __future__ import absolute_import | 15 from __future__ import absolute_import |
16 | 16 |
17 import sys | 17 import sys |
18 | |
18 try: | 19 try: |
19 import docutils.core as core | 20 import docutils.core as core |
20 import docutils.nodes as nodes | 21 import docutils.nodes as nodes |
21 import docutils.utils as utils | 22 import docutils.utils as utils |
22 import docutils.parsers.rst.roles as roles | 23 import docutils.parsers.rst.roles as roles |
23 except ImportError: | 24 except ImportError: |
24 sys.stderr.write("abort: couldn't generate documentation: docutils " | 25 sys.stderr.write( |
25 "module is missing\n") | 26 "abort: couldn't generate documentation: docutils " |
26 sys.stderr.write("please install python-docutils or see " | 27 "module is missing\n" |
27 "http://docutils.sourceforge.net/\n") | 28 ) |
29 sys.stderr.write( | |
30 "please install python-docutils or see " | |
31 "http://docutils.sourceforge.net/\n" | |
32 ) | |
28 sys.exit(-1) | 33 sys.exit(-1) |
34 | |
29 | 35 |
30 def role_hg(name, rawtext, text, lineno, inliner, options=None, content=None): | 36 def role_hg(name, rawtext, text, lineno, inliner, options=None, content=None): |
31 text = "hg " + utils.unescape(text) | 37 text = "hg " + utils.unescape(text) |
32 linktext = nodes.literal(rawtext, text) | 38 linktext = nodes.literal(rawtext, text) |
33 parts = text.split() | 39 parts = text.split() |
44 # :hg:`help -c COMMAND ...` is equivalent to :hg:`COMMAND` | 50 # :hg:`help -c COMMAND ...` is equivalent to :hg:`COMMAND` |
45 # (mainly for :hg:`help -c config`) | 51 # (mainly for :hg:`help -c config`) |
46 refuri = "hg.1.html#%s" % args[1] | 52 refuri = "hg.1.html#%s" % args[1] |
47 else: | 53 else: |
48 refuri = "hg.1.html#%s" % args[0] | 54 refuri = "hg.1.html#%s" % args[0] |
49 node = nodes.reference(rawtext, '', linktext, | 55 node = nodes.reference(rawtext, '', linktext, refuri=refuri) |
50 refuri=refuri) | |
51 return [node], [] | 56 return [node], [] |
57 | |
52 | 58 |
53 roles.register_local_role("hg", role_hg) | 59 roles.register_local_role("hg", role_hg) |
54 | 60 |
55 if __name__ == "__main__": | 61 if __name__ == "__main__": |
56 if len(sys.argv) < 2: | 62 if len(sys.argv) < 2: |