summaryrefslogtreecommitdiff
path: root/doc/tools/makerst.py
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-10-03 08:41:21 +0200
committerGitHub <noreply@github.com>2019-10-03 08:41:21 +0200
commitc9781df31604b8dbf463d8ef9f56bcbadfbc8eb6 (patch)
tree62cad41591d046a0f2e92c1e15669f591e6d377c /doc/tools/makerst.py
parentff9bbf1818d62d8eb336a6a0f29357824a00b366 (diff)
parentd4a55fb6397053119fecc67006284cc81b908100 (diff)
Merge pull request #32403 from yeonghoey/enforce4space
Print errors when tab indent found in [codeblock]
Diffstat (limited to 'doc/tools/makerst.py')
-rwxr-xr-xdoc/tools/makerst.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py
index 8eddc35352..1b27e4a35a 100755
--- a/doc/tools/makerst.py
+++ b/doc/tools/makerst.py
@@ -608,8 +608,10 @@ def rstize_text(text, state): # type: (str, State) -> str
break
pre_text = text[:pos]
+ indent_level = 0
while text[pos + 1] == '\t':
pos += 1
+ indent_level += 1
post_text = text[pos + 1:]
# Handle codeblocks
@@ -633,6 +635,9 @@ def rstize_text(text, state): # type: (str, State) -> str
while code_pos + to_skip + 1 < len(code_text) and code_text[code_pos + to_skip + 1] == '\t':
to_skip += 1
+ if to_skip > indent_level:
+ print_error("Four spaces should be used for indentation within [codeblock], file: {}".format(state.current_class), state)
+
if len(code_text[code_pos + to_skip + 1:]) == 0:
code_text = code_text[:code_pos] + "\n"
code_pos += 1