summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrebortg <github@ghlr.de>2020-12-11 11:49:47 +0100
committerrebortg <github@ghlr.de>2020-12-11 11:49:47 +0100
commit23fa394cb212ecf4f26e0816ccf390f989b84970 (patch)
tree2d899f63421ceca32a455855f5be7f51c4fce5b4
parent365be1770647cfb7fe35356730ab2a6289a14f4f (diff)
downloadvyos-documentation-23fa394cb212ecf4f26e0816ccf390f989b84970.tar.gz
vyos-documentation-23fa394cb212ecf4f26e0816ccf390f989b84970.zip
linter add start/stop function with rst comments
-rw-r--r--.github/vyos-linter.py78
-rw-r--r--docs/documentation.rst11
2 files changed, 56 insertions, 33 deletions
diff --git a/.github/vyos-linter.py b/.github/vyos-linter.py
index ebf00b2d..4a8108b8 100644
--- a/.github/vyos-linter.py
+++ b/.github/vyos-linter.py
@@ -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
-
- 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)
+ # 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)
+
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()
diff --git a/docs/documentation.rst b/docs/documentation.rst
index f1dc8095..3a2bfdcb 100644
--- a/docs/documentation.rst
+++ b/docs/documentation.rst
@@ -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
^^^^^^^^^^^^^^^^^^^^^^^^