Skip to content

Commit

Permalink
feat: remove CreateDocStandard command due to unmaintainble and unnec…
Browse files Browse the repository at this point in the history
…essary complex logic
  • Loading branch information
kkoomen committed Aug 19, 2022
1 parent ff85d35 commit 8c402d6
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 283 deletions.
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ on a function, press `<Leader>d`, jump quickly through `TODO` items using
- [`g:doge_comment_jump_modes`](#gdoge_comment_jump_modes)
- [Commands](#commands)
- [`:DogeGenerate {doc_standard}`](#dogegenerate-doc_standard)
- [`:DogeCreateDocStandard {doc_standard}`](#dogecreatedocstandard-doc_standard)
- [Language-specific configuration](#language-specific-configuration)
- [JavaScript](#javascript)
- [PHP](#php)
Expand Down Expand Up @@ -275,16 +274,6 @@ The numeric value should point to an index key from the
The string value should point to a doc standard name listed in the
`b:doge_supported_doc_standards` variable.

### `:DogeCreateDocStandard {doc_standard}`

Command to generate a custom doc standard template. The `{doc_standard}` is a
mandatory argument which is the name of the new doc standard. If it exists, the
existing doc standard with the same name will be used as base for the custom
template. It can complete the available doc standards for the current buffer.

For more information on how to create custom doc standards you can read
[Writing your first pattern](./CONTRIBUTING.md#writing-your-first-pattern).

# Language-specific configuration

Below is a list of language-specific configuration and their default values.
Expand Down
49 changes: 1 addition & 48 deletions autoload/doge.vim
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ endfunction

""
" @public
" This function will be triggered on the FileType autocmd and will:
" - apply aliases
" - remove conflicting doc standards from the previous filetype.
" This function will be triggered on the FileType autocmd and will apply aliases
function! doge#on_filetype_change() abort
" Check if the current filetype is an alias, if so, initialize that filetype.
if get(g:, 'doge_ignore_on_filetype_change', 0) == v:true
Expand All @@ -133,51 +131,6 @@ function! doge#on_filetype_change() abort
endif
endfor
endif

" Remove conflicting doc standards from the previous filetype.
if !exists('b:doge_prev_supported_doc_standards')
\ && exists('b:doge_supported_doc_standards')
" Save the current supported doc standards
let b:doge_prev_supported_doc_standards = copy(get(b:, 'doge_supported_doc_standards', []))
let b:doge_prev_ft = &filetype
elseif exists('b:doge_prev_supported_doc_standards')
\ && exists('b:doge_supported_doc_standards')
\ && get(b:, 'doge_prev_ft', '') != &filetype
" Remove all the doc standards from the previous filetype.
" If the current filetype is not an alias of the previous filetype then we
" will remove the doc standard.
for l:doc in get(b:, 'doge_prev_supported_doc_standards', [])
let l:is_alias = 0

if (has_key(g:doge_filetype_aliases, &filetype) && index(get(g:doge_filetype_aliases, &filetype, []), b:doge_prev_ft) >= 0)
\ || (has_key(g:doge_filetype_aliases, b:doge_prev_ft) && index(get(g:doge_filetype_aliases, b:doge_prev_ft, []), &filetype) >= 0)
let l:is_alias = 1
endif

if l:is_alias == v:false
for [l:ft, l:aliases] in items(get(g:, 'doge_filetype_aliases'))
if index(l:aliases, &filetype) >= 0 && index(l:aliases, b:doge_prev_ft) >= 0
let l:is_alias = 1
break
endif
endfor
endif

if l:is_alias == v:false
let l:doc_idx = index(b:doge_supported_doc_standards, l:doc)
if l:doc_idx >= 0 && b:doge_prev_supported_doc_standards != b:doge_supported_doc_standards
call remove(b:doge_supported_doc_standards, l:doc_idx)
if has_key(get(b:, 'doge_patterns', {}), l:doc)
unlet b:doge_patterns[l:doc]
endif
endif
endif

let b:doge_doc_standard = get(g:, 'doge_doc_standard_' . &filetype, b:doge_supported_doc_standards[0])
endfor
let b:doge_prev_supported_doc_standards = copy(b:doge_supported_doc_standards)
let b:doge_prev_ft = &filetype
endif
endfunction

"" @public
Expand Down
12 changes: 1 addition & 11 deletions autoload/doge/buffer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,7 @@ endfunction
" 'defaults': A list of supported doc standards that should be allowed.
" Returns a list of accepted doc standards.
function! doge#buffer#get_supported_doc_standards(defaults) abort
" We sort them so that we can use uniq() on it.
let l:docs = uniq(sort(extend(copy(get(b:, 'doge_supported_doc_standards', [])), a:defaults)))

" After sorted it, we will remove the defaults and prepend the defaults so
" that we can reset the order as we defined it in the ftplugin/{ft}.vim.
for l:default in a:defaults
call remove(l:docs, index(l:docs, l:default))
endfor

" Prepend the defaults to the filtered docs list.
return extend(a:defaults, l:docs)
return a:defaults
endfunction

""
Expand Down
13 changes: 2 additions & 11 deletions doc/doge.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ COMMANDS *doge-commands*
The string value should point to a doc standard name listed in the
`b:doge_supported_doc_standards` variable.

:DogeCreateDocStandard {doc_standard} *:DogeCreateDocStandard*
Command to generate a custom doc standard template. The `{doc_standard}` is
a mandatory argument which is the name of the new doc standard. If it
exists, the existing doc standard with the same name will be used as base
for the custom template.

It can complete the available doc standards for the current buffer.

==============================================================================
FUNCTIONS *doge-functions*

Expand All @@ -111,9 +103,8 @@ doge#command_complete() *doge#command_complete()*
Return a list of supported doc standards for the current buffer.

doge#on_filetype_change() *doge#on_filetype_change()*
This function will be triggered on the FileType autocmd and will:
apply aliases
remove conflicting doc standards from the previous filetype.
This function will be triggered on the FileType autocmd and will apply
aliases

doge#install() *doge#install()*
Install the necessary dependencies.
Expand Down
1 change: 0 additions & 1 deletion doc/tags
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
:DogeCreateDocStandard doge.txt /*:DogeCreateDocStandard*
:DogeGenerate doge.txt /*:DogeGenerate*
doge doge.txt /*doge*
doge#activate() doge.txt /*doge#activate()*
Expand Down
10 changes: 0 additions & 10 deletions plugin/doge.vim
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,6 @@ endif
" `b:doge_supported_doc_standards` variable.
command -count -nargs=? -complete=customlist,doge#command_complete DogeGenerate call doge#generate(<count> ? <count> : <q-args>)

""
" @command DogeCreateDocStandard {doc_standard}
" Command to generate a custom doc standard template. The `{doc_standard}` is a
" mandatory argument which is the name of the new doc standard. If it exists,
" the existing doc standard with the same name will be used as base for the
" custom template.
"
" It can complete the available doc standards for the current buffer.
command -nargs=1 -complete=customlist,doge#command_complete DogeCreateDocStandard call doge#pattern#custom(<q-args>)

augroup doge
autocmd!
autocmd TextChangedI * call doge#comment#update_interactive_comment_info()
Expand Down
26 changes: 0 additions & 26 deletions test/autocmd-filetype.vader

This file was deleted.

165 changes: 0 additions & 165 deletions test/commands/create-doc-standard.vader

This file was deleted.

0 comments on commit 8c402d6

Please sign in to comment.