diff options
-rw-r--r-- | README.md | 7 | ||||
-rw-r--r-- | ale_linters/mail/proselint.vim | 9 | ||||
-rw-r--r-- | ale_linters/php/phan.vim | 36 | ||||
-rw-r--r-- | autoload/ale/fix/registry.vim | 15 | ||||
-rw-r--r-- | autoload/ale/fixers/hfmt.vim | 16 | ||||
-rw-r--r-- | autoload/ale/fixers/mix_format.vim | 16 | ||||
-rw-r--r-- | autoload/ale/fixers/rustfmt.vim | 17 | ||||
-rw-r--r-- | doc/ale-elixir.txt | 17 | ||||
-rw-r--r-- | doc/ale-haskell.txt | 10 | ||||
-rw-r--r-- | doc/ale-php.txt | 15 | ||||
-rw-r--r-- | doc/ale-rust.txt | 13 | ||||
-rw-r--r-- | doc/ale.txt | 12 | ||||
-rw-r--r-- | test/elixir-test-files/testfile.ex | 0 | ||||
-rw-r--r-- | test/fixers/test_hfmt_fixer_callback.vader | 24 | ||||
-rw-r--r-- | test/fixers/test_mix_format_fixer_callback.vader | 20 | ||||
-rw-r--r-- | test/fixers/test_rustfmt_fixer_callback.vader | 38 | ||||
-rw-r--r-- | test/handler/test_php_phan_handler.vader | 24 | ||||
-rw-r--r-- | test/rust_files/testfile.rs | 0 | ||||
-rwxr-xr-x | test/script/check-supported-tools-tables | 20 | ||||
-rwxr-xr-x | test/script/check-toc | 11 |
20 files changed, 299 insertions, 21 deletions
@@ -99,7 +99,7 @@ formatting. | GraphQL | [gqlint](https://github.com/happylinks/gqlint) | | Haml | [haml-lint](https://github.com/brigade/haml-lint) | | Handlebars | [ember-template-lint](https://github.com/rwjblue/ember-template-lint) | -| Haskell | [ghc](https://www.haskell.org/ghc/), [stack-ghc](https://haskellstack.org/), [stack-build](https://haskellstack.org/) !!, [ghc-mod](https://github.com/DanielG/ghc-mod), [stack-ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools) | +| Haskell | [ghc](https://www.haskell.org/ghc/), [stack-ghc](https://haskellstack.org/), [stack-build](https://haskellstack.org/) !!, [ghc-mod](https://github.com/DanielG/ghc-mod), [stack-ghc-mod](https://github.com/DanielG/ghc-mod), [hlint](https://hackage.haskell.org/package/hlint), [hdevtools](https://hackage.haskell.org/package/hdevtools), [hfmt](https://github.com/danstiner/hfmt) | | HTML | [HTMLHint](http://htmlhint.com/), [proselint](http://proselint.com/), [tidy](http://www.html-tidy.org/) | | Idris | [idris](http://www.idris-lang.org/) | | Java | [checkstyle](http://checkstyle.sourceforge.net), [javac](http://www.oracle.com/technetwork/java/javase/downloads/index.html) | @@ -109,6 +109,7 @@ formatting. | LaTeX | [chktex](http://www.nongnu.org/chktex/), [lacheck](https://www.ctan.org/pkg/lacheck), [proselint](http://proselint.com/) | | LLVM | [llc](https://llvm.org/docs/CommandGuide/llc.html) | | Lua | [luacheck](https://github.com/mpeterv/luacheck) | +| Mail | [proselint](http://proselint.com/) | | Make | [checkmake](https://github.com/mrtazz/checkmake) | | Markdown | [mdl](https://github.com/mivok/markdownlint), [proselint](http://proselint.com/), [vale](https://github.com/ValeLint/vale), [remark-lint](https://github.com/wooorm/remark-lint) !! | | MATLAB | [mlint](https://www.mathworks.com/help/matlab/ref/mlint.html) | @@ -119,7 +120,7 @@ formatting. | Objective-C++ | [clang](http://clang.llvm.org/) | | OCaml | [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions | | Perl | [perl -c](https://perl.org/), [perl-critic](https://metacpan.org/pod/Perl::Critic) | -| PHP | [hack](http://hacklang.org/), [langserver](https://github.com/felixfbecker/php-language-server), [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer) | +| PHP | [hack](http://hacklang.org/), [langserver](https://github.com/felixfbecker/php-language-server), [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions, [php -l](https://secure.php.net/), [phpcs](https://github.com/squizlabs/PHP_CodeSniffer), [phpmd](https://phpmd.org), [phpstan](https://github.com/phpstan/phpstan), [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer) | | Pod | [proselint](http://proselint.com/)| | Pug | [pug-lint](https://github.com/pugjs/pug-lint) | | Puppet | [puppet](https://puppet.com), [puppet-lint](https://puppet-lint.com) | @@ -129,7 +130,7 @@ formatting. | reStructuredText | [proselint](http://proselint.com/) | | RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) | | Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org) | -| Rust | cargo !! (see `:help ale-integration-rust` for configuration instructions), [rls](https://github.com/rust-lang-nursery/rls), [rustc](https://www.rust-lang.org/) | +| Rust | cargo !! (see `:help ale-integration-rust` for configuration instructions), [rls](https://github.com/rust-lang-nursery/rls), [rustc](https://www.rust-lang.org/), [rustfmt](https://github.com/rust-lang-nursery/rustfmt) | | SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) | | SCSS | [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint), [prettier](https://github.com/prettier/prettier) | | Scala | [scalac](http://scala-lang.org), [scalastyle](http://www.scalastyle.org) | diff --git a/ale_linters/mail/proselint.vim b/ale_linters/mail/proselint.vim new file mode 100644 index 00000000..82c8d1f8 --- /dev/null +++ b/ale_linters/mail/proselint.vim @@ -0,0 +1,9 @@ +" Author: Daniel M. Capella https://github.com/polyzen +" Description: proselint for mail files + +call ale#linter#Define('mail', { +\ 'name': 'proselint', +\ 'executable': 'proselint', +\ 'command': 'proselint %t', +\ 'callback': 'ale#handlers#unix#HandleAsWarning', +\}) diff --git a/ale_linters/php/phan.vim b/ale_linters/php/phan.vim new file mode 100644 index 00000000..f3b3d48f --- /dev/null +++ b/ale_linters/php/phan.vim @@ -0,0 +1,36 @@ +" Author: diegoholiveira <https://github.com/diegoholiveira> +" Description: static analyzer for PHP + +" Define the minimum severity +let g:ale_php_phan_minimum_severity = get(g:, 'ale_php_phan_minimum_severity', 0) + +function! ale_linters#php#phan#GetCommand(buffer) abort + return 'phan -y ' + \ . ale#Var(a:buffer, 'php_phan_minimum_severity') + \ . ' %s' +endfunction + +function! ale_linters#php#phan#Handle(buffer, lines) abort + " Matches against lines like the following: + " + " /path/to/some-filename.php:18 ERRORTYPE message + let l:pattern = '^.*:\(\d\+\)\s\(\w\+\)\s\(.\+\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'text': l:match[3], + \ 'type': 'W', + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('php', { +\ 'name': 'phan', +\ 'executable': 'phan', +\ 'command_callback': 'ale_linters#php#phan#GetCommand', +\ 'callback': 'ale_linters#php#phan#Handle', +\}) diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index d26c71ab..bbdcc430 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -27,6 +27,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['javascript', 'typescript'], \ 'description': 'Apply eslint --fix to a file.', \ }, +\ 'mix_format': { +\ 'function': 'ale#fixers#mix_format#Fix', +\ 'suggested_filetypes': ['elixir'], +\ 'description': 'Apply mix format to a file.', +\ }, \ 'format': { \ 'function': 'ale#fixers#format#Fix', \ 'suggested_filetypes': ['elm'], @@ -107,6 +112,16 @@ let s:default_registry = { \ 'suggested_filetypes': ['typescript'], \ 'description': 'Fix typescript files with tslint --fix.', \ }, +\ 'rustfmt': { +\ 'function': 'ale#fixers#rustfmt#Fix', +\ 'suggested_filetypes': ['rust'], +\ 'description': 'Fix Rust files with Rustfmt.', +\ }, +\ 'hfmt': { +\ 'function': 'ale#fixers#hfmt#Fix', +\ 'suggested_filetypes': ['haskell'], +\ 'description': 'Fix Haskell files with hfmt.', +\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/hfmt.vim b/autoload/ale/fixers/hfmt.vim new file mode 100644 index 00000000..ea061da4 --- /dev/null +++ b/autoload/ale/fixers/hfmt.vim @@ -0,0 +1,16 @@ +" Author: zack <zack@kourouma.me> +" Description: Integration of hfmt with ALE. + +call ale#Set('haskell_hfmt_executable', 'hfmt') + +function! ale#fixers#hfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'haskell_hfmt_executable') + + return { + \ 'command': ale#Escape(l:executable) + \ . ' -w' + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction + diff --git a/autoload/ale/fixers/mix_format.vim b/autoload/ale/fixers/mix_format.vim new file mode 100644 index 00000000..04866408 --- /dev/null +++ b/autoload/ale/fixers/mix_format.vim @@ -0,0 +1,16 @@ +" Author: carakan <carakan@gmail.com> +" Description: Fixing files with elixir formatter 'mix format'. + +call ale#Set('elixir_mix_executable', 'mix') + +function! ale#fixers#mix_format#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'elixir_mix_executable') +endfunction + +function! ale#fixers#mix_format#Fix(buffer) abort + return { + \ 'command': ale#Escape(ale#fixers#mix_format#GetExecutable(a:buffer)) + \ . ' format %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/autoload/ale/fixers/rustfmt.vim b/autoload/ale/fixers/rustfmt.vim new file mode 100644 index 00000000..fb5ac61c --- /dev/null +++ b/autoload/ale/fixers/rustfmt.vim @@ -0,0 +1,17 @@ +" Author: Kelly Fox <kelly@bumfuddled.com> +" Description: Integration of rustfmt with ALE. + +call ale#Set('rust_rustfmt_executable', 'rustfmt') +call ale#Set('rust_rustfmt_options', '') + +function! ale#fixers#rustfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'rust_rustfmt_executable') + let l:options = ale#Var(a:buffer, 'rust_rustfmt_options') + + return { + \ 'command': ale#Escape(l:executable) + \ . (empty(l:options) ? '' : ' ' . l:options) + \ . ' %t', + \ 'read_temporary_file': 1, + \} +endfunction diff --git a/doc/ale-elixir.txt b/doc/ale-elixir.txt new file mode 100644 index 00000000..a5318c0f --- /dev/null +++ b/doc/ale-elixir.txt @@ -0,0 +1,17 @@ +=============================================================================== +ALE Elixir Integration *ale-elixir-options* + + +=============================================================================== +mix *ale-elixir-mix* + +g:ale_elixir_mix_options *g:ale_elixir_mix_options* + *b:ale_elixir_mix_options* + Type: |String| + Default: `'mix'` + + + This variable can be changed to specify the mix executable. + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale-haskell.txt b/doc/ale-haskell.txt index bbf99fcf..4a490efc 100644 --- a/doc/ale-haskell.txt +++ b/doc/ale-haskell.txt @@ -21,6 +21,16 @@ g:ale_haskell_hdevtools_options *g:ale_haskell_hdevtools_options* This variable can be changed to modify flags given to hdevtools. =============================================================================== +hfmt *ale-haskell-hfmt* + +g:ale_haskell_hfmt_executable *g:ale_haskell_hfmt_executable* + *b:ale_haskell_hfmt_executable* + Type: |String| + Default: `'hfmt'` + + This variable can be changed to use a different executable for hfmt. + +=============================================================================== stack-build *ale-haskell-stack-build* g:ale_haskell_stack_build_options *g:ale_haskell_stack_build_options* diff --git a/doc/ale-php.txt b/doc/ale-php.txt index bae6d7d0..8756d60e 100644 --- a/doc/ale-php.txt +++ b/doc/ale-php.txt @@ -35,6 +35,21 @@ g:ale_php_langserver_use_global *g:ale_php_langserver_use_global* =============================================================================== +phan *ale-php-phan* + +WARNING: please do not use this linter if you have an configuration file +for your project because the phan will look into your entirely project and +ale will display in the current buffer warnings that may belong to other file. + +g:ale_php_phan_minimum_severity *g:ale_php_phan_minimum_severity* + *b:ale_php_phan_minimum_severity* + Type: |Number| + Default: `0` + + This variable defines the minimum severity level + + +=============================================================================== phpcbf *ale-php-phpcbf* g:ale_php_phpcbf_executable *g:ale_php_phpcbf_executable* diff --git a/doc/ale-rust.txt b/doc/ale-rust.txt index 52dc3d61..e20aea2c 100644 --- a/doc/ale-rust.txt +++ b/doc/ale-rust.txt @@ -22,6 +22,8 @@ Integration Information over cargo. rls implements the Language Server Protocol for incremental compilation of Rust code, and can check Rust files while you type. `rls` requires Rust files to contained in Cargo projects. + 4. rustfmt -- If you have `rustfmt` installed, you can use it as a fixer to + consistently reformat your Rust code. Only cargo is enabled by default. To switch to using rustc instead of cargo, configure |g:ale_linters| appropriately: > @@ -71,4 +73,15 @@ g:ale_rust_ignore_error_codes *g:ale_rust_ignore_error_codes* =============================================================================== +rustfmt *ale-rust-rustfmt* + +g:ale_rust_rustfmt_options *g:ale_rust_rustfmt_options* + *b:ale_rust_rustfmt_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to the rustfmt fixer. + + +=============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index e32a03db..42f48b23 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -48,6 +48,8 @@ CONTENTS *ale-contents* dartanalyzer........................|ale-dart-dartanalyzer| dockerfile............................|ale-dockerfile-options| hadolint............................|ale-dockerfile-hadolint| + elixir................................|ale-elixir-options| + mix.................................|ale-elixir-mix| elm...................................|ale-elm-options| elm-format..........................|ale-elm-elm-format| elm-make............................|ale-elm-elm-make| @@ -70,6 +72,7 @@ CONTENTS *ale-contents* ember-template-lint.................|ale-handlebars-embertemplatelint| haskell...............................|ale-haskell-options| hdevtools...........................|ale-haskell-hdevtools| + hfmt................................|ale-haskell-hfmt| stack-build.........................|ale-haskell-stack-build| html..................................|ale-html-options| htmlhint............................|ale-html-htmlhint| @@ -113,6 +116,7 @@ CONTENTS *ale-contents* php...................................|ale-php-options| hack................................|ale-php-hack| langserver..........................|ale-php-langserver| + phan................................|ale-php-phan| phpcbf..............................|ale-php-phpcbf| phpcs...............................|ale-php-phpcs| phpmd...............................|ale-php-phpmd| @@ -142,6 +146,7 @@ CONTENTS *ale-contents* cargo...............................|ale-rust-cargo| rls.................................|ale-rust-rls| rustc...............................|ale-rust-rustc| + rustfmt.............................|ale-rust-rustfmt| sass..................................|ale-sass-options| stylelint...........................|ale-sass-stylelint| scala.................................|ale-scala-options| @@ -251,7 +256,7 @@ Notes: * GraphQL: `gqlint` * Haml: `haml-lint` * Handlebars: `ember-template-lint` -* Haskell: `ghc`, `stack-ghc`, `stack-build`!!, `ghc-mod`, `stack-ghc-mod`, `hlint`, `hdevtools` +* Haskell: `ghc`, `stack-ghc`, `stack-build`!!, `ghc-mod`, `stack-ghc-mod`, `hlint`, `hdevtools`, `hfmt` * HTML: `HTMLHint`, `proselint`, `tidy` * Idris: `idris` * Java: `checkstyle`, `javac` @@ -261,6 +266,7 @@ Notes: * LaTeX (tex): `chktex`, `lacheck`, `proselint` * LLVM: `llc` * Lua: `luacheck` +* Mail: `proselint` * Make: `checkmake` * Markdown: `mdl`, `proselint`, `vale`, `remark-lint` * MATLAB: `mlint` @@ -271,7 +277,7 @@ Notes: * Objective-C++: `clang` * OCaml: `merlin` (see |ale-ocaml-merlin|) * Perl: `perl -c`, `perl-critic` -* PHP: `hack`, `langserver`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf` +* PHP: `hack`, `langserver`, `phan`, `php -l`, `phpcs`, `phpmd`, `phpstan`, `phpcbf` * Pod: `proselint` * Pug: `pug-lint` * Puppet: `puppet`, `puppet-lint` @@ -281,7 +287,7 @@ Notes: * reStructuredText: `proselint` * RPM spec: `rpmlint` * Ruby: `brakeman`, `rails_best_practices`!!, `reek`, `rubocop`, `ruby` -* Rust: `cargo`!!, `rls`, `rustc` (see |ale-integration-rust|) +* Rust: `cargo`!!, `rls`, `rustc` (see |ale-integration-rust|), `rustfmt` * SASS: `sass-lint`, `stylelint` * SCSS: `sass-lint`, `scss-lint`, `stylelint`, `prettier` * Scala: `scalac`, `scalastyle` diff --git a/test/elixir-test-files/testfile.ex b/test/elixir-test-files/testfile.ex new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/elixir-test-files/testfile.ex diff --git a/test/fixers/test_hfmt_fixer_callback.vader b/test/fixers/test_hfmt_fixer_callback.vader new file mode 100644 index 00000000..69cd03f8 --- /dev/null +++ b/test/fixers/test_hfmt_fixer_callback.vader @@ -0,0 +1,24 @@ +Before: + Save g:ale_haskell_hfmt_executable + + " Use an invalid global executable, so we don't match it. + let g:ale_haskell_hfmt_executable = 'xxxinvalid' + + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The hfmt callback should return the correct default values): + call ale#test#SetFilename('../haskell_files/testfile.hs') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' -w' + \ . ' %t', + \ }, + \ ale#fixers#hfmt#Fix(bufnr('')) diff --git a/test/fixers/test_mix_format_fixer_callback.vader b/test/fixers/test_mix_format_fixer_callback.vader new file mode 100644 index 00000000..c6c97c57 --- /dev/null +++ b/test/fixers/test_mix_format_fixer_callback.vader @@ -0,0 +1,20 @@ +Before: + call ale#test#SetDirectory('/testplugin/test/fixers') + Save g:ale_elixir_mix_executable + + let g:ale_elixir_mix_executable = 'xxxinvalid' + +After: + call ale#test#RestoreDirectory() + +Execute(The mix_format callback should return the correct default values): + call ale#test#SetFilename('../elixir-test-files/testfile.ex') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' format %t', + \ }, + \ ale#fixers#mix_format#Fix(bufnr('')) + diff --git a/test/fixers/test_rustfmt_fixer_callback.vader b/test/fixers/test_rustfmt_fixer_callback.vader new file mode 100644 index 00000000..36dd58a1 --- /dev/null +++ b/test/fixers/test_rustfmt_fixer_callback.vader @@ -0,0 +1,38 @@ +Before: + Save g:ale_rust_rustfmt_executable + Save g:ale_rust_rustfmt_options + + " Use an invalid global executable, so we don't match it. + let g:ale_rust_rustfmt_executable = 'xxxinvalid' + let g:ale_rust_rustfmt_options = '' + + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The rustfmt callback should return the correct default values): + call ale#test#SetFilename('../rust_files/testfile.rs') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' %t', + \ }, + \ ale#fixers#rustfmt#Fix(bufnr('')) + +Execute(The rustfmt callback should include custom rustfmt options): + let g:ale_rust_rustfmt_options = "--skip-children" + call ale#test#SetFilename('../rust_files/testfile.rs') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' ' . g:ale_rust_rustfmt_options + \ . ' %t', + \ }, + \ ale#fixers#rustfmt#Fix(bufnr('')) diff --git a/test/handler/test_php_phan_handler.vader b/test/handler/test_php_phan_handler.vader new file mode 100644 index 00000000..68ed6d06 --- /dev/null +++ b/test/handler/test_php_phan_handler.vader @@ -0,0 +1,24 @@ +Before: + runtime ale_linters/php/phan.vim + +Execute(The php static analyzer handler should parse errors from phan): + AssertEqual + \ [ + \ { + \ 'lnum': 25, + \ 'type': 'W', + \ 'text': 'Return type of getValidator is undeclared type \Respect\Validation\Validator', + \ }, + \ { + \ 'lnum': 66, + \ 'type': 'W', + \ 'text': 'Call to method string from undeclared class \Respect\Validation\Validator', + \ }, + \ ], + \ ale_linters#php#phan#Handle(347, [ + \ "example.php:25 PhanUndeclaredTypeReturnType Return type of getValidator is undeclared type \\Respect\\Validation\\Validator", + \ "example.php:66 PhanUndeclaredClassMethod Call to method string from undeclared class \\Respect\\Validation\\Validator", + \ ]) + +After: + call ale#linter#Reset() diff --git a/test/rust_files/testfile.rs b/test/rust_files/testfile.rs new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/rust_files/testfile.rs diff --git a/test/script/check-supported-tools-tables b/test/script/check-supported-tools-tables index 1d0fec53..32cebb2d 100755 --- a/test/script/check-supported-tools-tables +++ b/test/script/check-supported-tools-tables @@ -30,30 +30,30 @@ readme_section_size="$( \ # shellcheck disable=SC2003 readme_end_line="$(expr "$readme_start_line" + "$readme_section_size")" -doc_file="$(mktemp)" -readme_file="$(mktemp)" +doc_file="$(mktemp -t doc.XXXXXXXX)" +readme_file="$(mktemp -t readme.XXXXXXXX)" sed -n "$ale_help_start_line,$ale_help_end_line"p doc/ale.txt \ | grep '\* .*: ' \ | sed 's/^*//' \ - | sed 's/[`!^]\|([^)]*)//g' \ + | sed 's/[`!^]//g;s/([^)]*)//g' \ | sed 's/ *\([,:]\)/\1/g' \ | sed 's/ */ /g' \ - | sed 's/^ *\| *$//g' \ + | sed 's/^ *//;s/ *$//' \ | sed 's/^/ /' \ > "$doc_file" sed -n "$readme_start_line,$readme_end_line"p README.md \ | grep '| .* |' \ - | sed '/^| Language\|^| ---/d' \ + | sed '/^| Language/d;/^| ---/d' \ | sed 's/^|//' \ - | sed 's/ \?|/:/' \ - | sed 's/[`!^|]\|([^)]*)//g' \ - | sed 's/\[\|\]//g' \ - | sed 's/see[^,]*\(,\|$\)/\1/g' \ + | sed 's/ \{0,1\}|/:/' \ + | sed 's/[`!^|]//g;s/([^)]*)//g' \ + | sed 's/\[//g;s/\]//g' \ + | sed 's/see[^,]*//g' \ | sed 's/ *\([,:]\)/\1/g' \ | sed 's/ */ /g' \ - | sed 's/^ *\| *$//g' \ + | sed 's/^ *//;s/ *$//' \ | sed 's/^/ /' \ | sed 's/ *-n flag//g' \ > "$readme_file" diff --git a/test/script/check-toc b/test/script/check-toc index c4512b08..426d5a1d 100755 --- a/test/script/check-toc +++ b/test/script/check-toc @@ -23,18 +23,19 @@ tagged_toc_file="$(mktemp -t ale.txt.XXXXXXXX)" sorted_toc_file="$(mktemp -t sorted-ale.txt.XXXXXXXX)" sed -n "$toc_start_line,$toc_end_line"p doc/ale.txt \ - | sed 's/^ \( *[^.]\+\)\.\+|\(.\+\)|/\1, \2/' \ + | sed 's/^ \( *[^.][^.]*\)\.\.*|\(..*\)|/\1, \2/' \ > "$toc_file" # Get all of the doc files in a natural sorted order. -doc_files="$(/bin/ls -1v doc | grep ^ale- | sed 's/^/doc\//' | paste -sd ' ')" +doc_files="$(/bin/ls -1v doc | grep ^ale- | sed 's/^/doc\//' | paste -sd ' ' -)" # shellcheck disable=SC2086 grep -h 'ale-.*-options\|^[a-z].*\*ale-.*\*$' $doc_files \ | sed 's/^/ /' \ | sed 's/ALE Shell Integration/ALE sh Integration/' \ - | sed 's/ ALE \(.*\) Integration/\L\1/' \ - | sed 's/ *\*\(.\+\)\*$/, \1/' \ + | sed 's/ ALE \(.*\) Integration/\1/' \ + | sed 's/ *\*\(..*\)\*$/, \1/' \ + | tr '[:upper:]' '[:lower:]' \ | sed 's/objective-c/objc/' \ | sed 's/c++/cpp/' \ > "$heading_file" @@ -62,7 +63,7 @@ while read -r; do done < "$toc_file" # Sort the sections and sub-sections and remove the tags. -sort -h "$tagged_toc_file" | sed 's/[0-9]\+ //' > "$sorted_toc_file" +sort -sn "$tagged_toc_file" | sed 's/[0-9][0-9]* //' > "$sorted_toc_file" echo 'Check for bad ToC sorting:' echo |