Skip to content

Commit

Permalink
ci: add a simple line length tool to check docs.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dhonx authored Feb 20, 2020
1 parent 6f7c103 commit 20d900a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,12 @@ jobs:
#node hi.js
- name: Test v binaries
run: ./v -silent build-vbinaries

docs-line-len-check:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: Build
run: make
- name: Check docs line length
run: ./v run cmd/tools/check-md.v doc/docs.md CHANGELOG.md
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ fns.txt
/v.c
/v.*.c
/v.c.out
/cmd/tools/check-md
/cmd/tools/performance_compare
/cmd/tools/oldv
/cmd/tools/vrepl
Expand Down
31 changes: 31 additions & 0 deletions cmd/tools/check-md.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module main

import os

const (
too_long_line_length = 100
)

fn main() {
files_paths := os.args[1..]
mut errors := 0
for file_path in files_paths {
real_path := os.realpath(file_path)
lines := os.read_lines(real_path) or {
continue
}
for i, line in lines {
if line.len > too_long_line_length {
eprintln('$real_path:${i+1}:${line.len+1}: line too long')
errors++
}
}
}
// TODO: uncomment this AFTER doc/docs.md line lengths are fixed
/*
if errors > 0 {
exit(1)
}
*/

}

0 comments on commit 20d900a

Please sign in to comment.