##// END OF EJS Templates
doc: describe full help document hierarchy to create a valid link in HTML...
doc: describe full help document hierarchy to create a valid link in HTML For example, ":hg:`help config.default-push`" creates an invalid link to "hgrc.5.html#default-push" in HTML, but ":hg:`help config.paths.default-push`" creates a valid link to "hgrc.5.html#paths".

File last commit:

r28049:c00f67c1 default
r28077:27ae22a4 default
Show More
docchecker
54 lines | 1.4 KiB | text/plain | TextLexer
timeless
docchecker: introduce a way to check for poor markup...
r27730 #!/usr/bin/env python
#
# docchecker - look for problematic markup
#
# Copyright 2016 timeless <timeless@mozdev.org> and others
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
import sys
import re
leadingline = re.compile(r'(^\s*)(\S.*)$')
hg_backtick = re.compile(r""":hg:`[^`]*'[^`]*`""")
timeless
docchecker: scan for missing space before :hg:
r27733 hg_cramped = re.compile(r'\w:hg:`')
timeless
docchecker: introduce a way to check for poor markup...
r27730
def check(line):
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 if hg_backtick.search(line):
print(line)
print("""warning: please avoid nesting ' in :hg:`...`""")
if hg_cramped.search(line):
print(line)
print('warning: please have a space before :hg:')
timeless
docchecker: introduce a way to check for poor markup...
r27730
def work(file):
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 (llead, lline) = ('', '')
timeless
docchecker: introduce a way to check for poor markup...
r27730
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 for line in file:
# this section unwraps lines
match = leadingline.match(line)
if not match:
check(lline)
(llead, lline) = ('', '')
continue
timeless
docchecker: introduce a way to check for poor markup...
r27730
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 lead, line = match.group(1), match.group(2)
if (lead == llead):
if (lline != ''):
lline += ' ' + line
else:
lline = line
else:
check(lline)
(llead, lline) = (lead, line)
check(lline)
timeless
docchecker: introduce a way to check for poor markup...
r27730
def main():
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 for f in sys.argv[1:]:
try:
with open(f) as file:
work(file)
except BaseException as e:
print("failed to process %s: %s" % (f, e))
timeless
docchecker: introduce a way to check for poor markup...
r27730
main()