mirror of
https://github.com/vyos/vyos-documentation.git
synced 2025-10-26 08:41:46 +01:00
linter add start/stop function with rst comments
This commit is contained in:
parent
365be17706
commit
23fa394cb2
76
.github/vyos-linter.py
vendored
76
.github/vyos-linter.py
vendored
@ -74,43 +74,55 @@ def handle_file_action(filepath):
|
||||
line = fp.readline()
|
||||
cnt = 1
|
||||
test_line_lenght = True
|
||||
start_vyoslinter = True
|
||||
indentation = 0
|
||||
while line:
|
||||
# ignore every '.. code-block::' for line lenght
|
||||
# rst code-block have its own style in html the format in rst
|
||||
# and the build page must be the same
|
||||
if test_line_lenght is False:
|
||||
if len(line) > indentation:
|
||||
#print(f"'{line}'")
|
||||
#print(indentation)
|
||||
if line[indentation].isspace() is False:
|
||||
test_line_lenght = True
|
||||
# search for ignore linter comments in lines
|
||||
if ".. stop_vyoslinter" in line:
|
||||
start_vyoslinter = False
|
||||
if ".. start_vyoslinter" in line:
|
||||
start_vyoslinter = True
|
||||
if start_vyoslinter:
|
||||
# ignore every '.. code-block::' for line lenght
|
||||
# rst code-block have its own style in html the format in rst
|
||||
# and the build page must be the same
|
||||
if test_line_lenght is False:
|
||||
if len(line) > indentation:
|
||||
#print(f"'{line}'")
|
||||
#print(indentation)
|
||||
if line[indentation].isspace() is False:
|
||||
test_line_lenght = True
|
||||
|
||||
if ".. code-block::" in line:
|
||||
test_line_lenght = False
|
||||
indentation = 0
|
||||
for i in line:
|
||||
if i.isspace():
|
||||
indentation = indentation + 1
|
||||
else:
|
||||
break
|
||||
err_mac = lint_mac(cnt, line.strip())
|
||||
err_ip4 = lint_ipv4(cnt, line.strip())
|
||||
err_ip6 = lint_ipv6(cnt, line.strip())
|
||||
if test_line_lenght:
|
||||
err_len = lint_linelen(cnt, line)
|
||||
else:
|
||||
err_len = None
|
||||
if err_mac:
|
||||
errors.append(err_mac)
|
||||
if err_ip4:
|
||||
errors.append(err_ip4)
|
||||
if err_ip6:
|
||||
errors.append(err_ip6)
|
||||
if err_len:
|
||||
errors.append(err_len)
|
||||
if ".. code-block::" in line:
|
||||
test_line_lenght = False
|
||||
indentation = 0
|
||||
for i in line:
|
||||
if i.isspace():
|
||||
indentation = indentation + 1
|
||||
else:
|
||||
break
|
||||
err_mac = lint_mac(cnt, line.strip())
|
||||
err_ip4 = lint_ipv4(cnt, line.strip())
|
||||
err_ip6 = lint_ipv6(cnt, line.strip())
|
||||
if test_line_lenght:
|
||||
err_len = lint_linelen(cnt, line)
|
||||
else:
|
||||
err_len = None
|
||||
if err_mac:
|
||||
errors.append(err_mac)
|
||||
if err_ip4:
|
||||
errors.append(err_ip4)
|
||||
if err_ip6:
|
||||
errors.append(err_ip6)
|
||||
if err_len:
|
||||
errors.append(err_len)
|
||||
|
||||
line = fp.readline()
|
||||
cnt += 1
|
||||
|
||||
# ensure linter was not stop on top and forgot to tun on again
|
||||
if start_vyoslinter == False:
|
||||
errors.append((f"Don't forgett to turn linter back on", cnt, 'error'))
|
||||
finally:
|
||||
fp.close()
|
||||
|
||||
|
||||
@ -163,6 +163,17 @@ Except in ``.. code-block::`` because it will use the html tag ``<pre>``
|
||||
which have the save line format as in the rst file.
|
||||
|
||||
|
||||
Autolinter
|
||||
^^^^^^^^^^
|
||||
|
||||
Each GitHub Pull request will automatically lint against the Address space and
|
||||
line length.
|
||||
|
||||
Sometimes it is necessary to provide real IP Addresses like in the
|
||||
:ref:`examples`. For this please use the sphinx comment syntax
|
||||
``.. stop_vyoslinter`` to stop the linter and ``.. start_vyoslinter`` to start.
|
||||
|
||||
|
||||
Custom Sphinx-doc Markup
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user