Mercurial > hg
comparison doc/check-seclevel.py @ 50269:05de4896508e stable 6.4rc0
branching: merge default into stable
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Thu, 02 Mar 2023 22:45:44 +0100 |
parents | 98e7be1ed6c5 |
children |
comparison
equal
deleted
inserted
replaced
50251:1ded5b48b8aa | 50269:05de4896508e |
---|---|
44 ) | 44 ) |
45 ui.warn(avail.encode('utf-8')) | 45 ui.warn(avail.encode('utf-8')) |
46 | 46 |
47 | 47 |
48 def checkseclevel(ui, doc, name, initlevel): | 48 def checkseclevel(ui, doc, name, initlevel): |
49 ui.notenoi18n('checking "%s"\n' % name) | 49 ui.notenoi18n(('checking "%s"\n' % name).encode('utf-8')) |
50 if not isinstance(doc, bytes): | 50 if not isinstance(doc, bytes): |
51 doc = doc.encode('utf-8') | 51 doc = doc.encode('utf-8') |
52 blocks, pruned = minirst.parse(doc, 0, ['verbose']) | 52 blocks, pruned = minirst.parse(doc, 0, ['verbose']) |
53 errorcnt = 0 | 53 errorcnt = 0 |
54 curlevel = initlevel | 54 curlevel = initlevel |
68 errorcnt += 1 | 68 errorcnt += 1 |
69 continue | 69 continue |
70 nextlevel = mark2level[mark] | 70 nextlevel = mark2level[mark] |
71 if curlevel < nextlevel and curlevel + 1 != nextlevel: | 71 if curlevel < nextlevel and curlevel + 1 != nextlevel: |
72 ui.warnnoi18n( | 72 ui.warnnoi18n( |
73 'gap of section level at "%s" of %s\n' % (title, name) | 73 ('gap of section level at "%s" of %s\n' % (title, name)).encode( |
74 'utf-8' | |
75 ) | |
74 ) | 76 ) |
75 showavailables(ui, initlevel) | 77 showavailables(ui, initlevel) |
76 errorcnt += 1 | 78 errorcnt += 1 |
77 continue | 79 continue |
78 ui.notenoi18n( | 80 ui.notenoi18n( |
79 'appropriate section level for "%s %s"\n' | 81 ( |
80 % (mark * (nextlevel * 2), title) | 82 'appropriate section level for "%s %s"\n' |
83 % (mark * (nextlevel * 2), title) | |
84 ).encode('utf-8') | |
81 ) | 85 ) |
82 curlevel = nextlevel | 86 curlevel = nextlevel |
83 | 87 |
84 return errorcnt | 88 return errorcnt |
85 | 89 |
88 errorcnt = 0 | 92 errorcnt = 0 |
89 for k, entry in cmdtable.items(): | 93 for k, entry in cmdtable.items(): |
90 name = k.split(b"|")[0].lstrip(b"^") | 94 name = k.split(b"|")[0].lstrip(b"^") |
91 if not entry[0].__doc__: | 95 if not entry[0].__doc__: |
92 ui.notenoi18n( | 96 ui.notenoi18n( |
93 'skip checking %s: no help document\n' % (namefmt % name) | 97 ( |
98 'skip checking %s: no help document\n' % (namefmt % name) | |
99 ).encode('utf-8') | |
94 ) | 100 ) |
95 continue | 101 continue |
96 errorcnt += checkseclevel( | 102 errorcnt += checkseclevel( |
97 ui, entry[0].__doc__, namefmt % name, initlevel | 103 ui, entry[0].__doc__, namefmt % name, initlevel |
98 ) | 104 ) |
115 list(extensions.enabled()) + list(extensions.disabled()) | 121 list(extensions.enabled()) + list(extensions.disabled()) |
116 ): | 122 ): |
117 mod = extensions.load(ui, name, None) | 123 mod = extensions.load(ui, name, None) |
118 if not mod.__doc__: | 124 if not mod.__doc__: |
119 ui.notenoi18n( | 125 ui.notenoi18n( |
120 'skip checking %s extension: no help document\n' % name | 126 ( |
127 'skip checking %s extension: no help document\n' % name | |
128 ).encode('utf-8') | |
121 ) | 129 ) |
122 continue | 130 continue |
123 errorcnt += checkseclevel( | 131 errorcnt += checkseclevel( |
124 ui, mod.__doc__, '%s extension' % name, initlevel_ext | 132 ui, mod.__doc__, '%s extension' % name, initlevel_ext |
125 ) | 133 ) |
142 else: | 150 else: |
143 with open(filename) as fp: | 151 with open(filename) as fp: |
144 doc = fp.read() | 152 doc = fp.read() |
145 | 153 |
146 ui.notenoi18n( | 154 ui.notenoi18n( |
147 'checking input from %s with initlevel %d\n' % (filename, initlevel) | 155 ( |
156 'checking input from %s with initlevel %d\n' % (filename, initlevel) | |
157 ).encode('utf-8') | |
148 ) | 158 ) |
149 return checkseclevel(ui, doc, 'input from %s' % filename, initlevel) | 159 return checkseclevel(ui, doc, 'input from %s' % filename, initlevel) |
150 | 160 |
151 | 161 |
152 def main(): | 162 def main(): |