mirror of
https://github.com/PeridexisErrant/DF-Walkthrough.git
synced 2025-09-22 05:40:49 +02:00
Add travis CI, linter
This commit is contained in:
parent
bfd5b11092
commit
0ae7c11b13
2 changed files with 48 additions and 0 deletions
9
.travis.yml
Normal file
9
.travis.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
language: python
|
||||||
|
python:
|
||||||
|
- "2.7"
|
||||||
|
- "3.4"
|
||||||
|
- "3.5"
|
||||||
|
script:
|
||||||
|
- pip install sphinx
|
||||||
|
- python misc/lint.py
|
||||||
|
- make html
|
39
misc/lint.py
Normal file
39
misc/lint.py
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Check for tabs and trailing whitespace in text files in all subdirs.
|
||||||
|
|
||||||
|
Any other automatic checks should be in this file too.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
text_extensions = ('rst', 'md', 'txt', 'html', 'css', 'js')
|
||||||
|
|
||||||
|
|
||||||
|
def lint():
|
||||||
|
"""Run linters on all files, print problem files."""
|
||||||
|
print('Checking for tabs or trailing whitespace...')
|
||||||
|
failed = False
|
||||||
|
for root, _, files in os.walk('.'):
|
||||||
|
for f in files:
|
||||||
|
fname = os.path.join(root, f)
|
||||||
|
if '_build' in fname or not any(
|
||||||
|
fname.endswith(ext) for ext in text_extensions):
|
||||||
|
continue
|
||||||
|
with open(fname, encoding='utf-8') as fh:
|
||||||
|
if '\t' in fh.read():
|
||||||
|
failed = True
|
||||||
|
print('ERROR: tabs found in {}'.format(fname))
|
||||||
|
if any(line.replace('\n', '') != line.rstrip()
|
||||||
|
for line in fh.readlines()):
|
||||||
|
failed = True
|
||||||
|
print('ERROR: trailing whitespace in {}'.format(fname))
|
||||||
|
if failed:
|
||||||
|
print('Use your text editor to convert tabs to spaces '
|
||||||
|
'or trim trailing whitespace with minimal effort.')
|
||||||
|
sys.exit(failed)
|
||||||
|
print('All files are OK')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
lint()
|
Loading…
Add table
Add a link
Reference in a new issue