Warn on invalid title length

This commit is contained in:
Otto Winter 2019-02-27 10:23:58 +01:00
parent e16c324b1f
commit 5f55de48ec
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
4 changed files with 25 additions and 3 deletions

View File

@ -165,7 +165,7 @@ Both options USB and OTA are done by running the command:
More details on programming can be found on :doc:`/devices/sonoff_basic`
3. Prepping and installing
****************************
**************************
* Ensure power is switched off.
* You can now add your water level sensor wiring to the PCB and have it extrude, SAFELY, next to your connector block.

View File

@ -54,9 +54,14 @@ RST primer:
.. code-block:: rst
My Sub-sub section
My Sub-sub Section
******************
.. note::
The length of the bar below the text **must** match the title Text length.
Also, titles should be in Title Case
- **Links**: To create a link to an external resource (for example https://www.google.com), use
``\`Link text <link_url>\`__``. For example:

View File

@ -1,4 +1,5 @@
from pathlib import Path
import re
import sys
errors = []
@ -15,6 +16,9 @@ def find_all(a_str, sub):
column += len(sub)
section_regex = re.compile(r'^(=+|-+|\*+|~+)$')
for f in sorted(Path('.').glob('**/*.rst')):
try:
content = f.read_text('utf-8')
@ -28,6 +32,19 @@ for f in sorted(Path('.').glob('**/*.rst')):
errors.append("File {} contains windows newline on line {}:{}. "
"Please set your editor to unix newline mode.".format(f, line, col))
lines = content.splitlines(keepends=False)
for i, line in enumerate(lines):
if i == 0:
continue
if not section_regex.match(line):
continue
line_above = lines[i - 1]
if len(line_above) != len(line):
errors.append("The title length must match the bar length below it. See {}:{}"
"".format(f, i))
for error in errors:
print(error)

View File

@ -179,7 +179,7 @@ creating a POST request at ``/light/<id>/turn_on?brightness=128&transition=2`` w
- **transition**: Transition to off in this duration in seconds.
Fan
****
***
Fans are similar to switches as they can be turned on/off and toggled. In addition, if the
underlying fan supports it, fans in the web server also support the speed settings "low",