From 27df1d3daaca1cc03ea8369b634d6ce7a308d5b2 Mon Sep 17 00:00:00 2001 From: Kim K Date: Fri, 29 Nov 2019 22:24:22 +0800 Subject: [PATCH] feat: Validate patterns when generating --- autoload/doge.vim | 10 ++++++++++ ftplugin/c.vim | 8 -------- ftplugin/coffee.vim | 8 -------- ftplugin/cpp.vim | 8 -------- ftplugin/groovy.vim | 8 -------- ftplugin/java.vim | 8 -------- ftplugin/javascript.vim | 8 -------- ftplugin/kotlin.vim | 8 -------- ftplugin/lua.vim | 8 -------- ftplugin/php.vim | 8 -------- ftplugin/python.vim | 8 -------- ftplugin/r.vim | 8 -------- ftplugin/ruby.vim | 8 -------- ftplugin/scala.vim | 8 -------- ftplugin/sh.vim | 8 -------- ftplugin/typescript.vim | 8 -------- 16 files changed, 10 insertions(+), 120 deletions(-) diff --git a/autoload/doge.vim b/autoload/doge.vim index 8f0e3243..1e3a4b3a 100644 --- a/autoload/doge.vim +++ b/autoload/doge.vim @@ -7,6 +7,16 @@ set cpoptions&vim " " arg: Either a count (0 by default) or a string (empty by default). function! doge#generate(arg) abort + " Immediately validate if the doc standard is allowed. + if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 + echoerr printf( + \ '[DoGe] "%s" is not a valid %s doc standard, available doc standard are: %s', + \ b:doge_doc_standard, + \ &filetype, + \ join(b:doge_supported_doc_standards, ', ') + \) + endif + let l:success = 0 " Store old search register. diff --git a/ftplugin/c.vim b/ftplugin/c.vim index 85e93951..9b4d1811 100644 --- a/ftplugin/c.vim +++ b/ftplugin/c.vim @@ -24,14 +24,6 @@ let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards([ \ 'kernel_doc' \ ]) let b:doge_doc_standard = doge#buffer#get_doc_standard('c') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid C doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/coffee.vim b/ftplugin/coffee.vim index a7ebc99e..d5c82d1b 100644 --- a/ftplugin/coffee.vim +++ b/ftplugin/coffee.vim @@ -12,14 +12,6 @@ let b:doge_pattern_multi_line_comment = '\m###.\{-}###' let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards(['jsdoc']) let b:doge_doc_standard = doge#buffer#get_doc_standard('coffee') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid CoffeeScript doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/cpp.vim b/ftplugin/cpp.vim index 54e5f69a..81913f6f 100644 --- a/ftplugin/cpp.vim +++ b/ftplugin/cpp.vim @@ -17,14 +17,6 @@ let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards([ \ 'doxygen_qt_no_asterisk', \ ]) let b:doge_doc_standard = doge#buffer#get_doc_standard('cpp') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid C++ doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/groovy.vim b/ftplugin/groovy.vim index 7c498b23..77bb8f5f 100644 --- a/ftplugin/groovy.vim +++ b/ftplugin/groovy.vim @@ -13,14 +13,6 @@ let b:doge_pattern_multi_line_comment = '\m\/\*.\{-}\*\/' let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards(['javadoc']) let b:doge_doc_standard = doge#buffer#get_doc_standard('groovy') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid Groovy doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/java.vim b/ftplugin/java.vim index 985596bb..8f04e738 100644 --- a/ftplugin/java.vim +++ b/ftplugin/java.vim @@ -11,14 +11,6 @@ let b:doge_pattern_multi_line_comment = '\m\/\*.\{-}\*\/' let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards(['javadoc']) let b:doge_doc_standard = doge#buffer#get_doc_standard('java') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid Java doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/javascript.vim b/ftplugin/javascript.vim index 96565c62..e7538941 100644 --- a/ftplugin/javascript.vim +++ b/ftplugin/javascript.vim @@ -11,14 +11,6 @@ let b:doge_pattern_multi_line_comment = '\m\/\*.\{-}\*\/' let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards(['jsdoc']) let b:doge_doc_standard = doge#buffer#get_doc_standard('javascript') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid JavaScript doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/kotlin.vim b/ftplugin/kotlin.vim index 190ee4b4..14f3e704 100644 --- a/ftplugin/kotlin.vim +++ b/ftplugin/kotlin.vim @@ -11,14 +11,6 @@ let b:doge_pattern_multi_line_comment = '\m\/\*.\{-}\*\/' let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards(['kdoc']) let b:doge_doc_standard = doge#buffer#get_doc_standard('kotlin') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid Kotlin doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/lua.vim b/ftplugin/lua.vim index 56ee9437..f757b0de 100644 --- a/ftplugin/lua.vim +++ b/ftplugin/lua.vim @@ -11,14 +11,6 @@ let b:doge_pattern_multi_line_comment = '\m--\+[[.\{-}]]--\+' let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards(['ldoc']) let b:doge_doc_standard = doge#buffer#get_doc_standard('lua') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid Lua doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/php.vim b/ftplugin/php.vim index 4577eeb5..4abcc82a 100644 --- a/ftplugin/php.vim +++ b/ftplugin/php.vim @@ -11,14 +11,6 @@ let b:doge_pattern_multi_line_comment = '\m\/\*.\{-}\*\/' let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards(['phpdoc']) let b:doge_doc_standard = doge#buffer#get_doc_standard('php') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid PHP doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/python.vim b/ftplugin/python.vim index 191e7ef7..ef910f26 100644 --- a/ftplugin/python.vim +++ b/ftplugin/python.vim @@ -19,14 +19,6 @@ let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards([ \ 'sphinx', \ ]) let b:doge_doc_standard = doge#buffer#get_doc_standard('python') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid Python doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/r.vim b/ftplugin/r.vim index 114f2a39..2a32a8ec 100644 --- a/ftplugin/r.vim +++ b/ftplugin/r.vim @@ -11,14 +11,6 @@ let b:doge_pattern_multi_line_comment = '\m#.\{-}$' let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards(['roxygen2']) let b:doge_doc_standard = doge#buffer#get_doc_standard('r') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid R doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim index 4f055e9b..b33dc0cc 100644 --- a/ftplugin/ruby.vim +++ b/ftplugin/ruby.vim @@ -11,14 +11,6 @@ let b:doge_pattern_multi_line_comment = '\m\(=begin.\{-}=end\|<<-DOC.\{-}DOC\)' let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards(['YARD']) let b:doge_doc_standard = doge#buffer#get_doc_standard('ruby') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid Ruby doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/scala.vim b/ftplugin/scala.vim index 24ac7c47..98b5819a 100644 --- a/ftplugin/scala.vim +++ b/ftplugin/scala.vim @@ -11,14 +11,6 @@ let b:doge_pattern_multi_line_comment = '\m\/\*.\{-}\*\/' let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards(['scaladoc']) let b:doge_doc_standard = doge#buffer#get_doc_standard('scala') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid Scala doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/sh.vim b/ftplugin/sh.vim index 074119d0..693d389f 100644 --- a/ftplugin/sh.vim +++ b/ftplugin/sh.vim @@ -11,14 +11,6 @@ let b:doge_pattern_multi_line_comment = '\m#.\{-}$' let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards(['google']) let b:doge_doc_standard = doge#buffer#get_doc_standard('sh') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid Shell doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ============================================================================== diff --git a/ftplugin/typescript.vim b/ftplugin/typescript.vim index fc0cb0c0..e6bf843f 100644 --- a/ftplugin/typescript.vim +++ b/ftplugin/typescript.vim @@ -14,14 +14,6 @@ let b:doge_pattern_multi_line_comment = '\m\/\*.\{-}\*\/' let b:doge_supported_doc_standards = doge#buffer#get_supported_doc_standards(['jsdoc']) let b:doge_doc_standard = doge#buffer#get_doc_standard('typescript') -if index(b:doge_supported_doc_standards, b:doge_doc_standard) < 0 - echoerr printf( - \ '[DoGe] %s is not a valid TypeScript doc standard, available doc standard are: %s', - \ b:doge_doc_standard, - \ join(b:doge_supported_doc_standards, ', ') - \ ) -endif - let b:doge_patterns = doge#buffer#get_patterns() " ==============================================================================