├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── doc_standard.md │ ├── feature_request.md │ ├── language.md │ └── question.md ├── PULL_REQUEST_TEMPLATE.md ├── auto_assign.yml ├── dependabot.yml └── workflows │ ├── release.yml │ └── tests.yml ├── .gitignore ├── .version ├── .vintrc.yaml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── addon-info.json ├── autoload ├── doge.vim └── doge │ ├── buffer.vim │ ├── comment.vim │ ├── indent.vim │ ├── preprocessors │ ├── c.vim │ ├── cpp.vim │ ├── javascript.vim │ ├── php.vim │ └── python.vim │ └── utils.vim ├── doc ├── banner.jpg ├── c-family-doc-standard-examples.md ├── demos │ └── README.md ├── doge.txt └── tags ├── ftplugin ├── c.vim ├── cpp.vim ├── cs.vim ├── html.vim ├── java.vim ├── javascript.vim ├── lua.vim ├── php.vim ├── python.vim ├── r.vim ├── ruby.vim ├── rust.vim ├── scala.vim └── sh.vim ├── helper ├── .editorconfig ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md └── src │ ├── base_parser.rs │ ├── bash │ ├── docs │ │ └── google.yaml │ ├── mod.rs │ └── parser.rs │ ├── c │ ├── docs │ │ ├── doxygen_cpp_comment_exclamation.yaml │ │ ├── doxygen_cpp_comment_slash.yaml │ │ ├── doxygen_cpp_comment_slash_banner.yaml │ │ ├── doxygen_javadoc.yaml │ │ ├── doxygen_javadoc_banner.yaml │ │ ├── doxygen_javadoc_no_asterisk.yaml │ │ ├── doxygen_qt.yaml │ │ ├── doxygen_qt_no_asterisk.yaml │ │ └── kernel_doc.yaml │ ├── mod.rs │ └── parser.rs │ ├── config.rs │ ├── cpp │ ├── docs │ │ ├── doxygen_cpp_comment_exclamation.yaml │ │ ├── doxygen_cpp_comment_slash.yaml │ │ ├── doxygen_cpp_comment_slash_banner.yaml │ │ ├── doxygen_javadoc.yaml │ │ ├── doxygen_javadoc_banner.yaml │ │ ├── doxygen_javadoc_no_asterisk.yaml │ │ ├── doxygen_qt.yaml │ │ └── doxygen_qt_no_asterisk.yaml │ ├── mod.rs │ └── parser.rs │ ├── csharp │ ├── docs │ │ └── xmldoc.yaml │ ├── mod.rs │ └── parser.rs │ ├── docblock.rs │ ├── html │ ├── mod.rs │ └── parser.rs │ ├── java │ ├── docs │ │ └── javadoc.yaml │ ├── mod.rs │ └── parser.rs │ ├── lib.rs │ ├── lua │ ├── docs │ │ └── ldoc.yaml │ ├── mod.rs │ └── parser.rs │ ├── main.rs │ ├── php │ ├── docs │ │ └── phpdoc.yaml │ ├── mod.rs │ └── parser.rs │ ├── python │ ├── docs │ │ ├── doxygen.yaml │ │ ├── google.yaml │ │ ├── numpy.yaml │ │ ├── reST.yaml │ │ └── sphinx.yaml │ ├── mod.rs │ └── parser.rs │ ├── r │ ├── docs │ │ └── roxygen2.yaml │ ├── mod.rs │ └── parser.rs │ ├── ruby │ ├── docs │ │ └── YARD.yaml │ ├── mod.rs │ └── parser.rs │ ├── rust │ ├── docs │ │ └── rustdoc.yaml │ ├── mod.rs │ └── parser.rs │ ├── scala │ ├── docs │ │ └── scaladoc.yaml │ ├── mod.rs │ └── parser.rs │ ├── tokens.rs │ ├── traverse.rs │ └── typescript │ ├── docs │ └── jsdoc.yaml │ ├── mod.rs │ └── parser.rs ├── plugin └── doge.vim ├── scripts ├── build.ps1 ├── build.sh ├── install.ps1 ├── install.sh ├── release.sh └── run-vader-tests.sh └── test ├── commands └── generate.vader ├── filetypes ├── c │ ├── function-declarations.vader │ ├── functions-doc-cpp-exclamation.vader │ ├── functions-doc-cpp-slash-banner.vader │ ├── functions-doc-cpp-slash.vader │ ├── functions-doc-javadoc-banner.vader │ ├── functions-doc-javadoc-no-asterisk.vader │ ├── functions-doc-qt-no-asterisk.vader │ ├── functions-doc-qt.vader │ ├── functions-kernel-doc.vader │ ├── functions.vader │ └── structs.vader ├── cpp │ ├── auto-functions.vader │ ├── classes.vader │ ├── function-declarations.vader │ ├── functions-doc-cpp-exclamation.vader │ ├── functions-doc-cpp-slash-banner.vader │ ├── functions-doc-cpp-slash.vader │ ├── functions-doc-javadoc-banner.vader │ ├── functions-doc-javadoc-no-asterisk.vader │ ├── functions-doc-qt-no-asterisk.vader │ ├── functions-doc-qt.vader │ ├── functions.vader │ ├── inline-functions.vader │ ├── structs.vader │ ├── template-functions.vader │ └── virtual-functions.vader ├── cs │ ├── class-constructor.vader │ ├── class-members.vader │ ├── class-methods.vader │ ├── class.vader │ └── enum.vader ├── groovy │ └── class-methods.vader ├── html │ └── script-element.vader ├── java │ └── class-methods.vader ├── javascript │ ├── classes.vader │ ├── es6.vader │ ├── es7.vader │ ├── functions-inside-objects.vader │ ├── functions.vader │ ├── ignored-expressions.vader │ └── jsx.vader ├── lua │ ├── functions.vader │ └── object-methods.vader ├── php │ ├── class-methods.vader │ ├── class-properties.vader │ ├── functions-with-namespaces.vader │ └── functions.vader ├── python │ ├── class-methods.vader │ ├── classes-doc-doxygen.vader │ ├── classes-doc-google.vader │ ├── classes-doc-numpy.vader │ ├── classes-doc-sphinx.vader │ ├── classes.vader │ ├── functions-doc-doxygen.vader │ ├── functions-doc-google.vader │ ├── functions-doc-numpy.vader │ ├── functions-doc-sphinx.vader │ └── functions.vader ├── r │ └── functions.vader ├── ruby │ ├── classes.vader │ └── functions.vader ├── rust │ └── functions.vader ├── scala │ ├── classes.vader │ ├── functions.vader │ └── lambda_expressions.vader ├── sh │ └── functions.vader ├── svelte │ ├── hello-world.vader │ └── table-component.vader ├── typescript │ ├── class-methods.vader │ ├── class-properties.vader │ ├── generics.vader │ └── return-types.vader └── vue │ └── table-component.vader ├── options ├── doge_buffer_mappings.vader ├── doge_comment_interactive.vader ├── doge_comment_jump_wrap.vader └── doge_doxygen_settings.vader ├── undo-cursor-pos.vader └── vimrc /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = LF 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.vader] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: kkoomen 2 | custom: ["https://paypal.me/koomenk", "https://buymeacoff.ee/kkoomen"] 3 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Report unwanted behavior 4 | title: '' 5 | labels: 'bug' 6 | assignees: '' 7 | --- 8 | 9 | 26 | 27 | **Describe the bug** 28 | 29 | 34 | 35 | **Settings** 36 | 37 | 44 | 45 | **To Reproduce** 46 | 47 | Steps to reproduce the behavior: 48 | 49 | 1. ... 50 | 51 | **Expected behavior** 52 | 53 | 56 | 57 | **Screenshots** 58 | 59 | 62 | 63 | **Output of `./bin/vim-doge-helper --version`** 64 | 65 | 70 | 71 | **Output of `vim --version`** 72 | 73 | 76 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/doc_standard.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Doc standard 3 | about: Suggest a new doc standard for a specific language 4 | title: 'Add doc standard for ' 5 | labels: 'enhancement' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Documentation standard** 11 | 14 | 15 | **How popular is the doc standard?** 16 | - [ ] Not popular at all 17 | - [ ] Some people use it 18 | - [ ] Quite a lot of people use it 19 | - [ ] It's not the most popular one, but a good alternative 20 | - [ ] Everyone is using it 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea or improvement 4 | title: '' 5 | labels: 'enhancement' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | 14 | 15 | **Describe the solution you'd like** 16 | 19 | 20 | **Describe alternatives you've considered** 21 | 24 | 25 | **Additional context** 26 | 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/language.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Language 3 | about: Suggest a new language 4 | title: 'Add support for ' 5 | labels: 'enhancement' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Documentation standard** 11 | 15 | 16 | **How popular is the doc standard?** 17 | - [ ] Not popular at all 18 | - [ ] Some people use it 19 | - [ ] Quite a lot of people use it 20 | - [ ] It's not the most popular one, but a good alternative 21 | - [ ] Everyone is using it 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Are you stuck using vim-doge? Ask us anything! 4 | title: '' 5 | labels: 'question' 6 | assignees: '' 7 | 8 | --- 9 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Prelude 2 | 3 | Thank you for helping out vim-doge! 4 | 5 | 8 | 9 | By contributing to vim-doge you agree to the following statements: 10 | 11 | - [ ] I have read and understood the [Contribution Guidelines](https://github.com/kkoomen/vim-doge/blob/master/CONTRIBUTING.md). 12 | - [ ] I have read and understood the [Code of Conduct](https://github.com/kkoomen/vim-doge/blob/master/CODE_OF_CONDUCT.md). 13 | 14 | # Why this PR? 15 | 16 | [A clear and concise description of why you made this PR] 17 | -------------------------------------------------------------------------------- /.github/auto_assign.yml: -------------------------------------------------------------------------------- 1 | # Set to true to add reviewers to pull requests 2 | addReviewers: true 3 | 4 | # A list of reviewers to be added to pull requests (GitHub user name) 5 | reviewers: 6 | - kkoomen 7 | 8 | # A list of keywords to be skipped the process that add reviewers if pull requests include it 9 | skipKeywords: 10 | - wip 11 | 12 | # A number of reviewers added to the pull request 13 | # Set 0 to add all the reviewers (default: 0) 14 | numberOfReviewers: 0 15 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: cargo 4 | directory: "/helper" 5 | open-pull-requests-limit: 0 6 | schedule: 7 | interval: daily 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Project specific folders 2 | /bin 3 | 4 | ### Linux ### 5 | *~ 6 | 7 | # temporary files which can be created if a process still has a handle open of a deleted file 8 | .fuse_hidden* 9 | 10 | # KDE directory preferences 11 | .directory 12 | 13 | # Linux trash folder which might appear on any partition or disk 14 | .Trash-* 15 | 16 | # .nfs files are created when an open file is removed but is still being accessed 17 | .nfs* 18 | 19 | ### macOS ### 20 | # General 21 | .DS_Store 22 | .AppleDouble 23 | .LSOverride 24 | 25 | # Icon must end with two \r 26 | Icon 27 | 28 | # Thumbnails 29 | ._* 30 | 31 | # Files that might appear in the root of a volume 32 | .DocumentRevisions-V100 33 | .fseventsd 34 | .Spotlight-V100 35 | .TemporaryItems 36 | .Trashes 37 | .VolumeIcon.icns 38 | .com.apple.timemachine.donotpresent 39 | 40 | # Directories potentially created on remote AFP share 41 | .AppleDB 42 | .AppleDesktop 43 | Network Trash Folder 44 | Temporary Items 45 | .apdisk 46 | 47 | ### macOS Patch ### 48 | # iCloud generated files 49 | *.icloud 50 | 51 | ### Vim ### 52 | # Swap 53 | [._]*.s[a-v][a-z] 54 | !*.svg # comment out if you don't need vector files 55 | [._]*.sw[a-p] 56 | [._]s[a-rt-v][a-z] 57 | [._]ss[a-gi-z] 58 | [._]sw[a-p] 59 | 60 | # Session 61 | Session.vim 62 | Sessionx.vim 63 | 64 | # Temporary 65 | .netrwhist 66 | # Auto-generated tag files 67 | tags 68 | # Persistent undo 69 | [._]*.un~ 70 | 71 | ### Windows ### 72 | # Windows thumbnail cache files 73 | Thumbs.db 74 | Thumbs.db:encryptable 75 | ehthumbs.db 76 | ehthumbs_vista.db 77 | 78 | # Dump file 79 | *.stackdump 80 | 81 | # Folder config file 82 | [Dd]esktop.ini 83 | 84 | # Recycle Bin used on file shares 85 | $RECYCLE.BIN/ 86 | 87 | # Windows Installer files 88 | *.cab 89 | *.msi 90 | *.msix 91 | *.msm 92 | *.msp 93 | 94 | # Windows shortcuts 95 | *.lnk 96 | -------------------------------------------------------------------------------- /.version: -------------------------------------------------------------------------------- 1 | 4.7.0 2 | -------------------------------------------------------------------------------- /.vintrc.yaml: -------------------------------------------------------------------------------- 1 | cmdargs: 2 | severity: style_problem 3 | color: true 4 | policies: 5 | ProhibitImplicitScopeVariable: 6 | enabled: true 7 | ProhibitAbbreviationOption: 8 | enabled: true 9 | ProhibitAutocmdWithNoGroup: 10 | enabled: true 11 | ProhibitCommandRelyOnUser: 12 | enabled: true 13 | ProhibitCommandWithUnintendedSideEffect: 14 | enabled: true 15 | ProhibitEncodingOptionAfterScriptEncoding: 16 | enabled: true 17 | ProhibitEqualTildeOperator: 18 | enabled: true 19 | ProhibitImplicitScopeBuiltinVariable: 20 | enabled: true 21 | ProhibitMissingScriptEncoding: 22 | enabled: true 23 | ProhibitNoAbortFunction: 24 | enabled: true 25 | ProhibitSetNoCompatible: 26 | enabled: true 27 | ProhibitUnnecessaryDoubleQuote: 28 | enabled: true 29 | ProhibitUnusedVariable: 30 | enabled: true 31 | ProhibitUsingUndeclaredVariable: 32 | enabled: true 33 | ProhibitAutocmdWithNoGroup: 34 | enabled: true 35 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies within all project spaces, and it also applies when 49 | an individual is representing the project or its community in public spaces. 50 | Examples of representing a project or community include using an official 51 | project e-mail address, posting via an official social media account, or acting 52 | as an appointed representative at an online or offline event. Representation of 53 | a project may be further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at koomen@protonmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /addon-info.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "doge", 3 | "description": "(Do)cumentation (Ge)nerator", 4 | "author": "Kim 金可明" 5 | } 6 | -------------------------------------------------------------------------------- /autoload/doge/buffer.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | "" 5 | " @public 6 | " 'filetype': The filetype where we initialized the b:doge_doc_standard. 7 | " Returns the current active doc standard. 8 | function! doge#buffer#get_doc_standard(filetype) abort 9 | return get(g:, 'doge_test_env', 0) 10 | \ ? b:doge_supported_doc_standards[0] 11 | \ : get(b:, 'doge_doc_standard', get(g:, 'doge_doc_standard_' . a:filetype, b:doge_supported_doc_standards[0])) 12 | endfunction 13 | 14 | let &cpoptions = s:save_cpo 15 | unlet s:save_cpo 16 | -------------------------------------------------------------------------------- /autoload/doge/indent.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | "" 5 | " @public 6 | " Indent a string based on a given line its indent, based on the user setting. 7 | function! doge#indent#add(indent, text) abort 8 | if len(a:text) < 1 9 | return a:text 10 | elseif &expandtab 11 | return repeat(' ', indent(line('.')) + a:indent) . a:text 12 | else 13 | return repeat("\t", (indent(line('.')) + a:indent) / shiftwidth()) . a:text 14 | endif 15 | endfunction 16 | 17 | let &cpoptions = s:save_cpo 18 | unlet s:save_cpo 19 | -------------------------------------------------------------------------------- /autoload/doge/preprocessors/c.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | function! doge#preprocessors#c#alter_parser_args(parser_args) abort 5 | let l:args = deepcopy(a:parser_args) 6 | let l:settings = get(g:, 'doge_doxygen_settings', {}) 7 | 8 | if l:settings['char'] ==# '\' 9 | let l:args += ['--doxygen-use-slash-char'] 10 | endif 11 | 12 | return l:args 13 | endfunction 14 | 15 | let &cpoptions = s:save_cpo 16 | unlet s:save_cpo 17 | -------------------------------------------------------------------------------- /autoload/doge/preprocessors/cpp.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | function! doge#preprocessors#cpp#alter_parser_args(parser_args) abort 5 | let l:args = deepcopy(a:parser_args) 6 | let l:settings = get(g:, 'doge_doxygen_settings', {}) 7 | 8 | if l:settings['char'] ==# '\' 9 | let l:args += ['--doxygen-use-slash-char'] 10 | endif 11 | 12 | return l:args 13 | endfunction 14 | 15 | let &cpoptions = s:save_cpo 16 | unlet s:save_cpo 17 | -------------------------------------------------------------------------------- /autoload/doge/preprocessors/javascript.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | function! doge#preprocessors#javascript#alter_parser_args(parser_args) abort 5 | let l:args = deepcopy(a:parser_args) 6 | let l:settings = get(g:, 'doge_javascript_settings', {}) 7 | 8 | if l:settings['destructuring_props'] 9 | let l:args += ['--js-destructuring-props'] 10 | endif 11 | 12 | if l:settings['omit_redundant_param_types'] 13 | let l:args += ['--js-omit-redundant-param-types'] 14 | endif 15 | 16 | return l:args 17 | endfunction 18 | 19 | let &cpoptions = s:save_cpo 20 | unlet s:save_cpo 21 | -------------------------------------------------------------------------------- /autoload/doge/preprocessors/php.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | function! doge#preprocessors#php#alter_parser_args(parser_args) abort 5 | let l:args = deepcopy(a:parser_args) 6 | let l:settings = get(g:, 'doge_php_settings', {}) 7 | 8 | if l:settings['resolve_fqn'] 9 | let l:args += ['--php-resolve-fqn'] 10 | endif 11 | 12 | return l:args 13 | endfunction 14 | 15 | let &cpoptions = s:save_cpo 16 | unlet s:save_cpo 17 | -------------------------------------------------------------------------------- /autoload/doge/preprocessors/python.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | function! doge#preprocessors#python#alter_parser_args(parser_args) abort 5 | let l:args = deepcopy(a:parser_args) 6 | let l:settings = get(g:, 'doge_python_settings', {}) 7 | 8 | if l:settings['single_quotes'] 9 | let l:args += ['--python-single-quotes'] 10 | endif 11 | 12 | if l:settings['omit_redundant_param_types'] 13 | let l:args += ['--python-omit-redundant-param-types'] 14 | endif 15 | 16 | return l:args 17 | endfunction 18 | 19 | let &cpoptions = s:save_cpo 20 | unlet s:save_cpo 21 | -------------------------------------------------------------------------------- /doc/banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kkoomen/vim-doge/03a84072ef21b205237c77986c78914395d646c3/doc/banner.jpg -------------------------------------------------------------------------------- /doc/demos/README.md: -------------------------------------------------------------------------------- 1 | # Table of Contents 2 | - [Table of Contents](#table-of-contents) 3 | - [Demos and supported functionality](#demos-and-supported-functionality) 4 | * [PHP](#php) 5 | * [JavaScript](#javascript) 6 | * [Python](#python) 7 | 8 | # Demos and supported functionality 9 | 10 | This README contains several demos of some of the languages being supported by 11 | vim-doge and also specifies _what_ is being supported. 12 | 13 | ## PHP 14 | 15 | Supported: 16 | - Class properties (based on the constructor of the surrounding class) 17 | - Class methods 18 | - Functions 19 | 20 | [![Demo PHP](https://asciinema.org/a/PXtgawXXnDOVbAm6Kk4cS2MmC.svg)](https://asciinema.org/a/PXtgawXXnDOVbAm6Kk4cS2MmC) 21 | 22 | ## JavaScript 23 | 24 | JavaScript is by far the most complicated ones to support, because of all the 25 | EcmaScript features and libraries that add TypeScript-like type hints. 26 | Nonetheless, vim-doge supports all of it. 27 | 28 | Supported: 29 | - Regular functions 30 | - Prototype functions 31 | - Generator functions 32 | - ES6 33 | - Fat-arrow functions 34 | - Classes 35 | - Class methods 36 | - Class properties 37 | - Destructuring in parameter lists 38 | - FlowJS/TypeScript-like type hints 39 | 40 | All of the above is _also_ supported for TypeScript and NodeJS. 41 | 42 | [![Demo JavaScript](https://asciinema.org/a/KUvRSPGyFVI0dKsblEa41RG3x.svg)](https://asciinema.org/a/KUvRSPGyFVI0dKsblEa41RG3x) 43 | 44 | ## Python 45 | 46 | Supported: 47 | - Functions 48 | - Class methods 49 | - Doc standards 50 | - reST 51 | - Sphinx 52 | - Doxygen 53 | - Numpy 54 | - Google 55 | - Python 3.7+ type hints 56 | 57 | [![Demo Python](https://asciinema.org/a/QKwuUrZphWPD6eZ3mowumkA1O.svg)](https://asciinema.org/a/QKwuUrZphWPD6eZ3mowumkA1O) 58 | -------------------------------------------------------------------------------- /doc/tags: -------------------------------------------------------------------------------- 1 | :DogeGenerate doge.txt /*:DogeGenerate* 2 | doge doge.txt /*doge* 3 | doge#activate() doge.txt /*doge#activate()* 4 | doge#buffer#get_doc_standard() doge.txt /*doge#buffer#get_doc_standard()* 5 | doge#command_complete() doge.txt /*doge#command_complete()* 6 | doge#comment#deactivate_when_done() doge.txt /*doge#comment#deactivate_when_done()* 7 | doge#comment#jump() doge.txt /*doge#comment#jump()* 8 | doge#comment#update_interactive_comment_info() doge.txt /*doge#comment#update_interactive_comment_info()* 9 | doge#deactivate() doge.txt /*doge#deactivate()* 10 | doge#generate() doge.txt /*doge#generate()* 11 | doge#indent#add() doge.txt /*doge#indent#add()* 12 | doge#install() doge.txt /*doge#install()* 13 | doge#on_filetype_change() doge.txt /*doge#on_filetype_change()* 14 | doge#run_parser() doge.txt /*doge#run_parser()* 15 | doge#utils#count() doge.txt /*doge#utils#count()* 16 | doge#utils#deepextend() doge.txt /*doge#utils#deepextend()* 17 | doge#utils#get_filetype() doge.txt /*doge#utils#get_filetype()* 18 | doge#utils#keyseq() doge.txt /*doge#utils#keyseq()* 19 | doge#utils#placeholder() doge.txt /*doge#utils#placeholder()* 20 | doge#utils#trim() doge.txt /*doge#utils#trim()* 21 | doge-commands doge.txt /*doge-commands* 22 | doge-config doge.txt /*doge-config* 23 | doge-contents doge.txt /*doge-contents* 24 | doge-functions doge.txt /*doge-functions* 25 | doge-intro doge.txt /*doge-intro* 26 | doge-preprocessors doge.txt /*doge-preprocessors* 27 | doge.txt doge.txt /*doge.txt* 28 | g:doge_buffer_mappings doge.txt /*g:doge_buffer_mappings* 29 | g:doge_comment_interactive doge.txt /*g:doge_comment_interactive* 30 | g:doge_comment_jump_modes doge.txt /*g:doge_comment_jump_modes* 31 | g:doge_comment_jump_wrap doge.txt /*g:doge_comment_jump_wrap* 32 | g:doge_enable_mappings doge.txt /*g:doge_enable_mappings* 33 | g:doge_mapping doge.txt /*g:doge_mapping* 34 | g:doge_mapping_comment_jump_backward doge.txt /*g:doge_mapping_comment_jump_backward* 35 | g:doge_mapping_comment_jump_forward doge.txt /*g:doge_mapping_comment_jump_forward* 36 | -------------------------------------------------------------------------------- /ftplugin/c.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | " The C filetype also gets triggerred for C++, so we want to ignore this. 5 | if &filetype !=? 'c' 6 | finish 7 | endif 8 | 9 | let b:doge_parser = 'c' 10 | let b:doge_insert = 'above' 11 | let b:char = get(g:, 'doge_doxygen_settings')['char'] 12 | 13 | let b:doge_supported_doc_standards = [ 14 | \ 'doxygen_javadoc', 15 | \ 'doxygen_javadoc_no_asterisk', 16 | \ 'doxygen_javadoc_banner', 17 | \ 'doxygen_qt', 18 | \ 'doxygen_qt_no_asterisk', 19 | \ 'kernel_doc', 20 | \ 'doxygen_cpp_comment_slash', 21 | \ 'doxygen_cpp_comment_exclamation', 22 | \ 'doxygen_cpp_comment_slash_banner', 23 | \ ] 24 | let b:doge_doc_standard = doge#buffer#get_doc_standard('c') 25 | 26 | let &cpoptions = s:save_cpo 27 | unlet s:save_cpo 28 | -------------------------------------------------------------------------------- /ftplugin/cpp.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | let b:doge_parser = 'cpp' 5 | let b:doge_insert = 'above' 6 | 7 | let b:doge_supported_doc_standards = [ 8 | \ 'doxygen_javadoc', 9 | \ 'doxygen_javadoc_no_asterisk', 10 | \ 'doxygen_javadoc_banner', 11 | \ 'doxygen_qt', 12 | \ 'doxygen_qt_no_asterisk', 13 | \ 'doxygen_cpp_comment_slash', 14 | \ 'doxygen_cpp_comment_exclamation', 15 | \ 'doxygen_cpp_comment_slash_banner', 16 | \ ] 17 | let b:doge_doc_standard = doge#buffer#get_doc_standard('cpp') 18 | 19 | let &cpoptions = s:save_cpo 20 | unlet s:save_cpo 21 | -------------------------------------------------------------------------------- /ftplugin/cs.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | let b:doge_parser = 'csharp' 5 | let b:doge_insert = 'above' 6 | 7 | let b:doge_supported_doc_standards = ['xmldoc'] 8 | let b:doge_doc_standard = doge#buffer#get_doc_standard('cs') 9 | 10 | let &cpoptions = s:save_cpo 11 | unlet s:save_cpo 12 | -------------------------------------------------------------------------------- /ftplugin/html.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | " The HTML filetype also gets triggerred for PHP files (and perhaps others). 5 | if &filetype !=? 'html' 6 | finish 7 | endif 8 | 9 | let b:doge_parser = 'html' 10 | let b:doge_insert = 'above' 11 | 12 | let b:doge_supported_doc_standards = ['jsdoc'] 13 | let b:doge_doc_standard = doge#buffer#get_doc_standard('html') 14 | 15 | let &cpoptions = s:save_cpo 16 | unlet s:save_cpo 17 | -------------------------------------------------------------------------------- /ftplugin/java.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | let b:doge_parser = 'java' 5 | let b:doge_insert = 'above' 6 | 7 | let b:doge_supported_doc_standards = ['javadoc'] 8 | let b:doge_doc_standard = doge#buffer#get_doc_standard('java') 9 | 10 | let &cpoptions = s:save_cpo 11 | unlet s:save_cpo 12 | -------------------------------------------------------------------------------- /ftplugin/javascript.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | let b:doge_parser = 'typescript' 5 | let b:doge_insert = 'above' 6 | 7 | if !exists('g:doge_javascript_settings') 8 | let g:doge_javascript_settings = { 9 | \ 'destructuring_props': 1, 10 | \ 'omit_redundant_param_types': 0, 11 | \} 12 | endif 13 | 14 | let b:doge_supported_doc_standards = ['jsdoc'] 15 | let b:doge_doc_standard = doge#buffer#get_doc_standard('javascript') 16 | 17 | let &cpoptions = s:save_cpo 18 | unlet s:save_cpo 19 | -------------------------------------------------------------------------------- /ftplugin/lua.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | let b:doge_parser = 'lua' 5 | let b:doge_insert = 'above' 6 | 7 | let b:doge_supported_doc_standards = ['ldoc'] 8 | let b:doge_doc_standard = doge#buffer#get_doc_standard('lua') 9 | 10 | let &cpoptions = s:save_cpo 11 | unlet s:save_cpo 12 | -------------------------------------------------------------------------------- /ftplugin/php.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | if !exists('g:doge_php_settings') 5 | let g:doge_php_settings = { 6 | \ 'resolve_fqn': 1, 7 | \} 8 | endif 9 | 10 | let b:doge_parser = 'php' 11 | let b:doge_insert = 'above' 12 | 13 | let b:doge_supported_doc_standards = ['phpdoc'] 14 | let b:doge_doc_standard = doge#buffer#get_doc_standard('php') 15 | 16 | let &cpoptions = s:save_cpo 17 | unlet s:save_cpo 18 | -------------------------------------------------------------------------------- /ftplugin/python.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | if !exists('g:doge_python_settings') 5 | let g:doge_python_settings = { 6 | \ 'single_quotes': 0, 7 | \ 'omit_redundant_param_types': 1, 8 | \} 9 | endif 10 | 11 | let b:doge_parser = 'python' 12 | let b:doge_insert = 'below' 13 | 14 | let b:doge_supported_doc_standards = [ 15 | \ 'reST', 16 | \ 'numpy', 17 | \ 'google', 18 | \ 'sphinx', 19 | \ 'doxygen', 20 | \ ] 21 | let b:doge_doc_standard = doge#buffer#get_doc_standard('python') 22 | 23 | let &cpoptions = s:save_cpo 24 | unlet s:save_cpo 25 | -------------------------------------------------------------------------------- /ftplugin/r.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | let b:doge_parser = 'r' 5 | let b:doge_insert = 'above' 6 | 7 | let b:doge_supported_doc_standards = ['roxygen2'] 8 | let b:doge_doc_standard = doge#buffer#get_doc_standard('r') 9 | 10 | let &cpoptions = s:save_cpo 11 | unlet s:save_cpo 12 | -------------------------------------------------------------------------------- /ftplugin/ruby.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | let b:doge_parser = 'ruby' 5 | let b:doge_insert = 'above' 6 | 7 | let b:doge_supported_doc_standards = ['YARD'] 8 | let b:doge_doc_standard = doge#buffer#get_doc_standard('ruby') 9 | 10 | let &cpoptions = s:save_cpo 11 | unlet s:save_cpo 12 | -------------------------------------------------------------------------------- /ftplugin/rust.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | let b:doge_parser = 'rust' 5 | let b:doge_insert = 'above' 6 | 7 | let b:doge_supported_doc_standards = ['rustdoc'] 8 | let b:doge_doc_standard = doge#buffer#get_doc_standard('rs') 9 | 10 | let &cpoptions = s:save_cpo 11 | unlet s:save_cpo 12 | -------------------------------------------------------------------------------- /ftplugin/scala.vim: -------------------------------------------------------------------------------- 1 | " ============================================================================== 2 | " The Scala documentation should follow the 'ScalaDoc' conventions. 3 | " see https://docs.scala-lang.org/style/scaladoc.html 4 | " ============================================================================== 5 | 6 | let s:save_cpo = &cpoptions 7 | set cpoptions&vim 8 | 9 | let b:doge_parser = 'scala' 10 | let b:doge_insert = 'above' 11 | 12 | let b:doge_supported_doc_standards = ['scaladoc'] 13 | let b:doge_doc_standard = doge#buffer#get_doc_standard('scala') 14 | 15 | let &cpoptions = s:save_cpo 16 | unlet s:save_cpo 17 | -------------------------------------------------------------------------------- /ftplugin/sh.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpoptions 2 | set cpoptions&vim 3 | 4 | let b:doge_parser = 'bash' 5 | let b:doge_insert = 'above' 6 | 7 | let b:doge_supported_doc_standards = ['google'] 8 | let b:doge_doc_standard = doge#buffer#get_doc_standard('sh') 9 | 10 | let &cpoptions = s:save_cpo 11 | unlet s:save_cpo 12 | -------------------------------------------------------------------------------- /helper/.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 4 7 | end_of_line = LF 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.yaml] 13 | indent_size = 2 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /helper/.gitignore: -------------------------------------------------------------------------------- 1 | ### Project ### 2 | /playground 3 | 4 | ### Linux ### 5 | *~ 6 | 7 | # temporary files which can be created if a process still has a handle open of a deleted file 8 | .fuse_hidden* 9 | 10 | # KDE directory preferences 11 | .directory 12 | 13 | # Linux trash folder which might appear on any partition or disk 14 | .Trash-* 15 | 16 | # .nfs files are created when an open file is removed but is still being accessed 17 | .nfs* 18 | 19 | ### macOS ### 20 | # General 21 | .DS_Store 22 | .AppleDouble 23 | .LSOverride 24 | 25 | # Icon must end with two \r 26 | Icon 27 | 28 | # Thumbnails 29 | ._* 30 | 31 | # Files that might appear in the root of a volume 32 | .DocumentRevisions-V100 33 | .fseventsd 34 | .Spotlight-V100 35 | .TemporaryItems 36 | .Trashes 37 | .VolumeIcon.icns 38 | .com.apple.timemachine.donotpresent 39 | 40 | # Directories potentially created on remote AFP share 41 | .AppleDB 42 | .AppleDesktop 43 | Network Trash Folder 44 | Temporary Items 45 | .apdisk 46 | 47 | ### macOS Patch ### 48 | # iCloud generated files 49 | *.icloud 50 | 51 | ### Rust ### 52 | # Generated by Cargo 53 | # will have compiled files and executables 54 | debug/ 55 | target/ 56 | 57 | # These are backup files generated by rustfmt 58 | **/*.rs.bk 59 | 60 | # MSVC Windows builds of rustc generate these, which store debugging information 61 | *.pdb 62 | 63 | ### Vim ### 64 | # Swap 65 | [._]*.s[a-v][a-z] 66 | !*.svg # comment out if you don't need vector files 67 | [._]*.sw[a-p] 68 | [._]s[a-rt-v][a-z] 69 | [._]ss[a-gi-z] 70 | [._]sw[a-p] 71 | 72 | # Session 73 | Session.vim 74 | Sessionx.vim 75 | 76 | # Temporary 77 | .netrwhist 78 | # Auto-generated tag files 79 | tags 80 | # Persistent undo 81 | [._]*.un~ 82 | 83 | #!! ERROR: vscode is undefined. Use list command to see defined gitignore types !!# 84 | 85 | ### Windows ### 86 | # Windows thumbnail cache files 87 | Thumbs.db 88 | Thumbs.db:encryptable 89 | ehthumbs.db 90 | ehthumbs_vista.db 91 | 92 | # Dump file 93 | *.stackdump 94 | 95 | # Folder config file 96 | [Dd]esktop.ini 97 | 98 | # Recycle Bin used on file shares 99 | $RECYCLE.BIN/ 100 | 101 | # Windows Installer files 102 | *.cab 103 | *.msi 104 | *.msix 105 | *.msm 106 | *.msp 107 | 108 | # Windows shortcuts 109 | *.lnk 110 | -------------------------------------------------------------------------------- /helper/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "vim-doge-helper" 3 | version = "4.7.0" 4 | edition = "2021" 5 | publish = false 6 | include = ["src"] 7 | 8 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 9 | 10 | [dependencies] 11 | clap = { version = "4.3.10", features = ["derive"] } 12 | tera = { version = "1", default-features = false } 13 | regex = "1.8.4" 14 | serde = { version = "1.0.104", features = ["derive"] } 15 | serde_json = "1.0.99" 16 | serde_yaml = "0.9.22" 17 | tree-sitter = "0.20.10" 18 | tree-sitter-bash = { git = "https://github.com/tree-sitter/tree-sitter-bash", rev = "1b0321e" } 19 | tree-sitter-lua = { git = "https://github.com/Azganoth/tree-sitter-lua", rev = "e198b76" } 20 | tree-sitter-ruby = { git = "https://github.com/tree-sitter/tree-sitter-ruby", rev = "f257f3f" } 21 | tree-sitter-rust = { git = "https://github.com/tree-sitter/tree-sitter-rust", rev = "0a70e15" } 22 | tree-sitter-c-sharp = { git = "https://github.com/tree-sitter/tree-sitter-c-sharp", rev = "1648e21" } 23 | tree-sitter-java = { git = "https://github.com/tree-sitter/tree-sitter-java", rev = "c194ee5" } 24 | tree-sitter-python = { git = "https://github.com/tree-sitter/tree-sitter-python", rev = "36f9e33" } 25 | tree-sitter-c = { git = "https://github.com/tree-sitter/tree-sitter-c", rev = "84bdf40" } 26 | tree-sitter-cpp = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev = "0e7b7a0" } 27 | tree-sitter-typescript = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "3429d8c" } 28 | tree-sitter-php = { git = "https://github.com/tree-sitter/tree-sitter-php", rev = "d43130f" } 29 | tree-sitter-r = { git = "https://github.com/r-lib/tree-sitter-r", rev = "c55f8b4" } 30 | tree-sitter-scala = { git = "https://github.com/tree-sitter/tree-sitter-scala", rev = "f14629b" } 31 | tree-sitter-html = { git = "https://github.com/tree-sitter/tree-sitter-html", rev = "d742025" } 32 | -------------------------------------------------------------------------------- /helper/README.md: -------------------------------------------------------------------------------- 1 | # vim-doge-helper 2 | 3 | Helper extension for the [vim-doge](https://github.com/kkoomen/vim-doge) 4 | plugin that parses code in order to generate docblocks using 5 | [tree-sitter](https://github.com/tree-sitter/tree-sitter), written in Rust. 6 | 7 | # Table of Contents 8 | - [vim-doge-helper](#vim-doge-helper) 9 | - [Table of Contents](#table-of-contents) 10 | - [Installation](#installation) 11 | - [Usage](#usage) 12 | - [Contributing](#contributing) 13 | 14 | # Installation 15 | 16 | ``` 17 | cargo install --path . 18 | ``` 19 | 20 | # Usage 21 | 22 | Assume the following php file `code.php`: 23 | 24 | ```php 25 | Option, String>>; 6 | 7 | /// Can be used to do some additional post-parsing processing for the line 8 | /// number. One common use case is that some languages typescript and java 9 | /// can have decorators on top of the functions, so we want to insert the 10 | /// docblock above these. Using this function, we can implement aditional 11 | /// logic that find the top-most decorator and returns that line number. 12 | fn postprocess_line(&self, line: usize) -> usize { 13 | line 14 | } 15 | 16 | fn get_code_bytes(&self) -> &[u8]; 17 | 18 | fn get_node_text(&self, node: &Node) -> String { 19 | node.utf8_text(self.get_code_bytes()).unwrap().to_owned() 20 | } 21 | 22 | /// Used as a dummy return value that allows to force render the `template` 23 | /// key inside doc configs that don't have any variables in the template. 24 | fn empty_parse_result(&self) -> Option, String>> { 25 | Some(Result::Ok(Map::new())) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /helper/src/bash/docs/google.yaml: -------------------------------------------------------------------------------- 1 | # https://google.github.io/styleguide/shell.xml#Function_Comments 2 | 3 | templates: 4 | function_definition: 5 | node_types: 6 | - function_definition 7 | template: | 8 | ################################################################################ 9 | # [TODO:description] 10 | # Globals: 11 | # [TODO:variable name] 12 | # Arguments: 13 | # $1: [TODO:description for each parameter] 14 | # Outputs: 15 | # [TODO:description for each output variable] 16 | # Returns: 17 | # [TODO:description] 18 | ################################################################################ 19 | -------------------------------------------------------------------------------- /helper/src/bash/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/bash/parser.rs: -------------------------------------------------------------------------------- 1 | use tree_sitter::{Parser, Node}; 2 | use serde_json::{Map, Value}; 3 | 4 | use crate::base_parser::BaseParser; 5 | use crate::traverse; 6 | 7 | pub struct BashParser<'a> { 8 | code: &'a str, 9 | tree: tree_sitter::Tree, 10 | line: &'a usize, 11 | node_types: &'a [&'a str], 12 | } 13 | 14 | impl<'a> BaseParser for BashParser<'a> { 15 | fn parse(&self) -> Option, String>> { 16 | self.parse_node(&self.tree.root_node()) 17 | } 18 | 19 | fn get_code_bytes(&self) -> &[u8] { 20 | &self.code.as_bytes() 21 | } 22 | } 23 | 24 | impl<'a> BashParser<'a> { 25 | pub fn new(code: &'a str, line: &'a usize, node_types: &'a [&'a str]) -> Self { 26 | let mut parser = Parser::new(); 27 | parser.set_language(tree_sitter_bash::language()).unwrap(); 28 | 29 | let tree = parser.parse(code, None).unwrap(); 30 | 31 | Self { code, tree, line, node_types } 32 | } 33 | 34 | fn parse_node(&self, node: &Node) -> Option, String>> { 35 | for child_node in traverse::PreOrder::new(node.walk()) { 36 | if child_node.start_position().row + 1 == *self.line && self.node_types.contains(&child_node.kind()) { 37 | return match child_node.kind() { 38 | "function_definition" => self.empty_parse_result(), 39 | _ => None, 40 | }; 41 | } 42 | } 43 | 44 | None 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /helper/src/c/docs/doxygen_cpp_comment_exclamation.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - function_definition 7 | - declaration 8 | template: | 9 | //! 10 | //! {{ char }}brief [TODO:summary] 11 | //! 12 | {% if params %} 13 | {% for param in params %} 14 | //! {{ char }}param[[TODO:direction]] {{ param.name }} [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | {% if return_type %} 18 | //! {{ char }}return [TODO:description] 19 | {% endif %} 20 | //! 21 | 22 | struct: 23 | node_types: 24 | - struct_specifier 25 | template: | 26 | //! 27 | //! struct {{ name }} - [TODO:description] 28 | //! 29 | 30 | struct_field: 31 | node_types: 32 | - field_declaration 33 | template: | 34 | //! 35 | //! {{ char }}{{ name }} [TODO:description] 36 | //! 37 | -------------------------------------------------------------------------------- /helper/src/c/docs/doxygen_cpp_comment_slash.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - function_definition 7 | - declaration 8 | template: | 9 | /// 10 | /// {{ char }}brief [TODO:summary] 11 | /// 12 | {% if params %} 13 | {% for param in params %} 14 | /// {{ char }}param[[TODO:direction]] {{ param.name }} [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | {% if return_type %} 18 | /// {{ char }}return [TODO:description] 19 | {% endif %} 20 | /// 21 | 22 | struct: 23 | node_types: 24 | - struct_specifier 25 | template: | 26 | /// 27 | /// struct {{ name }} - [TODO:description] 28 | /// 29 | 30 | struct_field: 31 | node_types: 32 | - field_declaration 33 | template: | 34 | /// 35 | /// {{ char }}{{ name }} [TODO:description] 36 | /// 37 | -------------------------------------------------------------------------------- /helper/src/c/docs/doxygen_cpp_comment_slash_banner.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - function_definition 7 | - declaration 8 | template: | 9 | //////////////////////////////////////////////////////////////////////////////// 10 | /// {{ char }}brief [TODO:summary] 11 | /// 12 | {% if params %} 13 | {% for param in params %} 14 | /// {{ char }}param[[TODO:direction]] {{ param.name }} [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | {% if return_type %} 18 | /// {{ char }}return [TODO:description] 19 | {% endif %} 20 | //////////////////////////////////////////////////////////////////////////////// 21 | 22 | struct: 23 | node_types: 24 | - struct_specifier 25 | template: | 26 | //////////////////////////////////////////////////////////////////////////////// 27 | /// struct {{ name }} - [TODO:description] 28 | //////////////////////////////////////////////////////////////////////////////// 29 | 30 | struct_field: 31 | node_types: 32 | - field_declaration 33 | template: | 34 | //////////////////////////////////////////////////////////////////////////////// 35 | /// {{ char }}{{ name }} [TODO:description] 36 | //////////////////////////////////////////////////////////////////////////////// 37 | -------------------------------------------------------------------------------- /helper/src/c/docs/doxygen_javadoc.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - function_definition 7 | - declaration 8 | template: | 9 | /** 10 | * {{ char }}brief [TODO:summary] 11 | {% if params or return_type %} 12 | * 13 | {% endif %} 14 | {% if params %} 15 | {% for param in params %} 16 | * {{ char }}param[[TODO:direction]] {{ param.name }} [TODO:description] 17 | {% endfor %} 18 | {% endif %} 19 | {% if return_type %} 20 | * {{ char }}return [TODO:description] 21 | {% endif %} 22 | */ 23 | 24 | struct: 25 | node_types: 26 | - struct_specifier 27 | template: | 28 | /** 29 | * struct {{ name }} - [TODO:description] 30 | */ 31 | 32 | struct_field: 33 | node_types: 34 | - field_declaration 35 | template: | 36 | /** 37 | * {{ char }}{{ name }} [TODO:description] 38 | */ 39 | -------------------------------------------------------------------------------- /helper/src/c/docs/doxygen_javadoc_banner.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - function_definition 7 | - declaration 8 | template: | 9 | /******************************************************************************* 10 | * {{ char }}brief [TODO:summary] 11 | {% if params or return_type %} 12 | * 13 | {% endif %} 14 | {% if params %} 15 | {% for param in params %} 16 | * {{ char }}param[[TODO:direction]] {{ param.name }} [TODO:description] 17 | {% endfor %} 18 | {% endif %} 19 | {% if return_type %} 20 | * {{ char }}return [TODO:description] 21 | {% endif %} 22 | ******************************************************************************/ 23 | 24 | struct: 25 | node_types: 26 | - struct_specifier 27 | template: | 28 | /******************************************************************************* 29 | * struct {{ name }} - [TODO:description] 30 | ******************************************************************************/ 31 | 32 | struct_field: 33 | node_types: 34 | - field_declaration 35 | template: | 36 | /******************************************************************************* 37 | * {{ char }}{{ name }} [TODO:description] 38 | ******************************************************************************/ 39 | -------------------------------------------------------------------------------- /helper/src/c/docs/doxygen_javadoc_no_asterisk.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - function_definition 7 | - declaration 8 | template: | 9 | /** 10 | {{ char }}brief [TODO:summary] 11 | {% if params or return_type %} 12 | ~ 13 | {% endif %} 14 | {% if params %} 15 | {% for param in params %} 16 | {{ char }}param[[TODO:direction]] {{ param.name }} [TODO:description] 17 | {% endfor %} 18 | {% endif %} 19 | {% if return_type %} 20 | {{ char }}return [TODO:description] 21 | {% endif %} 22 | */ 23 | 24 | struct: 25 | node_types: 26 | - struct_specifier 27 | template: | 28 | /** 29 | struct {{ name }} - [TODO:description] 30 | */ 31 | 32 | struct_field: 33 | node_types: 34 | - field_declaration 35 | template: | 36 | /** 37 | {{ char }}{{ name }} [TODO:description] 38 | */ 39 | -------------------------------------------------------------------------------- /helper/src/c/docs/doxygen_qt.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - function_definition 7 | - declaration 8 | template: | 9 | /*! 10 | * {{ char }}brief [TODO:summary] 11 | {% if params or return_type %} 12 | * 13 | {% endif %} 14 | {% if params %} 15 | {% for param in params %} 16 | * {{ char }}param[[TODO:direction]] {{ param.name }} [TODO:description] 17 | {% endfor %} 18 | {% endif %} 19 | {% if return_type %} 20 | * {{ char }}return [TODO:description] 21 | {% endif %} 22 | */ 23 | 24 | struct: 25 | node_types: 26 | - struct_specifier 27 | template: | 28 | /*! 29 | * struct {{ name }} - [TODO:description] 30 | */ 31 | 32 | struct_field: 33 | node_types: 34 | - field_declaration 35 | template: | 36 | /*! 37 | * {{ char }}{{ name }} [TODO:description] 38 | */ 39 | -------------------------------------------------------------------------------- /helper/src/c/docs/doxygen_qt_no_asterisk.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - function_definition 7 | - declaration 8 | template: | 9 | /*! 10 | {{ char }}brief [TODO:summary] 11 | {% if params or return_type %} 12 | ~ 13 | {% endif %} 14 | {% if params %} 15 | {% for param in params %} 16 | {{ char }}param[[TODO:direction]] {{ param.name }} [TODO:description] 17 | {% endfor %} 18 | {% endif %} 19 | {% if return_type %} 20 | {{ char }}return [TODO:description] 21 | {% endif %} 22 | */ 23 | 24 | struct: 25 | node_types: 26 | - struct_specifier 27 | template: | 28 | /*! 29 | struct {{ name }} - [TODO:description] 30 | */ 31 | 32 | struct_field: 33 | node_types: 34 | - field_declaration 35 | template: | 36 | /*! 37 | {{ char }}{{ name }} [TODO:description] 38 | */ 39 | -------------------------------------------------------------------------------- /helper/src/c/docs/kernel_doc.yaml: -------------------------------------------------------------------------------- 1 | # https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - function_definition 7 | - declaration 8 | template: | 9 | /** 10 | * {{ name }}(): [TODO:summary] 11 | {% if params %} 12 | {% for param in params %} 13 | * @{{ param.name }}: [TODO:description] 14 | {% endfor %} 15 | {% endif %} 16 | * 17 | * [TODO:long description] 18 | {% if return_type %} 19 | * 20 | * Return: [TODO:description] 21 | {% endif %} 22 | */ 23 | 24 | struct: 25 | node_types: 26 | - struct_specifier 27 | template: | 28 | /** 29 | * struct {{ name }} - [TODO:description] 30 | */ 31 | 32 | struct_field: 33 | node_types: 34 | - field_declaration 35 | template: | 36 | /** 37 | * @{{ name }}: [TODO:description] 38 | */ 39 | -------------------------------------------------------------------------------- /helper/src/c/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/config.rs: -------------------------------------------------------------------------------- 1 | pub fn load_doc_config_str<'a>(parser_name: &'a str, doc_name: &'a str) -> &'a str { 2 | let config_name = format!("{}_{}", parser_name, doc_name); 3 | match config_name.as_str() { 4 | "python_reST" => include_str!("python/docs/reST.yaml"), 5 | "python_numpy" => include_str!("python/docs/numpy.yaml"), 6 | "python_google" => include_str!("python/docs/google.yaml"), 7 | "python_sphinx" => include_str!("python/docs/sphinx.yaml"), 8 | "python_doxygen" => include_str!("python/docs/doxygen.yaml"), 9 | 10 | "cpp_doxygen_cpp_comment_exclamation" => include_str!("cpp/docs/doxygen_cpp_comment_exclamation.yaml"), 11 | "cpp_doxygen_cpp_comment_slash" => include_str!("cpp/docs/doxygen_cpp_comment_slash.yaml"), 12 | "cpp_doxygen_cpp_comment_slash_banner" => include_str!("cpp/docs/doxygen_cpp_comment_slash_banner.yaml"), 13 | "cpp_doxygen_javadoc" => include_str!("cpp/docs/doxygen_javadoc.yaml"), 14 | "cpp_doxygen_javadoc_banner" => include_str!("cpp/docs/doxygen_javadoc_banner.yaml"), 15 | "cpp_doxygen_javadoc_no_asterisk" => include_str!("cpp/docs/doxygen_javadoc_no_asterisk.yaml"), 16 | "cpp_doxygen_qt" => include_str!("cpp/docs/doxygen_qt.yaml"), 17 | "cpp_doxygen_qt_no_asterisk" => include_str!("cpp/docs/doxygen_qt_no_asterisk.yaml"), 18 | 19 | "c_doxygen_cpp_comment_exclamation" => include_str!("c/docs/doxygen_cpp_comment_exclamation.yaml"), 20 | "c_doxygen_cpp_comment_slash" => include_str!("c/docs/doxygen_cpp_comment_slash.yaml"), 21 | "c_doxygen_cpp_comment_slash_banner" => include_str!("c/docs/doxygen_cpp_comment_slash_banner.yaml"), 22 | "c_doxygen_javadoc" => include_str!("c/docs/doxygen_javadoc.yaml"), 23 | "c_doxygen_javadoc_banner" => include_str!("c/docs/doxygen_javadoc_banner.yaml"), 24 | "c_doxygen_javadoc_no_asterisk" => include_str!("c/docs/doxygen_javadoc_no_asterisk.yaml"), 25 | "c_doxygen_qt" => include_str!("c/docs/doxygen_qt.yaml"), 26 | "c_doxygen_qt_no_asterisk" => include_str!("c/docs/doxygen_qt_no_asterisk.yaml"), 27 | "c_kernel_doc" => include_str!("c/docs/kernel_doc.yaml"), 28 | 29 | "php_phpdoc" => include_str!("php/docs/phpdoc.yaml"), 30 | "typescript_jsdoc" | "html_jsdoc" => include_str!("typescript/docs/jsdoc.yaml"), 31 | "lua_ldoc" => include_str!("lua/docs/ldoc.yaml"), 32 | "java_javadoc" => include_str!("java/docs/javadoc.yaml"), 33 | "ruby_YARD" => include_str!("ruby/docs/YARD.yaml"), 34 | "csharp_xmldoc" => include_str!("csharp/docs/xmldoc.yaml"), 35 | "bash_google" => include_str!("bash/docs/google.yaml"), 36 | "rust_rustdoc" => include_str!("rust/docs/rustdoc.yaml"), 37 | "r_roxygen2" => include_str!("r/docs/roxygen2.yaml"), 38 | "scala_scaladoc" => include_str!("scala/docs/scaladoc.yaml"), 39 | 40 | _ => panic!("Unsupported {} doc: {}", parser_name, doc_name), 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /helper/src/cpp/docs/doxygen_cpp_comment_exclamation.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_specifier 7 | - template_declaration 8 | template: | 9 | //! 10 | //! {{ char }}brief [TODO:summary] 11 | {% if tparams %} 12 | //! 13 | {% for tparam in tparams %} 14 | //! {{ char }}tparam {{ tparam.name }} [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | //! 18 | 19 | function: 20 | node_types: 21 | - function_definition 22 | - declaration 23 | - template_declaration 24 | - function_declarator 25 | template: | 26 | //! 27 | //! {{ char }}brief [TODO:summary] 28 | //! 29 | {% if tparams %} 30 | {% for tparam in tparams %} 31 | //! {{ char }}tparam {{ tparam.name }} [TODO:description] 32 | {% endfor %} 33 | {% endif %} 34 | {% if params %} 35 | {% for param in params %} 36 | //! {{ char }}param[[TODO:direction]] {{ param.name | default(value="[TODO:name]") }} [TODO:description] 37 | {% endfor %} 38 | {% endif %} 39 | {% if return_type %} 40 | //! {{ char }}return [TODO:description] 41 | {% endif %} 42 | //! 43 | 44 | struct: 45 | node_types: 46 | - struct_specifier 47 | - template_declaration 48 | template: | 49 | //! 50 | //! struct {{ name }} - [TODO:description] 51 | {% if tparams %} 52 | //! 53 | {% for tparam in tparams %} 54 | //! {{ char }}tparam {{ tparam.name }} [TODO:description] 55 | {% endfor %} 56 | {% endif %} 57 | //! 58 | 59 | struct_field: 60 | node_types: 61 | - field_declaration 62 | template: | 63 | //! 64 | //! {{ char }}{{ name }} [TODO:description] 65 | //! 66 | -------------------------------------------------------------------------------- /helper/src/cpp/docs/doxygen_cpp_comment_slash.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_specifier 7 | - template_declaration 8 | template: | 9 | /// 10 | /// {{ char }}brief [TODO:summary] 11 | {% if tparams %} 12 | /// 13 | {% for tparam in tparams %} 14 | /// {{ char }}tparam {{ tparam.name }} [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | /// 18 | 19 | function: 20 | node_types: 21 | - function_definition 22 | - declaration 23 | - template_declaration 24 | - function_declarator 25 | template: | 26 | /// 27 | /// {{ char }}brief [TODO:summary] 28 | /// 29 | {% if tparams %} 30 | {% for tparam in tparams %} 31 | /// {{ char }}tparam {{ tparam.name }} [TODO:description] 32 | {% endfor %} 33 | {% endif %} 34 | {% if params %} 35 | {% for param in params %} 36 | /// {{ char }}param[[TODO:direction]] {{ param.name | default(value="[TODO:name]") }} [TODO:description] 37 | {% endfor %} 38 | {% endif %} 39 | {% if return_type %} 40 | /// {{ char }}return [TODO:description] 41 | {% endif %} 42 | /// 43 | 44 | struct: 45 | node_types: 46 | - struct_specifier 47 | - template_declaration 48 | template: | 49 | /// 50 | /// struct {{ name }} - [TODO:description] 51 | {% if tparams %} 52 | /// 53 | {% for tparam in tparams %} 54 | /// {{ char }}tparam {{ tparam.name }} [TODO:description] 55 | {% endfor %} 56 | {% endif %} 57 | /// 58 | 59 | struct_field: 60 | node_types: 61 | - field_declaration 62 | template: | 63 | /// 64 | /// {{ char }}{{ name }} [TODO:description] 65 | /// 66 | -------------------------------------------------------------------------------- /helper/src/cpp/docs/doxygen_cpp_comment_slash_banner.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_specifier 7 | - template_declaration 8 | template: | 9 | //////////////////////////////////////////////////////////////////////////////// 10 | /// {{ char }}brief [TODO:summary] 11 | {% if tparams %} 12 | /// 13 | {% for tparam in tparams %} 14 | /// {{ char }}tparam {{ tparam.name }} [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | //////////////////////////////////////////////////////////////////////////////// 18 | 19 | function: 20 | node_types: 21 | - function_definition 22 | - declaration 23 | - template_declaration 24 | - function_declarator 25 | template: | 26 | //////////////////////////////////////////////////////////////////////////////// 27 | /// {{ char }}brief [TODO:summary] 28 | /// 29 | {% if tparams %} 30 | {% for tparam in tparams %} 31 | /// {{ char }}tparam {{ tparam.name }} [TODO:description] 32 | {% endfor %} 33 | {% endif %} 34 | {% if params %} 35 | {% for param in params %} 36 | /// {{ char }}param[[TODO:direction]] {{ param.name | default(value="[TODO:name]") }} [TODO:description] 37 | {% endfor %} 38 | {% endif %} 39 | {% if return_type %} 40 | /// {{ char }}return [TODO:description] 41 | {% endif %} 42 | //////////////////////////////////////////////////////////////////////////////// 43 | 44 | struct: 45 | node_types: 46 | - struct_specifier 47 | - template_declaration 48 | template: | 49 | //////////////////////////////////////////////////////////////////////////////// 50 | /// struct {{ name }} - [TODO:description] 51 | {% if tparams %} 52 | /// 53 | {% for tparam in tparams %} 54 | /// {{ char }}tparam {{ tparam.name }} [TODO:description] 55 | {% endfor %} 56 | {% endif %} 57 | //////////////////////////////////////////////////////////////////////////////// 58 | 59 | struct_field: 60 | node_types: 61 | - field_declaration 62 | template: | 63 | //////////////////////////////////////////////////////////////////////////////// 64 | /// {{ char }}{{ name }} [TODO:description] 65 | //////////////////////////////////////////////////////////////////////////////// 66 | -------------------------------------------------------------------------------- /helper/src/cpp/docs/doxygen_javadoc.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_specifier 7 | - template_declaration 8 | template: | 9 | /** 10 | * {{ char }}brief [TODO:summary] 11 | {% if tparams %} 12 | * 13 | {% for tparam in tparams %} 14 | * {{ char }}tparam {{ tparam.name }} [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | */ 18 | 19 | function: 20 | node_types: 21 | - function_definition 22 | - declaration 23 | - template_declaration 24 | - function_declarator 25 | template: | 26 | /** 27 | * {{ char }}brief [TODO:summary] 28 | * 29 | {% if tparams %} 30 | {% for tparam in tparams %} 31 | * {{ char }}tparam {{ tparam.name }} [TODO:description] 32 | {% endfor %} 33 | {% endif %} 34 | {% if params %} 35 | {% for param in params %} 36 | * {{ char }}param[[TODO:direction]] {{ param.name | default(value="[TODO:name]") }} [TODO:description] 37 | {% endfor %} 38 | {% endif %} 39 | {% if return_type %} 40 | * {{ char }}return [TODO:description] 41 | {% endif %} 42 | */ 43 | 44 | struct: 45 | node_types: 46 | - struct_specifier 47 | - template_declaration 48 | template: | 49 | /** 50 | * struct {{ name }} - [TODO:description] 51 | {% if tparams %} 52 | * 53 | {% for tparam in tparams %} 54 | * {{ char }}tparam {{ tparam.name }} [TODO:description] 55 | {% endfor %} 56 | {% endif %} 57 | */ 58 | 59 | struct_field: 60 | node_types: 61 | - field_declaration 62 | template: | 63 | /** 64 | * {{ char }}{{ name }} [TODO:description] 65 | */ 66 | -------------------------------------------------------------------------------- /helper/src/cpp/docs/doxygen_javadoc_banner.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_specifier 7 | - template_declaration 8 | template: | 9 | /******************************************************************************* 10 | * {{ char }}brief [TODO:summary] 11 | {% if tparams %} 12 | * 13 | {% for tparam in tparams %} 14 | * {{ char }}tparam {{ tparam.name }} [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | ******************************************************************************/ 18 | 19 | function: 20 | node_types: 21 | - function_definition 22 | - declaration 23 | - template_declaration 24 | - function_declarator 25 | template: | 26 | /******************************************************************************* 27 | * {{ char }}brief [TODO:summary] 28 | * 29 | {% if tparams %} 30 | {% for tparam in tparams %} 31 | * {{ char }}tparam {{ tparam.name }} [TODO:description] 32 | {% endfor %} 33 | {% endif %} 34 | {% if params %} 35 | {% for param in params %} 36 | * {{ char }}param[[TODO:direction]] {{ param.name | default(value="[TODO:name]") }} [TODO:description] 37 | {% endfor %} 38 | {% endif %} 39 | {% if return_type %} 40 | * {{ char }}return [TODO:description] 41 | {% endif %} 42 | ******************************************************************************/ 43 | 44 | struct: 45 | node_types: 46 | - struct_specifier 47 | - template_declaration 48 | template: | 49 | /******************************************************************************* 50 | * struct {{ name }} - [TODO:description] 51 | {% if tparams %} 52 | * 53 | {% for tparam in tparams %} 54 | * {{ char }}tparam {{ tparam.name }} [TODO:description] 55 | {% endfor %} 56 | {% endif %} 57 | ******************************************************************************/ 58 | 59 | struct_field: 60 | node_types: 61 | - field_declaration 62 | template: | 63 | /******************************************************************************* 64 | * {{ char }}{{ name }} [TODO:description] 65 | ******************************************************************************/ 66 | -------------------------------------------------------------------------------- /helper/src/cpp/docs/doxygen_javadoc_no_asterisk.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_specifier 7 | - template_declaration 8 | template: | 9 | /** 10 | {{ char }}brief [TODO:summary] 11 | {% if tparams %} 12 | ~ 13 | {% for tparam in tparams %} 14 | {{ char }}tparam {{ tparam.name }} [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | */ 18 | 19 | function: 20 | node_types: 21 | - function_definition 22 | - declaration 23 | - template_declaration 24 | - function_declarator 25 | template: | 26 | /** 27 | {{ char }}brief [TODO:summary] 28 | ~ 29 | {% if tparams %} 30 | {% for tparam in tparams %} 31 | {{ char }}tparam {{ tparam.name }} [TODO:description] 32 | {% endfor %} 33 | {% endif %} 34 | {% if params %} 35 | {% for param in params %} 36 | {{ char }}param[[TODO:direction]] {{ param.name | default(value="[TODO:name]") }} [TODO:description] 37 | {% endfor %} 38 | {% endif %} 39 | {% if return_type %} 40 | {{ char }}return [TODO:description] 41 | {% endif %} 42 | */ 43 | 44 | struct: 45 | node_types: 46 | - struct_specifier 47 | - template_declaration 48 | template: | 49 | /** 50 | struct {{ name }} - [TODO:description] 51 | {% if tparams %} 52 | ~ 53 | {% for tparam in tparams %} 54 | {{ char }}tparam {{ tparam.name }} [TODO:description] 55 | {% endfor %} 56 | {% endif %} 57 | */ 58 | 59 | struct_field: 60 | node_types: 61 | - field_declaration 62 | template: | 63 | /** 64 | {{ char }}{{ name }} [TODO:description] 65 | */ 66 | -------------------------------------------------------------------------------- /helper/src/cpp/docs/doxygen_qt.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_specifier 7 | - template_declaration 8 | template: | 9 | /*! 10 | * {{ char }}brief [TODO:summary] 11 | {% if tparams %} 12 | * 13 | {% for tparam in tparams %} 14 | * {{ char }}tparam {{ tparam.name }} [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | */ 18 | 19 | function: 20 | node_types: 21 | - function_definition 22 | - declaration 23 | - template_declaration 24 | - function_declarator 25 | template: | 26 | /*! 27 | * {{ char }}brief [TODO:summary] 28 | * 29 | {% if tparams %} 30 | {% for tparam in tparams %} 31 | * {{ char }}tparam {{ tparam.name }} [TODO:description] 32 | {% endfor %} 33 | {% endif %} 34 | {% if params %} 35 | {% for param in params %} 36 | * {{ char }}param[[TODO:direction]] {{ param.name | default(value="[TODO:name]") }} [TODO:description] 37 | {% endfor %} 38 | {% endif %} 39 | {% if return_type %} 40 | * {{ char }}return [TODO:description] 41 | {% endif %} 42 | */ 43 | 44 | struct: 45 | node_types: 46 | - struct_specifier 47 | - template_declaration 48 | template: | 49 | /*! 50 | * struct {{ name }} - [TODO:description] 51 | {% if tparams %} 52 | * 53 | {% for tparam in tparams %} 54 | * {{ char }}tparam {{ tparam.name }} [TODO:description] 55 | {% endfor %} 56 | {% endif %} 57 | */ 58 | 59 | struct_field: 60 | node_types: 61 | - field_declaration 62 | template: | 63 | /*! 64 | * {{ char }}{{ name }} [TODO:description] 65 | */ 66 | -------------------------------------------------------------------------------- /helper/src/cpp/docs/doxygen_qt_no_asterisk.yaml: -------------------------------------------------------------------------------- 1 | # http://www.doxygen.nl/manual/docblocks.html 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_specifier 7 | - template_declaration 8 | template: | 9 | /*! 10 | {{ char }}brief [TODO:summary] 11 | {% if tparams %} 12 | ~ 13 | {% for tparam in tparams %} 14 | {{ char }}tparam {{ tparam.name }} [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | */ 18 | 19 | function: 20 | node_types: 21 | - function_definition 22 | - declaration 23 | - template_declaration 24 | - function_declarator 25 | template: | 26 | /*! 27 | {{ char }}brief [TODO:summary] 28 | ~ 29 | {% if tparams %} 30 | {% for tparam in tparams %} 31 | {{ char }}tparam {{ tparam.name }} [TODO:description] 32 | {% endfor %} 33 | {% endif %} 34 | {% if params %} 35 | {% for param in params %} 36 | {{ char }}param[[TODO:direction]] {{ param.name | default(value="[TODO:name]") }} [TODO:description] 37 | {% endfor %} 38 | {% endif %} 39 | {% if return_type %} 40 | {{ char }}return [TODO:description] 41 | {% endif %} 42 | */ 43 | 44 | struct: 45 | node_types: 46 | - struct_specifier 47 | - template_declaration 48 | template: | 49 | /*! 50 | struct {{ name }} - [TODO:description] 51 | {% if tparams %} 52 | ~ 53 | {% for tparam in tparams %} 54 | {{ char }}tparam {{ tparam.name }} [TODO:description] 55 | {% endfor %} 56 | {% endif %} 57 | */ 58 | 59 | struct_field: 60 | node_types: 61 | - field_declaration 62 | template: | 63 | /*! 64 | {{ char }}{{ name }} [TODO:description] 65 | */ 66 | -------------------------------------------------------------------------------- /helper/src/cpp/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/csharp/docs/xmldoc.yaml: -------------------------------------------------------------------------------- 1 | # https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/ 2 | 3 | templates: 4 | method: 5 | node_types: 6 | - method_declaration 7 | - operator_declaration 8 | - delegate_declaration 9 | - constructor_declaration 10 | template: | 11 | /// 12 | /// [TODO:description] 13 | /// 14 | {% if params %} 15 | {% for param in params %} 16 | /// [TODO:description] 17 | {% endfor %} 18 | {% endif %} 19 | {% if has_non_void_return_type and not is_constructor %} 20 | /// [TODO:description] 21 | {% endif %} 22 | 23 | other: 24 | node_types: 25 | - class_declaration 26 | - variable_declaration 27 | - property_declaration 28 | - field_declaration 29 | - enum_declaration 30 | template: | 31 | /// 32 | /// [TODO:description] 33 | /// 34 | -------------------------------------------------------------------------------- /helper/src/csharp/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/html/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/html/parser.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use tree_sitter::{Parser, Node}; 4 | use serde_json::{Map, Value}; 5 | 6 | use crate::traverse; 7 | use crate::base_parser::BaseParser; 8 | use crate::typescript::parser::TypescriptParser; 9 | 10 | pub struct HtmlParser<'a> { 11 | code: &'a str, 12 | tree: tree_sitter::Tree, 13 | line: &'a usize, 14 | node_types: &'a [&'a str], 15 | options: &'a HashMap<&'a str, bool>, 16 | } 17 | 18 | impl<'a> BaseParser for HtmlParser<'a> { 19 | fn parse(&self) -> Option, String>> { 20 | self.parse_node(&self.tree.root_node()) 21 | } 22 | 23 | fn get_code_bytes(&self) -> &[u8] { 24 | &self.code.as_bytes() 25 | } 26 | } 27 | 28 | impl<'a> HtmlParser<'a> { 29 | pub fn new(code: &'a str, line: &'a usize, node_types: &'a [&'a str], options: &'a HashMap<&'a str, bool>) -> Self { 30 | let mut parser = Parser::new(); 31 | parser.set_language(tree_sitter_html::language()).unwrap(); 32 | 33 | let tree = parser.parse(code, None).unwrap(); 34 | 35 | Self { code, tree, line, options, node_types } 36 | } 37 | 38 | fn parse_node(&self, node: &Node) -> Option, String>> { 39 | for child_node in traverse::PreOrder::new(node.walk()) { 40 | // Parse the script element that is surrounding the cursor. 41 | if child_node.kind() == "script_element" && 42 | child_node.start_position().row <= self.line - 1 && 43 | child_node.end_position().row >= self.line - 1 44 | { 45 | return self.parse_script_element(&child_node); 46 | } 47 | } 48 | 49 | None 50 | } 51 | 52 | fn parse_script_element(&self, script_element_node: &Node) -> Option, String>> { 53 | let raw_text = script_element_node 54 | .children(&mut script_element_node.walk()) 55 | .filter(|node| node.kind() == "raw_text") 56 | .next() 57 | .and_then(|node| Some(self.get_node_text(&node))) 58 | .unwrap(); 59 | 60 | // The new line must be based on the script tag starting position. 61 | let line = self.line - script_element_node.start_position().row; 62 | 63 | // Parse the inner content of the script tag with the TS parser. 64 | let ts_parser = TypescriptParser::new(&raw_text, &line, self.node_types, self.options); 65 | ts_parser.parse() 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /helper/src/java/docs/javadoc.yaml: -------------------------------------------------------------------------------- 1 | # https://www.oracle.com/technetwork/articles/javase/index-137868.html 2 | 3 | templates: 4 | method: 5 | node_types: 6 | - method_declaration 7 | template: | 8 | /** 9 | * [TODO:description] 10 | {% if params %} 11 | * 12 | {% for param in params %} 13 | * @param {{ param.name }} [TODO:description] 14 | {% endfor %} 15 | {% endif %} 16 | {% if return_type %} 17 | * 18 | * @return [TODO:description] 19 | {% endif %} 20 | {% if exceptions %} 21 | * 22 | {% for exception in exceptions %} 23 | * @throws {{ exception.name }} [TODO:description] 24 | {% endfor %} 25 | {% endif %} 26 | */ 27 | -------------------------------------------------------------------------------- /helper/src/java/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod traverse; 2 | pub mod tokens; 3 | pub mod config; 4 | pub mod docblock; 5 | pub mod base_parser; 6 | 7 | pub mod bash; 8 | pub mod php; 9 | pub mod lua; 10 | pub mod ruby; 11 | pub mod rust; 12 | pub mod csharp; 13 | pub mod java; 14 | pub mod python; 15 | pub mod c; 16 | pub mod cpp; 17 | pub mod typescript; 18 | pub mod r; 19 | pub mod scala; 20 | pub mod html; 21 | -------------------------------------------------------------------------------- /helper/src/lua/docs/ldoc.yaml: -------------------------------------------------------------------------------- 1 | # https://github.com/stevedonovan/LDoc 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - function_definition_statement 7 | - function_definition 8 | template: | 9 | -- [TODO:summary] 10 | -- [TODO:description] 11 | {% if params %} 12 | {% for param in params %} 13 | -- @param {{ param.name }} [TODO:description] 14 | {% endfor %} 15 | {% endif %} 16 | -------------------------------------------------------------------------------- /helper/src/lua/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/lua/parser.rs: -------------------------------------------------------------------------------- 1 | use tree_sitter::{Parser, Node}; 2 | use serde_json::{Map, Value}; 3 | 4 | use crate::base_parser::BaseParser; 5 | use crate::traverse; 6 | 7 | pub struct LuaParser<'a> { 8 | code: &'a str, 9 | tree: tree_sitter::Tree, 10 | line: &'a usize, 11 | node_types: &'a [&'a str], 12 | } 13 | 14 | impl<'a> BaseParser for LuaParser<'a> { 15 | fn parse(&self) -> Option, String>> { 16 | self.parse_node(&self.tree.root_node()) 17 | } 18 | 19 | fn get_code_bytes(&self) -> &[u8] { 20 | &self.code.as_bytes() 21 | } 22 | } 23 | 24 | impl<'a> LuaParser<'a> { 25 | pub fn new(code: &'a str, line: &'a usize, node_types: &'a [&'a str]) -> Self { 26 | let mut parser = Parser::new(); 27 | parser.set_language(tree_sitter_lua::language()).unwrap(); 28 | 29 | let tree = parser.parse(code, None).unwrap(); 30 | 31 | Self { code, tree, line, node_types } 32 | } 33 | 34 | fn parse_node(&self, node: &Node) -> Option, String>> { 35 | for child_node in traverse::PreOrder::new(node.walk()) { 36 | if child_node.start_position().row + 1 == *self.line && self.node_types.contains(&child_node.kind()) { 37 | return match child_node.kind() { 38 | "function_definition_statement" | "function_definition" => Some(self.parse_function(&child_node)), 39 | _ => None, 40 | }; 41 | } 42 | } 43 | 44 | None 45 | } 46 | 47 | fn parse_function(&self, node: &Node) -> Result, String> { 48 | let mut tokens = Map::new(); 49 | 50 | for child_node in node.children(&mut node.walk()) { 51 | match child_node.kind() { 52 | "parameter_list" => { 53 | let mut params = Vec::new(); 54 | 55 | child_node 56 | .children(&mut child_node.walk()) 57 | .filter(|node| node.kind() == "identifier") 58 | .for_each(|node| { 59 | let mut param = Map::new(); 60 | 61 | let func_name = self.get_node_text(&node); 62 | if func_name != "self" { 63 | param.insert("name".to_string(), Value::String(func_name)); 64 | } 65 | 66 | if !param.is_empty() { 67 | params.push(Value::Object(param)); 68 | } 69 | }); 70 | 71 | if !params.is_empty() { 72 | tokens.insert("params".to_string(), Value::Array(params)); 73 | } 74 | }, 75 | _ => {}, 76 | } 77 | } 78 | 79 | Ok(tokens) 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /helper/src/php/docs/phpdoc.yaml: -------------------------------------------------------------------------------- 1 | # https://www.phpdoc.org 2 | 3 | templates: 4 | class_property: 5 | node_types: 6 | - property_declaration 7 | template: | 8 | /** 9 | * @var {{ type | default(value="[TODO:type]") }} 10 | */ 11 | 12 | function: 13 | node_types: 14 | - method_declaration 15 | - function_definition 16 | template: > 17 | /** 18 | * [TODO:description] 19 | {% if params %} 20 | * 21 | {% for param in params %} 22 | * @param {{ param.type | default(value="[TODO:type]") }} {{ param.name }} {% if param.default_value %}(optional){% endif %} [TODO:description] 23 | {% endfor %} 24 | {% endif %} 25 | {% if exceptions %} 26 | * 27 | {% for exception in exceptions %} 28 | * @throws {{ exception.name | default(value="[TODO:name]") }} [TODO:description] 29 | {% endfor %} 30 | {% endif %} 31 | {% if not is_constructor_method %} 32 | * 33 | * @return {{ return_type | default(value="[TODO:type]") }} [TODO:description] 34 | {% endif %} 35 | */ 36 | -------------------------------------------------------------------------------- /helper/src/php/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/python/docs/doxygen.yaml: -------------------------------------------------------------------------------- 1 | # https://www.woolseyworkshop.com/2020/06/25/documenting-python-programs-with-doxygen/ 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_definition 7 | template: | 8 | """! @brief [TODO:description]""" 9 | 10 | function: 11 | node_types: 12 | - function_definition 13 | template: | 14 | {% if not params and not exceptions and not return_type %} 15 | """! @brief [TODO:description]""" 16 | {% else %} 17 | """! 18 | @brief [TODO:description] 19 | {% if params %} 20 | ~ 21 | {% for param in params %} 22 | @param {{ param.name }} [TODO:description] 23 | {% endfor %} 24 | {% endif %} 25 | {% if return_type %} 26 | ~ 27 | @return [TODO:description] 28 | {% endif %} 29 | {% if exceptions %} 30 | ~ 31 | {% for exception in exceptions %} 32 | @throws {{ exception.name | default(value="[TODO:name]") }} [TODO:description] 33 | {% endfor %} 34 | {% endif %} 35 | """ 36 | {% endif %} 37 | -------------------------------------------------------------------------------- /helper/src/python/docs/google.yaml: -------------------------------------------------------------------------------- 1 | # https://github.com/google/styleguide/blob/gh-pages/pyguide.md 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_definition 7 | template: | 8 | """ 9 | [TODO:description] 10 | {% if attributes %} 11 | ~ 12 | Attributes: 13 | {% for attribute in attributes %} 14 | {{ attribute.name }}{% if show_types or not attribute.type %} ({{ attribute.type | default(value="[TODO:type]") }}){% endif %}: [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | """ 18 | 19 | function: 20 | node_types: 21 | - function_definition 22 | template: | 23 | """[TODO:summary] 24 | ~ 25 | [TODO:description] 26 | {% if params %} 27 | ~ 28 | Args: 29 | {% for param in params %} 30 | {{ param.name | default(value="[TODO:name]") }}{% if show_types or not param.type %} ({{ param.type | default(value="[TODO:type]") }}){% endif %}: [TODO:description] 31 | {% endfor %} 32 | {% endif %} 33 | {% if return_type %} 34 | ~ 35 | Returns: 36 | {% if show_types or not return_type %}{{ return_type }}: {% endif %}{% if return_type %}[TODO:description]{% endif %} 37 | {% endif %} 38 | {% if exceptions %} 39 | ~ 40 | Raises: 41 | {% for exception in exceptions %} 42 | {{ exception.name | default(value="[TODO:name]") }}: [TODO:description] 43 | {% endfor %} 44 | {% endif %} 45 | """ 46 | -------------------------------------------------------------------------------- /helper/src/python/docs/numpy.yaml: -------------------------------------------------------------------------------- 1 | # http://daouzli.com/blog/docstring.html#numpydoc 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_definition 7 | template: | 8 | """ 9 | [TODO:description] 10 | {% if attributes %} 11 | ~ 12 | Attributes 13 | ---------- 14 | {% for attribute in attributes %} 15 | {{ attribute.name }}{% if show_types or not attribute.type %} : {{ attribute.type | default(value="[TODO:type]") }}{% endif %} 16 | [TODO:description] 17 | {% endfor %} 18 | {% endif %} 19 | """ 20 | 21 | function: 22 | node_types: 23 | - function_definition 24 | template: | 25 | """ 26 | [TODO:summary] 27 | ~ 28 | [TODO:description] 29 | {% if params %} 30 | ~ 31 | Parameters 32 | ---------- 33 | {% for param in params %} 34 | {{ param.name }}{% if show_types or not param.type %} : {{ param.type | default(value="[TODO:type]") }}{% endif %} 35 | [TODO:description] 36 | {% endfor %} 37 | {% endif %} 38 | {% if return_type %} 39 | ~ 40 | Returns 41 | ------- 42 | {{ return_type }} 43 | [TODO:description] 44 | {% endif %} 45 | {% if exceptions %} 46 | ~ 47 | Raises 48 | ------ 49 | {% for exception in exceptions %} 50 | {{ exception.name | default(value="[TODO:name]") }}: 51 | [TODO:description] 52 | {% endfor %} 53 | {% endif %} 54 | """ 55 | -------------------------------------------------------------------------------- /helper/src/python/docs/reST.yaml: -------------------------------------------------------------------------------- 1 | # http://daouzli.com/blog/docstring.html#restructuredtext 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_definition 7 | template: | 8 | """ 9 | [TODO:description] 10 | {% if attributes %} 11 | ~ 12 | Attributes: 13 | {% for attribute in attributes %} 14 | {{ attribute.name }}{% if show_types or not attribute.type %} ({{ attribute.type | default(value="[TODO:type]") }}){% endif %}: [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | """ 18 | 19 | function: 20 | node_types: 21 | - function_definition 22 | template: | 23 | """ 24 | [TODO:description] 25 | {% if params or return_type or exceptions %} 26 | ~ 27 | {% endif %} 28 | {% if params %} 29 | {% for param in params %} 30 | :param {{ param.name }}{% if show_types or not param.type %} {{ param.type | default(value="[TODO:type]") }}{% endif %}: [TODO:description] 31 | {% endfor %} 32 | {% endif %} 33 | {% if return_type %} 34 | :return: [TODO:description] 35 | {% endif %} 36 | {% if exceptions %} 37 | {% for exception in exceptions %} 38 | :raises {{ exception.name | default(value="[TODO:name]") }}: [TODO:description] 39 | {% endfor %} 40 | {% endif %} 41 | """ 42 | -------------------------------------------------------------------------------- /helper/src/python/docs/sphinx.yaml: -------------------------------------------------------------------------------- 1 | # https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html 2 | 3 | templates: 4 | class: 5 | node_types: 6 | - class_definition 7 | template: | 8 | """ 9 | [TODO:description] 10 | {% if attributes %} 11 | ~ 12 | Attributes: 13 | {% for attribute in attributes %} 14 | {{ attribute.name }}{% if show_types or not attribute.type %} ({{ attribute.type | default(value="[TODO:type]") }}){% endif %}: [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | """ 18 | 19 | function: 20 | node_types: 21 | - function_definition 22 | template: | 23 | """ 24 | [TODO:description] 25 | {% if params or return_type or exceptions %} 26 | ~ 27 | {% endif %} 28 | {% if params %} 29 | {% for param in params %} 30 | :param {{ param.name }}: [TODO:description]{% if param.default_value %}, defaults to {{ param.default_value }}{% endif %} 31 | {% if show_types or not param.type %}:type {{ param.name }}: {{ param.type | default(value="[TODO:type]") }}{% if param.default_value %}, optional{% endif %}{% endif %} 32 | {% endfor %} 33 | {% endif %} 34 | {% if return_type %} 35 | :return: [TODO:description] 36 | {% if show_types %} 37 | :rtype: {{ return_type | default(value="[TODO:type]") }} 38 | {% endif %} 39 | {% endif %} 40 | {% if exceptions %} 41 | {% for exception in exceptions %} 42 | :raises {{ exception.name | default(value="[TODO:name]") }}: [TODO:description] 43 | {% endfor %} 44 | {% endif %} 45 | """ 46 | -------------------------------------------------------------------------------- /helper/src/python/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/r/docs/roxygen2.yaml: -------------------------------------------------------------------------------- 1 | # https://github.com/klutometis/roxygen 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - function_definition 7 | template: | 8 | #' [TODO:title of the function] 9 | #' 10 | #' [TODO:brief description] 11 | {% if params %} 12 | #' 13 | {% for param in params %} 14 | #' @param {{ param.name }} [TODO:description]{% if param.default_value %}. Default is {{ param.default_value }}.{% endif %} 15 | {% endfor %} 16 | {% endif %} 17 | #' 18 | #' @return [TODO:description] 19 | #' 20 | #' @examples 21 | #' {{ func_name }}([TODO:parameters]) 22 | #' 23 | #' @rdname {{ func_name }} 24 | #' 25 | #' @method {{ func_name }} 26 | -------------------------------------------------------------------------------- /helper/src/r/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/ruby/docs/YARD.yaml: -------------------------------------------------------------------------------- 1 | # https://www.rubydoc.info/gems/yard/file/docs/Tags.md 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - method 7 | - singleton_method 8 | template: | 9 | # [TODO:description] 10 | {% if params %} 11 | {% for param in params %} 12 | # @param {{ param.name }} [[TODO:type]] [TODO:description] 13 | {% endfor %} 14 | {% endif %} 15 | -------------------------------------------------------------------------------- /helper/src/ruby/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/rust/docs/rustdoc.yaml: -------------------------------------------------------------------------------- 1 | # https://doc.rust-lang.org/rust-by-example/meta/doc.html 2 | 3 | templates: 4 | function: 5 | node_types: 6 | - function_item 7 | template: | 8 | /// [TODO:description] 9 | {% if params %} 10 | /// 11 | /// # Arguments 12 | /// 13 | {% for param in params %} 14 | /// * `{{ param.name }}` - [TODO:description] 15 | {% endfor %} 16 | {% endif %} 17 | {% if has_panics %} 18 | /// 19 | /// # Panics 20 | /// 21 | /// [TODO:describe scenarios in which the function could panic] 22 | {% endif %} 23 | {% if has_errors %} 24 | /// 25 | /// # Errors 26 | /// 27 | /// [TODO:describe error types and what triggers them] 28 | {% endif %} 29 | {% if has_unsafe %} 30 | /// 31 | /// # Safety 32 | /// 33 | /// [TODO:explain why the function is unsafe] 34 | {% endif %} 35 | /// 36 | /// # Examples 37 | /// 38 | /// ``` 39 | /// [TODO:write some example code] 40 | /// ``` 41 | -------------------------------------------------------------------------------- /helper/src/rust/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/scala/docs/scaladoc.yaml: -------------------------------------------------------------------------------- 1 | # https://docs.scala-lang.org/style/scaladoc.html 2 | 3 | templates: 4 | lambda_expression: 5 | node_types: 6 | - lambda_expression 7 | template: | 8 | /** [TODO:description] 9 | * 10 | {% if params %} 11 | {% for param in params %} 12 | * @param {{ param.name }} [TODO:description] 13 | {% endfor %} 14 | {% endif %} 15 | * @return [TODO:description] 16 | */ 17 | 18 | function: 19 | node_types: 20 | - function_definition 21 | template: | 22 | /** [TODO:description] 23 | * 24 | {% if params %} 25 | {% for param in params %} 26 | * @param {{ param.name }} [TODO:description] 27 | {% endfor %} 28 | {% endif %} 29 | * @return [TODO:description] 30 | */ 31 | 32 | class: 33 | node_types: 34 | - class_definition 35 | template: | 36 | {% if params %} 37 | /** [TODO:description] 38 | * 39 | {% for param in params %} 40 | * @param {{ param.name }} [TODO:description] 41 | {% endfor %} 42 | */ 43 | {% else %} 44 | /** [TODO:description] */ 45 | {% endif %} 46 | -------------------------------------------------------------------------------- /helper/src/scala/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /helper/src/tokens.rs: -------------------------------------------------------------------------------- 1 | use tera::{Tera, Context}; 2 | use regex::Regex; 3 | use serde_json::{Map, json, Value}; 4 | 5 | pub fn replace_tokens( 6 | template: &str, 7 | tokens: &Map, 8 | ) -> Result> { 9 | let mut tera = Tera::default(); 10 | 11 | let tokens_json = json!(tokens); 12 | let context = Context::from_serialize(tokens_json).unwrap(); 13 | match tera.add_raw_template("docblock", template) { 14 | Ok(()) => {}, 15 | Err(err) => panic!("Failed to render template: {:#?}", err), 16 | } 17 | 18 | let docstring = tera.render("docblock", &context).unwrap(); 19 | let docstring_lines: Vec<&str> = docstring.split("\n").collect(); 20 | 21 | let clean_docstring: Vec = docstring_lines 22 | .iter() 23 | .filter(|line| !line.trim().is_empty()) 24 | .map(|line| { 25 | let patterns = [ 26 | (r" +", " "), // Replace multiple spaces with a single space. 27 | (r"^~$", ""), // Lines marked with ~ are those to be preserved 28 | ]; 29 | 30 | let mut new_line = line.to_owned().to_string(); 31 | 32 | for (pattern, replacement) in patterns.iter() { 33 | let regex = Regex::new(pattern).unwrap(); 34 | new_line = regex.replace_all(&new_line, *replacement).to_string(); 35 | } 36 | 37 | new_line 38 | }) 39 | .collect(); 40 | 41 | Ok(clean_docstring.join("\n")) 42 | } 43 | -------------------------------------------------------------------------------- /helper/src/traverse.rs: -------------------------------------------------------------------------------- 1 | // Lazy pre-order traversal over arbitrary tree-sitter trees. 2 | 3 | use tree_sitter::{Node, TreeCursor}; 4 | 5 | pub struct PreOrder<'a> { 6 | cursor: TreeCursor<'a>, 7 | done: bool, 8 | } 9 | 10 | impl<'a> PreOrder<'a> { 11 | pub fn new(cursor: TreeCursor<'a>) -> Self { 12 | Self { 13 | cursor, 14 | done: false, 15 | } 16 | } 17 | } 18 | 19 | // Traverse the tree in root-left-right fashion. 20 | impl<'a> Iterator for PreOrder<'a> { 21 | type Item = Node<'a>; 22 | 23 | fn next(&mut self) -> Option { 24 | if self.done { 25 | return None; 26 | } 27 | 28 | // Capture the root node. 29 | let node = self.cursor.node(); 30 | 31 | // If this node has a child, move there and return the root, or 32 | // if this node has a sibling, move there and return the root. 33 | if self.cursor.goto_first_child() || self.cursor.goto_next_sibling() { 34 | return Some(node); 35 | } 36 | 37 | loop { 38 | // We are done retracing all the way back to the root node. 39 | if !self.cursor.goto_parent() { 40 | self.done = true; 41 | break; 42 | } 43 | 44 | if self.cursor.goto_next_sibling() { 45 | break; 46 | } 47 | } 48 | 49 | Some(node) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /helper/src/typescript/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod parser; 2 | -------------------------------------------------------------------------------- /scripts/build.ps1: -------------------------------------------------------------------------------- 1 | $RootDir = Resolve-Path -Path ((Split-Path $myInvocation.MyCommand.Path) + "\..") 2 | $BuildTarget = $args[0] 3 | $OutFile = $args[1] 4 | 5 | Set-Location $RootDir 6 | if (!(Test-Path -Path "./bin")) { New-Item -ItemType Directory -Path "./bin" | Out-Null } 7 | if (Test-Path -Path "./bin/vim-doge-helper.exe") { Remove-Item -Path "./bin/vim-doge-helper.exe" } 8 | 9 | # Build the binary. 10 | Set-Location "$RootDir/helper" 11 | 12 | if ($BuildTarget) { 13 | cargo build --release --target "$BuildTarget" 14 | Copy-Item -Path "target/$BuildTarget/release/vim-doge-helper.exe" -Destination "../bin/" 15 | } 16 | else { 17 | cargo build --release 18 | Copy-Item -Path "target/release/vim-doge-helper.exe" -Destination "../bin/" 19 | } 20 | 21 | # Archive the binary. 22 | if ($OutFile) { 23 | $OutFile = "$OutFile.zip" 24 | 25 | Set-Location "$RootDir/bin" 26 | Remove-Item -Path "./*.zip" 27 | Write-Host "[vim-doge] Archiving $RootDir/bin/vim-doge-helper.exe -> $RootDir/bin/$OutFile" 28 | 7z a -tzip "$OutFile" "vim-doge-helper.exe" 29 | } 30 | 31 | Write-Host "[vim-doge] Done building vim-doge-helper" 32 | -------------------------------------------------------------------------------- /scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # For more info about the 'set' command, see 4 | # https://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin 5 | set -e 6 | set -u 7 | 8 | ROOT_DIR=$(cd "$(dirname "$0")/.."; pwd -P) 9 | BUILD_TARGET="${1:-}" 10 | OUTFILE="${2:-}" 11 | OS="$(uname)" 12 | 13 | CMD="cargo" 14 | if [[ "$OS" != "Darwin" ]] && command -v cross >/dev/null 2>&1; then 15 | CMD="cross" 16 | fi 17 | 18 | cd $ROOT_DIR 19 | [[ ! -d ./bin ]] && mkdir ./bin 20 | [[ -e ./bin/vim-doge-helper ]] && rm -f ./bin/vim-doge-helper 21 | 22 | # Build the binary. 23 | cd $ROOT_DIR/helper 24 | if [[ "$BUILD_TARGET" != "" ]]; then 25 | eval "$CMD build --release --target $BUILD_TARGET" 26 | cp target/$BUILD_TARGET/release/vim-doge-helper ../bin/ 27 | else 28 | eval "$CMD build --release" 29 | cp target/release/vim-doge-helper ../bin/ 30 | fi 31 | 32 | # Archive the binary. 33 | if [[ "$OUTFILE" != "" ]]; then 34 | OUTFILE="$OUTFILE.tar.gz" 35 | 36 | cd $ROOT_DIR/bin 37 | rm -f ./*.tar.gz 38 | echo "==> Archiving $ROOT_DIR/bin/vim-doge-helper -> $ROOT_DIR/bin/$OUTFILE" 39 | tar -czf "$OUTFILE" vim-doge-helper 40 | fi 41 | 42 | echo "🎉 Done building vim-doge-helper" 43 | -------------------------------------------------------------------------------- /scripts/install.ps1: -------------------------------------------------------------------------------- 1 | $RootDir = Resolve-Path -Path ((Split-Path $MyInvocation.MyCommand.Path) + "\..") 2 | $InstallDir = $args[0] 3 | 4 | if (-not $InstallDir) { 5 | $InstallDir = $RootDir 6 | } 7 | 8 | $BinDir = "$InstallDir\bin" 9 | $OutFile = "$BinDir\vim-doge-helper.exe" 10 | 11 | Write-Host "Installation path: $OutFile" 12 | 13 | $Arch = $env:PROCESSOR_ARCHITECTURE 14 | if ($Arch -eq 'x86') { 15 | # 32-bit 16 | $AssetName = "vim-doge-helper-windows-i686.zip" 17 | } 18 | else { 19 | # 64-bit 20 | $AssetName = "vim-doge-helper-windows-x86_64.zip" 21 | } 22 | 23 | $AppVersion = Get-Content "$RootDir\.version" 24 | 25 | $AssetPath = "$RootDir\bin\$AssetName" 26 | 27 | $DownloadUrl = "https://github.com/kkoomen/vim-doge/releases/download/v$AppVersion/$AssetName" 28 | 29 | if (Test-Path $AssetPath) { 30 | Remove-Item "$AssetPath" 31 | } 32 | 33 | if (Test-Path $OutFile) { 34 | Remove-Item "$OutFile" 35 | } 36 | 37 | try { 38 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls12, [Net.SecurityProtocolType]::Ssl3 39 | [Net.ServicePointManager]::SecurityProtocol = "Tls, Tls11, Tls12, Ssl3" 40 | Write-Host "Successfully set SSL/TLS security protocol" 41 | } catch { 42 | Write-Host "Failed to set SSL/TLS security protocol" 43 | } 44 | 45 | Invoke-WebRequest -Uri $DownloadUrl -OutFile ( New-Item -Path "$AssetPath" -Force ) 46 | Expand-Archive -LiteralPath $AssetPath -DestinationPath $BinDir 47 | Remove-Item $AssetPath 48 | 49 | Write-Host "Successfully downloaded vim-doge-helper" 50 | -------------------------------------------------------------------------------- /scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # For more info about the 'set' command, see 4 | # https://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin 5 | set -e 6 | set -u 7 | 8 | if ! which curl > /dev/null 2>&1; then 9 | echo "curl: command not found" >&2 10 | echo 'Please make sure that curl is installed and available in your $PATH' >&2 11 | exit 127 12 | fi 13 | 14 | ROOT_DIR=$(cd "$(dirname "$0")/.."; pwd -P) 15 | INSTALL_DIR="${1:-$ROOT_DIR}" 16 | BIN_DIR="$INSTALL_DIR/bin" 17 | OUTFILE="$BIN_DIR/vim-doge-helper" 18 | 19 | echo "Installation path: $OUTFILE" 20 | 21 | cd "$ROOT_DIR" 22 | 23 | if [ -e "$OUTFILE" ]; then 24 | rm -f "$OUTFILE" 25 | fi 26 | 27 | [ ! -d $BIN_DIR ] && mkdir -p $BIN_DIR 28 | cd $BIN_DIR 29 | 30 | OS="$(uname)" 31 | ARCH="$(uname -m)" 32 | APP_VERSION=$(cat "$ROOT_DIR/.version") 33 | RELEASE_URL="https://github.com/kkoomen/vim-doge/releases/download/v$APP_VERSION" 34 | 35 | if [ $OS = 'Darwin' ]; then 36 | if [ $ARCH = 'arm64' ]; then 37 | TARGET="vim-doge-helper-macos-aarch64" 38 | else 39 | TARGET="vim-doge-helper-macos-x86_64" 40 | fi 41 | elif [ $OS = 'Linux' ]; then 42 | if [ $ARCH = 'aarch64' ]; then 43 | TARGET="vim-doge-helper-linux-aarch64" 44 | else 45 | TARGET="vim-doge-helper-linux-x86_64" 46 | fi 47 | else 48 | echo "vim-doge does not support your system" 49 | exit 1 50 | fi 51 | 52 | ARCHIVE_FILENAME="$TARGET.tar.gz" 53 | DOWNLOAD_URL="$RELEASE_URL/$ARCHIVE_FILENAME" 54 | echo "Downloading $DOWNLOAD_URL" 55 | curl -L --progress-bar --fail --output "$ARCHIVE_FILENAME" "$DOWNLOAD_URL" 56 | tar xzf "$ARCHIVE_FILENAME" 57 | rm -f "$ARCHIVE_FILENAME" 58 | chmod +x "$OUTFILE" 59 | -------------------------------------------------------------------------------- /scripts/release.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # For more info about the 'set' command, see 4 | # https://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin 5 | set -e 6 | set -u 7 | 8 | if [[ -n $(git status -s) ]]; then 9 | echo "There are uncommitted changes in the current directory, please commit them first." 10 | exit 1 11 | fi 12 | 13 | current_version="$(cat helper/Cargo.toml | grep -E '^version = \"[0-9]+\.[0-9]+\.[0-9]+\"$' | sed -E 's/version = \"([0-9]+\.[0-9]+\.[0-9]+)\"/\1/g')" 14 | 15 | echo "Current version: $current_version" 16 | read -p "Enter the next version (format: X.X.X): " next_version 17 | 18 | current_branch="$(git rev-parse --abbrev-ref HEAD)" 19 | release_branch="release/v$next_version" 20 | if [[ "$current_branch" != "$release_branch" ]]; then 21 | echo "Checking out to $release_branch" 22 | git checkout -b release/v$next_version 23 | fi 24 | 25 | echo "$next_version" > .version 26 | 27 | # Replace the current version in helper/Cargo.toml with the new version. 28 | sed -E -i '' "s/^version = \"[0-9]+\.[0-9]+\.[0-9]+\"$/version = \"$next_version\"/" helper/Cargo.toml 29 | 30 | # Trigger a build so that the version will be applied to the Cargo.lock as well. 31 | cd helper 32 | cargo build 33 | cd .. 34 | 35 | # Run vimdoc if it's installed to make sure all documentation is generated. 36 | if command -v vimdoc >/dev/null 2>&1; then 37 | echo "Running vimdoc..." 38 | vimdoc . 39 | fi 40 | 41 | git diff .version helper/Cargo.toml helper/Cargo.lock doc/doge.txt 42 | 43 | echo "Committing the above changes..." 44 | git add .version helper/Cargo.toml helper/Cargo.lock doc/doge.txt 45 | git commit -m "chore(release): v$next_version :tada:" 46 | 47 | echo "Done, make sure to push the above changes." 48 | -------------------------------------------------------------------------------- /scripts/run-vader-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # For more info about the 'set' command, see 4 | # https://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin 5 | set -e 6 | set -u 7 | 8 | ROOT_DIR=$(cd "$(dirname "$0")/.."; pwd -P) 9 | 10 | vim="$1" 11 | tests=${2:-"$ROOT_DIR/test/*.vader $ROOT_DIR/test/commands/*.vader $ROOT_DIR/test/options/*.vader $ROOT_DIR/test/filetypes/*/*.vader"} 12 | 13 | red='\033[0;31m' 14 | green='\033[0;32m' 15 | blue='\033[0;34m' 16 | nc='\033[0m' 17 | 18 | run_file="$(mktemp)" 19 | 20 | function filter-vader-output() { 21 | local hit_first_vader_line=0 22 | local force_echo=0 23 | 24 | while read -r; do 25 | # Search for the first Vader output line. 26 | if ((!hit_first_vader_line)); then 27 | if [[ "$REPLY" = *'Starting Vader:'* ]]; then 28 | hit_first_vader_line=1 29 | else 30 | continue; 31 | fi 32 | fi 33 | 34 | # If an error occured, make sure to print it. 35 | if [[ "$REPLY" = *'Expected:'* ]]; then 36 | force_echo=1 37 | elif [[ "$REPLY" =~ \[[A-Z\ ]+\] ]]; then 38 | force_echo=0 39 | fi 40 | 41 | if [[ "$REPLY" =~ \[[A-Z\ ]+\] ]] \ 42 | || [[ "$REPLY" = *'Starting Vader:'* ]] \ 43 | || [[ "$REPLY" = *'Success/Total'* ]] \ 44 | || [[ "$REPLY" = *'Elapsed time:'* ]] \ 45 | || [[ $force_echo = 1 ]] 46 | then 47 | echo "$REPLY" 48 | fi 49 | done 50 | 51 | # Echo a 1 into the temp file to indicate this (re)try is successful. 52 | if ((hit_first_vader_line)); then 53 | echo 1 > "$run_file" 54 | fi 55 | } 56 | 57 | function color-vader-output() { 58 | while read -r; do 59 | # Split blocks by echoing an extra white line. 60 | if [[ "$REPLY" = *'GIVEN'* ]] || [[ "$REPLY" = *'EXECUTE'* ]]; then 61 | echo 62 | fi 63 | 64 | if [[ "$REPLY" = *'(X)'* ]]; then 65 | echo -en "$red" 66 | elif [[ "$REPLY" = *'Starting Vader:'* ]]; then 67 | echo -en "$blue" 68 | else 69 | echo -en "$nc" 70 | fi 71 | 72 | if [[ "$REPLY" = *'Success/Total'* ]]; then 73 | echo 74 | 75 | success="$(echo -n "$REPLY" | grep -o '[0-9]\+/' | head -n 1 | cut -d / -f 1)" 76 | total="$(echo -n "$REPLY" | grep -o '/[0-9]\+' | head -n 1 | cut -d / -f 2)" 77 | 78 | if [ "$success" -lt "$total" ]; then 79 | echo -en "$red" 80 | else 81 | echo -en "$green" 82 | fi 83 | 84 | echo "$REPLY" 85 | echo -en "$nc" 86 | echo 87 | else 88 | echo "$REPLY" 89 | fi 90 | done 91 | 92 | echo -en "$nc" 93 | } 94 | 95 | echo 96 | echo '================================================================================' 97 | echo "Running tests for $vim" 98 | echo '================================================================================' 99 | echo 100 | 101 | max_retries=5 102 | tries=0 103 | exit_code=0 104 | 105 | while [ "$tries" -lt $max_retries ]; do 106 | tries=$((tries + 1)) 107 | echo "($tries/$max_retries) Trying to run tests..." 108 | 109 | set -o pipefail 110 | 111 | "$vim" -u $ROOT_DIR/test/vimrc "+Vader! $tests" 2>&1 | filter-vader-output | color-vader-output || exit_code=$? 112 | 113 | set +o pipefail 114 | 115 | if [ -s "$run_file" ]; then 116 | break 117 | fi 118 | done 119 | 120 | if [ "$tries" -gt 1 ]; then 121 | echo 122 | echo "Tried to run tests $tries times" 123 | fi 124 | 125 | rm "$run_file" 126 | 127 | echo "vim-doge exited with status code $exit_code" 128 | exit "$exit_code" 129 | -------------------------------------------------------------------------------- /test/commands/generate.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # 3 | # Test the DogeGenerate command 4 | # 5 | # ============================================================================== 6 | 7 | # ============================================================================== 8 | # Test the C doxygen_javadoc style doc standard generation. 9 | # ============================================================================== 10 | Given c (functions with x and y parameters): 11 | int testA(int x, int y) {} 12 | 13 | int testB(int x, int y) {} 14 | 15 | Do (trigger 'DogeGenerate doxygen_javadoc' and 'DogeGenerate 3'): 16 | # Test by name 17 | :DogeGenerate doxygen_javadoc\ 18 | 19 | # Test by index 20 | :10\ 21 | :DogeGenerate 1\ 22 | 23 | Expect c (generated comments): 24 | /** 25 | * @brief [TODO:summary] 26 | * 27 | * @param[[TODO:direction]] x [TODO:description] 28 | * @param[[TODO:direction]] y [TODO:description] 29 | * @return [TODO:description] 30 | */ 31 | int testA(int x, int y) {} 32 | 33 | /** 34 | * @brief [TODO:summary] 35 | * 36 | * @param[[TODO:direction]] x [TODO:description] 37 | * @param[[TODO:direction]] y [TODO:description] 38 | * @return [TODO:description] 39 | */ 40 | int testB(int x, int y) {} 41 | 42 | # ============================================================================== 43 | # Test the C kernel doc standard generation. 44 | # ============================================================================== 45 | Given c (functions with x and y parameters): 46 | int testA(int x, int y) {} 47 | 48 | int testB(int x, int y) {} 49 | 50 | Do (trigger 'DogeGenerate doxygen_javadoc' and 'DogeGenerate 3'): 51 | # Test by name 52 | :DogeGenerate kernel_doc\ 53 | 54 | # Test by index 55 | :12\ 56 | :DogeGenerate 6\ 57 | 58 | Expect c (generated comments): 59 | /** 60 | * testA(): [TODO:summary] 61 | * @x: [TODO:description] 62 | * @y: [TODO:description] 63 | * 64 | * [TODO:long description] 65 | * 66 | * Return: [TODO:description] 67 | */ 68 | int testA(int x, int y) {} 69 | 70 | /** 71 | * testB(): [TODO:summary] 72 | * @x: [TODO:description] 73 | * @y: [TODO:description] 74 | * 75 | * [TODO:long description] 76 | * 77 | * Return: [TODO:description] 78 | */ 79 | int testB(int x, int y) {} 80 | -------------------------------------------------------------------------------- /test/filetypes/c/function-declarations.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function declarations with parameters. 3 | # ============================================================================== 4 | Given c (function declaration with parameters): 5 | int add(int x, int y); 6 | 7 | Do (trigger doge): 8 | \ 9 | 10 | Expect c (generated comment with @brief, @param and @return tags): 11 | /** 12 | * @brief [TODO:summary] 13 | * 14 | * @param[[TODO:direction]] x [TODO:description] 15 | * @param[[TODO:direction]] y [TODO:description] 16 | * @return [TODO:description] 17 | */ 18 | int add(int x, int y); 19 | -------------------------------------------------------------------------------- /test/filetypes/c/functions-doc-cpp-exclamation.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function definitions with parameters with return type. 3 | # ============================================================================== 4 | Given c (function definition with parameters with return type): 5 | int add(int x, int y) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_cpp_comment_exclamation'\ 9 | \ 10 | 11 | Expect c (generated comment with @brief, @param and @return tags): 12 | //! 13 | //! @brief [TODO:summary] 14 | //! 15 | //! @param[[TODO:direction]] x [TODO:description] 16 | //! @param[[TODO:direction]] y [TODO:description] 17 | //! @return [TODO:description] 18 | //! 19 | int add(int x, int y) {} 20 | 21 | # ============================================================================== 22 | # Function definitions with parameters with 'void' return type. 23 | # ============================================================================== 24 | Given c (function definition with parameters with 'void' return type): 25 | void add(int x, int y) {} 26 | 27 | Do (trigger doge): 28 | :let b:doge_doc_standard='doxygen_cpp_comment_exclamation'\ 29 | \ 30 | 31 | Expect c (generated comment with @brief and @param tags): 32 | //! 33 | //! @brief [TODO:summary] 34 | //! 35 | //! @param[[TODO:direction]] x [TODO:description] 36 | //! @param[[TODO:direction]] y [TODO:description] 37 | //! 38 | void add(int x, int y) {} 39 | -------------------------------------------------------------------------------- /test/filetypes/c/functions-doc-cpp-slash-banner.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function definitions with parameters with return type. 3 | # ============================================================================== 4 | Given c (function definition with parameters with return type): 5 | int add(int x, int y) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_cpp_comment_slash_banner'\ 9 | \ 10 | 11 | Expect c (generated comment with @brief, @param and @return tags): 12 | //////////////////////////////////////////////////////////////////////////////// 13 | /// @brief [TODO:summary] 14 | /// 15 | /// @param[[TODO:direction]] x [TODO:description] 16 | /// @param[[TODO:direction]] y [TODO:description] 17 | /// @return [TODO:description] 18 | //////////////////////////////////////////////////////////////////////////////// 19 | int add(int x, int y) {} 20 | 21 | # ============================================================================== 22 | # Function definitions with parameters with 'void' return type. 23 | # ============================================================================== 24 | Given c (function definition with parameters with 'void' return type): 25 | void add(int x, int y) {} 26 | 27 | Do (trigger doge): 28 | :let b:doge_doc_standard='doxygen_cpp_comment_slash_banner'\ 29 | \ 30 | 31 | Expect c (generated comment with @brief and @param tags): 32 | //////////////////////////////////////////////////////////////////////////////// 33 | /// @brief [TODO:summary] 34 | /// 35 | /// @param[[TODO:direction]] x [TODO:description] 36 | /// @param[[TODO:direction]] y [TODO:description] 37 | //////////////////////////////////////////////////////////////////////////////// 38 | void add(int x, int y) {} 39 | -------------------------------------------------------------------------------- /test/filetypes/c/functions-doc-cpp-slash.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function definitions with parameters with return type. 3 | # ============================================================================== 4 | Given c (function definition with parameters with return type): 5 | int add(int x, int y) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_cpp_comment_slash'\ 9 | \ 10 | 11 | Expect c (generated comment with @brief, @param and @return tags): 12 | /// 13 | /// @brief [TODO:summary] 14 | /// 15 | /// @param[[TODO:direction]] x [TODO:description] 16 | /// @param[[TODO:direction]] y [TODO:description] 17 | /// @return [TODO:description] 18 | /// 19 | int add(int x, int y) {} 20 | 21 | # ============================================================================== 22 | # Function definitions with parameters with 'void' return type. 23 | # ============================================================================== 24 | Given c (function definition with parameters with 'void' return type): 25 | void add(int x, int y) {} 26 | 27 | Do (trigger doge): 28 | :let b:doge_doc_standard='doxygen_cpp_comment_slash'\ 29 | \ 30 | 31 | Expect c (generated comment with @brief and @param tags): 32 | /// 33 | /// @brief [TODO:summary] 34 | /// 35 | /// @param[[TODO:direction]] x [TODO:description] 36 | /// @param[[TODO:direction]] y [TODO:description] 37 | /// 38 | void add(int x, int y) {} 39 | -------------------------------------------------------------------------------- /test/filetypes/c/functions-doc-javadoc-banner.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function definitions with parameters with return type. 3 | # ============================================================================== 4 | Given c (function definition with parameters with return type): 5 | int add(int x, int y) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_javadoc_banner'\ 9 | \ 10 | 11 | Expect c (generated comment with @brief, @param and @return tags): 12 | /******************************************************************************* 13 | * @brief [TODO:summary] 14 | * 15 | * @param[[TODO:direction]] x [TODO:description] 16 | * @param[[TODO:direction]] y [TODO:description] 17 | * @return [TODO:description] 18 | ******************************************************************************/ 19 | int add(int x, int y) {} 20 | 21 | # ============================================================================== 22 | # Function definitions with parameters with 'void' return type. 23 | # ============================================================================== 24 | Given c (function definition with parameters with 'void' return type): 25 | void add(int x, int y) {} 26 | 27 | Do (trigger doge): 28 | :let b:doge_doc_standard='doxygen_javadoc_banner'\ 29 | \ 30 | 31 | Expect c (generated comment with @brief and @param tags): 32 | /******************************************************************************* 33 | * @brief [TODO:summary] 34 | * 35 | * @param[[TODO:direction]] x [TODO:description] 36 | * @param[[TODO:direction]] y [TODO:description] 37 | ******************************************************************************/ 38 | void add(int x, int y) {} 39 | -------------------------------------------------------------------------------- /test/filetypes/c/functions-doc-javadoc-no-asterisk.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function definitions with parameters with return type. 3 | # ============================================================================== 4 | Given c (function definition with parameters with return type): 5 | int add(int x, int y) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_javadoc_no_asterisk'\ 9 | \ 10 | 11 | Expect c (generated comment with @brief, @param and @return tags): 12 | /** 13 | @brief [TODO:summary] 14 | 15 | @param[[TODO:direction]] x [TODO:description] 16 | @param[[TODO:direction]] y [TODO:description] 17 | @return [TODO:description] 18 | */ 19 | int add(int x, int y) {} 20 | 21 | # ============================================================================== 22 | # Function definitions with parameters with 'void' return type. 23 | # ============================================================================== 24 | Given c (function definition with parameters with 'void' return type): 25 | void add(int x, int y) {} 26 | 27 | Do (trigger doge): 28 | :let b:doge_doc_standard='doxygen_javadoc_no_asterisk'\ 29 | \ 30 | 31 | Expect c (generated comment with @brief and @param tags): 32 | /** 33 | @brief [TODO:summary] 34 | 35 | @param[[TODO:direction]] x [TODO:description] 36 | @param[[TODO:direction]] y [TODO:description] 37 | */ 38 | void add(int x, int y) {} 39 | -------------------------------------------------------------------------------- /test/filetypes/c/functions-doc-qt-no-asterisk.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function definitions with parameters with return type. 3 | # ============================================================================== 4 | Given c (function definition with parameters with return type): 5 | int add(int x, int y) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_qt_no_asterisk'\ 9 | \ 10 | 11 | Expect c (generated comment with @brief, @param and @return tags): 12 | /*! 13 | @brief [TODO:summary] 14 | 15 | @param[[TODO:direction]] x [TODO:description] 16 | @param[[TODO:direction]] y [TODO:description] 17 | @return [TODO:description] 18 | */ 19 | int add(int x, int y) {} 20 | 21 | # ============================================================================== 22 | # Function definitions with parameters with 'void' return type. 23 | # ============================================================================== 24 | Given c (function definition with parameters with 'void' return type): 25 | void add(int x, int y) {} 26 | 27 | Do (trigger doge): 28 | :let b:doge_doc_standard='doxygen_qt_no_asterisk'\ 29 | \ 30 | 31 | Expect c (generated comment with @brief and @param tags): 32 | /*! 33 | @brief [TODO:summary] 34 | 35 | @param[[TODO:direction]] x [TODO:description] 36 | @param[[TODO:direction]] y [TODO:description] 37 | */ 38 | void add(int x, int y) {} 39 | -------------------------------------------------------------------------------- /test/filetypes/c/functions-doc-qt.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function definitions with parameters with return type. 3 | # ============================================================================== 4 | Given c (function definition with parameters with return type): 5 | int add(int x, int y) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_qt'\ 9 | \ 10 | 11 | Expect c (generated comment with @brief, @param and @return tags): 12 | /*! 13 | * @brief [TODO:summary] 14 | * 15 | * @param[[TODO:direction]] x [TODO:description] 16 | * @param[[TODO:direction]] y [TODO:description] 17 | * @return [TODO:description] 18 | */ 19 | int add(int x, int y) {} 20 | 21 | # ============================================================================== 22 | # Function definitions with parameters with 'void' return type. 23 | # ============================================================================== 24 | Given c (function definition with parameters with 'void' return type): 25 | void add(int x, int y) {} 26 | 27 | Do (trigger doge): 28 | :let b:doge_doc_standard='doxygen_qt'\ 29 | \ 30 | 31 | Expect c (generated comment with @brief and @param tags): 32 | /*! 33 | * @brief [TODO:summary] 34 | * 35 | * @param[[TODO:direction]] x [TODO:description] 36 | * @param[[TODO:direction]] y [TODO:description] 37 | */ 38 | void add(int x, int y) {} 39 | -------------------------------------------------------------------------------- /test/filetypes/c/functions-kernel-doc.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function definitions with parameters with return type. 3 | # ============================================================================== 4 | Given c (function definition and declaration with parameters with return type): 5 | int add(int x, int y) {} 6 | 7 | int add(int x, int y); 8 | 9 | int (*add2)(int x, int y); 10 | 11 | 12 | Do (trigger doge): 13 | :let b:doge_doc_standard='kernel_doc'\ 14 | \ 15 | :12\ 16 | \ 17 | :23\ 18 | \ 19 | 20 | Expect c (generated comment with the function name, all parameter tags, a description and a 'Return' keyword): 21 | /** 22 | * add(): [TODO:summary] 23 | * @x: [TODO:description] 24 | * @y: [TODO:description] 25 | * 26 | * [TODO:long description] 27 | * 28 | * Return: [TODO:description] 29 | */ 30 | int add(int x, int y) {} 31 | 32 | /** 33 | * add(): [TODO:summary] 34 | * @x: [TODO:description] 35 | * @y: [TODO:description] 36 | * 37 | * [TODO:long description] 38 | * 39 | * Return: [TODO:description] 40 | */ 41 | int add(int x, int y); 42 | 43 | /** 44 | * add2(): [TODO:summary] 45 | * @x: [TODO:description] 46 | * @y: [TODO:description] 47 | * 48 | * [TODO:long description] 49 | * 50 | * Return: [TODO:description] 51 | */ 52 | int (*add2)(int x, int y); 53 | 54 | # ============================================================================== 55 | # Function definitions with parameters with 'void' return type. 56 | # ============================================================================== 57 | Given c (function definition and declaration with parameters with 'void' return type): 58 | void add(int x, int y) {} 59 | 60 | void add(int x, int y); 61 | 62 | Do (trigger doge): 63 | :let b:doge_doc_standard='kernel_doc'\ 64 | \ 65 | :10\ 66 | \ 67 | 68 | Expect c (generated comment with the function name, all parameter tags, and a description): 69 | /** 70 | * add(): [TODO:summary] 71 | * @x: [TODO:description] 72 | * @y: [TODO:description] 73 | * 74 | * [TODO:long description] 75 | */ 76 | void add(int x, int y) {} 77 | 78 | /** 79 | * add(): [TODO:summary] 80 | * @x: [TODO:description] 81 | * @y: [TODO:description] 82 | * 83 | * [TODO:long description] 84 | */ 85 | void add(int x, int y); 86 | 87 | # ============================================================================== 88 | # Function definitions with parameters with 'void' return type. 89 | # ============================================================================== 90 | Given c (struct with fields): 91 | struct foo { 92 | int bar; 93 | } 94 | 95 | Do (trigger doge): 96 | :let b:doge_doc_standard='kernel_doc'\ 97 | \ 98 | :5\ 99 | \ 100 | 101 | Expect c (generated comments for the struct and the fields): 102 | /** 103 | * struct foo - [TODO:description] 104 | */ 105 | struct foo { 106 | /** 107 | * @bar: [TODO:description] 108 | */ 109 | int bar; 110 | } 111 | -------------------------------------------------------------------------------- /test/filetypes/c/functions.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function definition with parameters. 3 | # ============================================================================== 4 | Given c (function definition with parameters): 5 | void bar(void); 6 | 7 | int foo(int a, char b) {} 8 | 9 | int *foo(int a, char *b) {} 10 | 11 | Do (trigger doge): 12 | \ 13 | :6\ 14 | \ 15 | :15\ 16 | \ 17 | 18 | Expect c (generated comment with @brief, @param and @return tags): 19 | /** 20 | * @brief [TODO:summary] 21 | */ 22 | void bar(void); 23 | 24 | /** 25 | * @brief [TODO:summary] 26 | * 27 | * @param[[TODO:direction]] a [TODO:description] 28 | * @param[[TODO:direction]] b [TODO:description] 29 | * @return [TODO:description] 30 | */ 31 | int foo(int a, char b) {} 32 | 33 | /** 34 | * @brief [TODO:summary] 35 | * 36 | * @param[[TODO:direction]] a [TODO:description] 37 | * @param[[TODO:direction]] b [TODO:description] 38 | * @return [TODO:description] 39 | */ 40 | int *foo(int a, char *b) {} 41 | -------------------------------------------------------------------------------- /test/filetypes/c/structs.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Struct with childs 3 | # ============================================================================== 4 | Given c (struct with childs): 5 | struct foo { 6 | int bar; 7 | }; 8 | 9 | Do (trigger doge): 10 | \ 11 | :5\ 12 | \ 13 | 14 | Expect c (generated comments): 15 | /** 16 | * struct foo - [TODO:description] 17 | */ 18 | struct foo { 19 | /** 20 | * @bar [TODO:description] 21 | */ 22 | int bar; 23 | }; 24 | -------------------------------------------------------------------------------- /test/filetypes/cpp/auto-functions.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Auto-functions with parameters using return type 'auto' 3 | # ============================================================================== 4 | Given cpp (auto-function with parameters using return type 'auto'): 5 | template 6 | auto Person::getPersonType (const Builder& builder) -> PersonType 7 | { 8 | return _person_type; 9 | } 10 | 11 | Do (trigger doge): 12 | \ 13 | 14 | Expect cpp (generated comment with @brief, @tparam, @param and @return tags): 15 | /** 16 | * @brief [TODO:summary] 17 | * 18 | * @tparam F [TODO:description] 19 | * @tparam Args [TODO:description] 20 | * @param[[TODO:direction]] builder [TODO:description] 21 | * @return [TODO:description] 22 | */ 23 | template 24 | auto Person::getPersonType (const Builder& builder) -> PersonType 25 | { 26 | return _person_type; 27 | } 28 | 29 | # ============================================================================== 30 | # Auto-functions with parameters with type hints using return type 'auto' 31 | # ============================================================================== 32 | Given cpp (auto-function with parameters with advanced type hints using return type 'auto'): 33 | template< 34 | class T, 35 | class U 36 | > 37 | auto add(T t, U u) 38 | { 39 | // 40 | } 41 | 42 | Do (trigger doge): 43 | :5\ 44 | \ 45 | 46 | Expect cpp (generated comment with @brief, @tparam, @param and @return tags): 47 | /** 48 | * @brief [TODO:summary] 49 | * 50 | * @tparam T [TODO:description] 51 | * @tparam U [TODO:description] 52 | * @param[[TODO:direction]] t [TODO:description] 53 | * @param[[TODO:direction]] u [TODO:description] 54 | */ 55 | template< 56 | class T, 57 | class U 58 | > 59 | auto add(T t, U u) 60 | { 61 | // 62 | } 63 | -------------------------------------------------------------------------------- /test/filetypes/cpp/classes.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Class templates. 3 | # ============================================================================== 4 | Given cpp (class template): 5 | template 6 | class test 7 | { 8 | // 9 | }; 10 | 11 | Do (trigger doge): 12 | \ 13 | 14 | Expect cpp (generated comment with @brief, @tparam tags): 15 | /** 16 | * @brief [TODO:summary] 17 | * 18 | * @tparam Test [TODO:description] 19 | */ 20 | template 21 | class test 22 | { 23 | // 24 | }; 25 | -------------------------------------------------------------------------------- /test/filetypes/cpp/function-declarations.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function declarations with parameters. 3 | # ============================================================================== 4 | Given cpp (function declaration with parameters): 5 | void append_token(const std::string& text /* inline comment */, const AST_Node* node); 6 | 7 | Do (trigger doge): 8 | \ 9 | 10 | Expect cpp (generated comment with @param and @return tags): 11 | /** 12 | * @brief [TODO:summary] 13 | * 14 | * @param[[TODO:direction]] text [TODO:description] 15 | * @param[[TODO:direction]] node [TODO:description] 16 | */ 17 | void append_token(const std::string& text /* inline comment */, const AST_Node* node); 18 | -------------------------------------------------------------------------------- /test/filetypes/cpp/functions-doc-cpp-exclamation.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Functions without parameters. 3 | # ============================================================================== 4 | Given cpp (function without parameters with return type): 5 | int myFunc(/* inline comment */) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_cpp_comment_exclamation'\ 9 | \ 10 | 11 | Expect cpp (generated comment with nothing but @brief and @return tag): 12 | //! 13 | //! @brief [TODO:summary] 14 | //! 15 | //! @return [TODO:description] 16 | //! 17 | int myFunc(/* inline comment */) {} 18 | 19 | # ============================================================================== 20 | # Functions with parameters. 21 | # ============================================================================== 22 | Given cpp (function with parameters without return type): 23 | class TestClass { 24 | public: 25 | int myFunc(); 26 | }; 27 | 28 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 29 | 30 | Do (trigger doge): 31 | :let b:doge_doc_standard='doxygen_cpp_comment_exclamation'\ 32 | :8\ 33 | \ 34 | 35 | Expect cpp (generated comment with @brief, @param and @return tags): 36 | class TestClass { 37 | public: 38 | int myFunc(); 39 | }; 40 | 41 | //! 42 | //! @brief [TODO:summary] 43 | //! 44 | //! @param[[TODO:direction]] text [TODO:description] 45 | //! @param[[TODO:direction]] node [TODO:description] 46 | //! @return [TODO:description] 47 | //! 48 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 49 | 50 | # ============================================================================== 51 | # Functions with parameters with default values. 52 | # ============================================================================== 53 | Given cpp (function with parameters with default values with void return type): 54 | void f(A* p = this) {} 55 | 56 | Do (trigger doge): 57 | :let b:doge_doc_standard='doxygen_cpp_comment_exclamation'\ 58 | \ 59 | 60 | Expect cpp (generated comment with @brief and @param tag): 61 | //! 62 | //! @brief [TODO:summary] 63 | //! 64 | //! @param[[TODO:direction]] p [TODO:description] 65 | //! 66 | void f(A* p = this) {} 67 | -------------------------------------------------------------------------------- /test/filetypes/cpp/functions-doc-cpp-slash-banner.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Functions without parameters. 3 | # ============================================================================== 4 | Given cpp (function without parameters with return type): 5 | int myFunc(/* inline comment */) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_cpp_comment_slash_banner'\ 9 | \ 10 | 11 | Expect cpp (generated comment with nothing but @brief and @return tag): 12 | //////////////////////////////////////////////////////////////////////////////// 13 | /// @brief [TODO:summary] 14 | /// 15 | /// @return [TODO:description] 16 | //////////////////////////////////////////////////////////////////////////////// 17 | int myFunc(/* inline comment */) {} 18 | 19 | # ============================================================================== 20 | # Functions with parameters. 21 | # ============================================================================== 22 | Given cpp (function with parameters without return type): 23 | class TestClass { 24 | public: 25 | int myFunc(); 26 | }; 27 | 28 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 29 | 30 | Do (trigger doge): 31 | :let b:doge_doc_standard='doxygen_cpp_comment_slash_banner'\ 32 | :8\ 33 | \ 34 | 35 | Expect cpp (generated comment with @brief, @param and @return tags): 36 | class TestClass { 37 | public: 38 | int myFunc(); 39 | }; 40 | 41 | //////////////////////////////////////////////////////////////////////////////// 42 | /// @brief [TODO:summary] 43 | /// 44 | /// @param[[TODO:direction]] text [TODO:description] 45 | /// @param[[TODO:direction]] node [TODO:description] 46 | /// @return [TODO:description] 47 | //////////////////////////////////////////////////////////////////////////////// 48 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 49 | 50 | # ============================================================================== 51 | # Functions with parameters with default values. 52 | # ============================================================================== 53 | Given cpp (function with parameters with default values with void return type): 54 | void f(A* p = this) {} 55 | 56 | Do (trigger doge): 57 | :let b:doge_doc_standard='doxygen_cpp_comment_slash_banner'\ 58 | \ 59 | 60 | Expect cpp (generated comment with @brief and @param tag): 61 | //////////////////////////////////////////////////////////////////////////////// 62 | /// @brief [TODO:summary] 63 | /// 64 | /// @param[[TODO:direction]] p [TODO:description] 65 | //////////////////////////////////////////////////////////////////////////////// 66 | void f(A* p = this) {} 67 | -------------------------------------------------------------------------------- /test/filetypes/cpp/functions-doc-cpp-slash.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Functions without parameters. 3 | # ============================================================================== 4 | Given cpp (function without parameters with return type): 5 | int myFunc(/* inline comment */) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_cpp_comment_slash'\ 9 | \ 10 | 11 | Expect cpp (generated comment with nothing but @brief and @return tag): 12 | /// 13 | /// @brief [TODO:summary] 14 | /// 15 | /// @return [TODO:description] 16 | /// 17 | int myFunc(/* inline comment */) {} 18 | 19 | # ============================================================================== 20 | # Functions with parameters. 21 | # ============================================================================== 22 | Given cpp (function with parameters without return type): 23 | class TestClass { 24 | public: 25 | int myFunc(); 26 | }; 27 | 28 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 29 | 30 | Do (trigger doge): 31 | :let b:doge_doc_standard='doxygen_cpp_comment_slash'\ 32 | :8\ 33 | \ 34 | 35 | Expect cpp (generated comment with @brief, @param and @return tags): 36 | class TestClass { 37 | public: 38 | int myFunc(); 39 | }; 40 | 41 | /// 42 | /// @brief [TODO:summary] 43 | /// 44 | /// @param[[TODO:direction]] text [TODO:description] 45 | /// @param[[TODO:direction]] node [TODO:description] 46 | /// @return [TODO:description] 47 | /// 48 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 49 | 50 | # ============================================================================== 51 | # Functions with parameters with default values. 52 | # ============================================================================== 53 | Given cpp (function with parameters with default values with void return type): 54 | void f(A* p = this) {} 55 | 56 | Do (trigger doge): 57 | :let b:doge_doc_standard='doxygen_cpp_comment_slash'\ 58 | \ 59 | 60 | Expect cpp (generated comment with @brief and @param tag): 61 | /// 62 | /// @brief [TODO:summary] 63 | /// 64 | /// @param[[TODO:direction]] p [TODO:description] 65 | /// 66 | void f(A* p = this) {} 67 | -------------------------------------------------------------------------------- /test/filetypes/cpp/functions-doc-javadoc-banner.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Functions without parameters. 3 | # ============================================================================== 4 | Given cpp (function without parameters with return type): 5 | int myFunc(/* inline comment */) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_javadoc_banner'\ 9 | \ 10 | 11 | Expect cpp (generated comment with nothing but @brief and @return tag): 12 | /******************************************************************************* 13 | * @brief [TODO:summary] 14 | * 15 | * @return [TODO:description] 16 | ******************************************************************************/ 17 | int myFunc(/* inline comment */) {} 18 | 19 | # ============================================================================== 20 | # Functions with parameters. 21 | # ============================================================================== 22 | Given cpp (function with parameters without return type): 23 | class TestClass { 24 | public: 25 | int myFunc(); 26 | }; 27 | 28 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 29 | 30 | Do (trigger doge): 31 | :let b:doge_doc_standard='doxygen_javadoc_banner'\ 32 | :8\ 33 | \ 34 | 35 | Expect cpp (generated comment with @brief, @param and @return tags): 36 | class TestClass { 37 | public: 38 | int myFunc(); 39 | }; 40 | 41 | /******************************************************************************* 42 | * @brief [TODO:summary] 43 | * 44 | * @param[[TODO:direction]] text [TODO:description] 45 | * @param[[TODO:direction]] node [TODO:description] 46 | * @return [TODO:description] 47 | ******************************************************************************/ 48 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 49 | 50 | # ============================================================================== 51 | # Functions with parameters with default values. 52 | # ============================================================================== 53 | Given cpp (function with parameters with default values with void return type): 54 | void f(A* p = this) {} 55 | 56 | Do (trigger doge): 57 | :let b:doge_doc_standard='doxygen_javadoc_banner'\ 58 | \ 59 | 60 | Expect cpp (generated comment with @brief and @param tag): 61 | /******************************************************************************* 62 | * @brief [TODO:summary] 63 | * 64 | * @param[[TODO:direction]] p [TODO:description] 65 | ******************************************************************************/ 66 | void f(A* p = this) {} 67 | -------------------------------------------------------------------------------- /test/filetypes/cpp/functions-doc-javadoc-no-asterisk.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Functions without parameters. 3 | # ============================================================================== 4 | Given cpp (function without parameters with return type): 5 | int myFunc(/* inline comment */) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_javadoc_no_asterisk'\ 9 | \ 10 | 11 | Expect cpp (generated comment with nothing but @brief and @return tag): 12 | /** 13 | @brief [TODO:summary] 14 | 15 | @return [TODO:description] 16 | */ 17 | int myFunc(/* inline comment */) {} 18 | 19 | # ============================================================================== 20 | # Functions with parameters. 21 | # ============================================================================== 22 | Given cpp (function with parameters without return type): 23 | class TestClass { 24 | public: 25 | int myFunc(); 26 | }; 27 | 28 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 29 | 30 | Do (trigger doge): 31 | :let b:doge_doc_standard='doxygen_javadoc_no_asterisk'\ 32 | :8\ 33 | \ 34 | 35 | Expect cpp (generated comment with @brief, @param and @return tags): 36 | class TestClass { 37 | public: 38 | int myFunc(); 39 | }; 40 | 41 | /** 42 | @brief [TODO:summary] 43 | 44 | @param[[TODO:direction]] text [TODO:description] 45 | @param[[TODO:direction]] node [TODO:description] 46 | @return [TODO:description] 47 | */ 48 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 49 | 50 | # ============================================================================== 51 | # Functions with parameters with default values. 52 | # ============================================================================== 53 | Given cpp (function with parameters with default values with void return type): 54 | void f(A* p = this) {} 55 | 56 | Do (trigger doge): 57 | :let b:doge_doc_standard='doxygen_javadoc_no_asterisk'\ 58 | \ 59 | 60 | Expect cpp (generated comment with @brief and @param tag): 61 | /** 62 | @brief [TODO:summary] 63 | 64 | @param[[TODO:direction]] p [TODO:description] 65 | */ 66 | void f(A* p = this) {} 67 | -------------------------------------------------------------------------------- /test/filetypes/cpp/functions-doc-qt-no-asterisk.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Functions without parameters. 3 | # ============================================================================== 4 | Given cpp (function without parameters with return type): 5 | int myFunc(/* inline comment */) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_qt_no_asterisk'\ 9 | \ 10 | 11 | Expect cpp (generated comment with nothing but @brief and @return tag): 12 | /*! 13 | @brief [TODO:summary] 14 | 15 | @return [TODO:description] 16 | */ 17 | int myFunc(/* inline comment */) {} 18 | 19 | # ============================================================================== 20 | # Functions with parameters. 21 | # ============================================================================== 22 | Given cpp (function with parameters without return type): 23 | class TestClass { 24 | public: 25 | int myFunc(); 26 | }; 27 | 28 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 29 | 30 | Do (trigger doge): 31 | :let b:doge_doc_standard='doxygen_qt_no_asterisk'\ 32 | :8\ 33 | \ 34 | 35 | Expect cpp (generated comment with @brief, @param and @return tags): 36 | class TestClass { 37 | public: 38 | int myFunc(); 39 | }; 40 | 41 | /*! 42 | @brief [TODO:summary] 43 | 44 | @param[[TODO:direction]] text [TODO:description] 45 | @param[[TODO:direction]] node [TODO:description] 46 | @return [TODO:description] 47 | */ 48 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 49 | 50 | # ============================================================================== 51 | # Functions with parameters with default values. 52 | # ============================================================================== 53 | Given cpp (function with parameters with default values with void return type): 54 | void f(A* p = this) {} 55 | 56 | Do (trigger doge): 57 | :let b:doge_doc_standard='doxygen_qt_no_asterisk'\ 58 | \ 59 | 60 | Expect cpp (generated comment with @brief and @param tag): 61 | /*! 62 | @brief [TODO:summary] 63 | 64 | @param[[TODO:direction]] p [TODO:description] 65 | */ 66 | void f(A* p = this) {} 67 | -------------------------------------------------------------------------------- /test/filetypes/cpp/functions-doc-qt.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Functions without parameters. 3 | # ============================================================================== 4 | Given cpp (function without parameters with return type): 5 | int myFunc(/* inline comment */) {} 6 | 7 | Do (trigger doge): 8 | :let b:doge_doc_standard='doxygen_qt'\ 9 | \ 10 | 11 | Expect cpp (generated comment with nothing but @brief and @return tag): 12 | /*! 13 | * @brief [TODO:summary] 14 | * 15 | * @return [TODO:description] 16 | */ 17 | int myFunc(/* inline comment */) {} 18 | 19 | # ============================================================================== 20 | # Functions with parameters. 21 | # ============================================================================== 22 | Given cpp (function with parameters without return type): 23 | class TestClass { 24 | public: 25 | int myFunc(); 26 | }; 27 | 28 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 29 | 30 | Do (trigger doge): 31 | :let b:doge_doc_standard='doxygen_qt'\ 32 | :8\ 33 | \ 34 | 35 | Expect cpp (generated comment with @brief, @param and @return tags): 36 | class TestClass { 37 | public: 38 | int myFunc(); 39 | }; 40 | 41 | /*! 42 | * @brief [TODO:summary] 43 | * 44 | * @param[[TODO:direction]] text [TODO:description] 45 | * @param[[TODO:direction]] node [TODO:description] 46 | * @return [TODO:description] 47 | */ 48 | int TestClass::myFunc(const std::string& text /* inline comment */, const Node* node) {} 49 | 50 | # ============================================================================== 51 | # Functions with parameters with default values. 52 | # ============================================================================== 53 | Given cpp (function with parameters with default values with void return type): 54 | void f(A* p = this) {} 55 | 56 | Do (trigger doge): 57 | :let b:doge_doc_standard='doxygen_qt'\ 58 | \ 59 | 60 | Expect cpp (generated comment with @brief and @param tag): 61 | /*! 62 | * @brief [TODO:summary] 63 | * 64 | * @param[[TODO:direction]] p [TODO:description] 65 | */ 66 | void f(A* p = this) {} 67 | -------------------------------------------------------------------------------- /test/filetypes/cpp/inline-functions.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Inline functions with parameters with return type. 3 | # ============================================================================== 4 | Given cpp (inline function with parameters with return type): 5 | inline bool operator<(const value_t lhs, const value_t rhs) noexcept {} 6 | 7 | Do (trigger doge): 8 | \ 9 | 10 | Expect cpp (generated comment with @brief, @param and @return tags): 11 | /** 12 | * @brief [TODO:summary] 13 | * 14 | * @param[[TODO:direction]] lhs [TODO:description] 15 | * @param[[TODO:direction]] rhs [TODO:description] 16 | * @return [TODO:description] 17 | */ 18 | inline bool operator<(const value_t lhs, const value_t rhs) noexcept {} 19 | -------------------------------------------------------------------------------- /test/filetypes/cpp/structs.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Struct with childs 3 | # ============================================================================== 4 | Given cpp (struct with childs): 5 | struct foo { 6 | int bar; 7 | }; 8 | 9 | Do (trigger doge): 10 | \ 11 | :5\ 12 | \ 13 | 14 | Expect cpp (generated comments): 15 | /** 16 | * struct foo - [TODO:description] 17 | */ 18 | struct foo { 19 | /** 20 | * @bar [TODO:description] 21 | */ 22 | int bar; 23 | }; 24 | -------------------------------------------------------------------------------- /test/filetypes/cpp/virtual-functions.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Virtual function declarations with parameters with return type. 3 | # ============================================================================== 4 | Given cpp (virtual function declarations with parameters with return type): 5 | class Test { 6 | virtual bool my_virtual_function(bool val); 7 | virtual bool my_pure_virtual_function(bool val) = 0; 8 | }; 9 | 10 | class Test2: public Test { 11 | bool my_virtual_function(bool val) override; 12 | bool my_pure_virtual_function(bool val) final; 13 | }; 14 | 15 | Do (trigger doge): 16 | :2\ 17 | \ 18 | :9\ 19 | \ 20 | :19\ 21 | \ 22 | :26\ 23 | \ 24 | 25 | Expect cpp (generated comment with @brief, @param and @return tags): 26 | class Test { 27 | /** 28 | * @brief [TODO:summary] 29 | * 30 | * @param[[TODO:direction]] val [TODO:description] 31 | * @return [TODO:description] 32 | */ 33 | virtual bool my_virtual_function(bool val); 34 | /** 35 | * @brief [TODO:summary] 36 | * 37 | * @param[[TODO:direction]] val [TODO:description] 38 | * @return [TODO:description] 39 | */ 40 | virtual bool my_pure_virtual_function(bool val) = 0; 41 | }; 42 | 43 | class Test2: public Test { 44 | /** 45 | * @brief [TODO:summary] 46 | * 47 | * @param[[TODO:direction]] val [TODO:description] 48 | * @return [TODO:description] 49 | */ 50 | bool my_virtual_function(bool val) override; 51 | /** 52 | * @brief [TODO:summary] 53 | * 54 | * @param[[TODO:direction]] val [TODO:description] 55 | * @return [TODO:description] 56 | */ 57 | bool my_pure_virtual_function(bool val) final; 58 | }; 59 | 60 | # ============================================================================== 61 | # Virtual function definitions with parameters with return type. 62 | # ============================================================================== 63 | Given cpp (virtual function definitions with parameters with return type): 64 | class base { 65 | public: 66 | bool fun_1(bool val) { cout << "base-1\n"; } 67 | }; 68 | 69 | class derived : public base { 70 | public: 71 | bool fun_1(bool val) { cout << "derived-1\n"; } 72 | }; 73 | 74 | Do (trigger doge): 75 | :3\ 76 | \ 77 | :14\ 78 | \ 79 | 80 | Expect cpp (generated comment with @brief, @param and @return tags): 81 | class base { 82 | public: 83 | /** 84 | * @brief [TODO:summary] 85 | * 86 | * @param[[TODO:direction]] val [TODO:description] 87 | * @return [TODO:description] 88 | */ 89 | bool fun_1(bool val) { cout << "base-1\n"; } 90 | }; 91 | 92 | class derived : public base { 93 | public: 94 | /** 95 | * @brief [TODO:summary] 96 | * 97 | * @param[[TODO:direction]] val [TODO:description] 98 | * @return [TODO:description] 99 | */ 100 | bool fun_1(bool val) { cout << "derived-1\n"; } 101 | }; 102 | -------------------------------------------------------------------------------- /test/filetypes/cs/class-constructor.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Construcor without params 3 | # ============================================================================== 4 | Given cs (constructor without params): 5 | public class MyClass 6 | { 7 | public MyClass() 8 | { 9 | } 10 | } 11 | 12 | Do (run doge): 13 | :3\ 14 | \ 15 | 16 | Expect cs (constructor with summary only): 17 | public class MyClass 18 | { 19 | /// 20 | /// [TODO:description] 21 | /// 22 | public MyClass() 23 | { 24 | } 25 | } 26 | 27 | # ============================================================================== 28 | # Constructor with params 29 | # ============================================================================== 30 | Given cs (constructor without params): 31 | public class MyClass 32 | { 33 | public MyClass(string arg1, MyClass arg2) 34 | { 35 | } 36 | } 37 | 38 | Do (run doge): 39 | :3\ 40 | \ 41 | 42 | Expect cs (constructor with summary only): 43 | public class MyClass 44 | { 45 | /// 46 | /// [TODO:description] 47 | /// 48 | /// [TODO:description] 49 | /// [TODO:description] 50 | public MyClass(string arg1, MyClass arg2) 51 | { 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /test/filetypes/cs/class-members.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Class constant 3 | # ============================================================================== 4 | Given cs (class constant): 5 | public class MyClass 6 | { 7 | public const doule PI = 3.14; 8 | } 9 | 10 | Do (run doge): 11 | :3\ 12 | \ 13 | 14 | Expect cs (class constant with summary block): 15 | public class MyClass 16 | { 17 | /// 18 | /// [TODO:description] 19 | /// 20 | public const doule PI = 3.14; 21 | } 22 | 23 | # ============================================================================== 24 | # Class variable 25 | # ============================================================================== 26 | Given cs (class variable): 27 | public class MyClass 28 | { 29 | public int one = 1; 30 | } 31 | 32 | Do (run doge): 33 | :3\ 34 | \ 35 | 36 | Expect cs (class variable with summary block): 37 | public class MyClass 38 | { 39 | /// 40 | /// [TODO:description] 41 | /// 42 | public int one = 1; 43 | } 44 | 45 | # ============================================================================== 46 | # Class property 47 | # ============================================================================== 48 | Given cs (class propery): 49 | public class MyClass 50 | { 51 | public string Prop 52 | { 53 | get 54 | { 55 | return "catch me if you can"; 56 | } 57 | } 58 | } 59 | 60 | Do (run doge): 61 | :3\ 62 | \ 63 | 64 | Expect cs (class property with summary block): 65 | public class MyClass 66 | { 67 | /// 68 | /// [TODO:description] 69 | /// 70 | public string Prop 71 | { 72 | get 73 | { 74 | return "catch me if you can"; 75 | } 76 | } 77 | } 78 | 79 | # ============================================================================== 80 | # Class property (setter) 81 | # ============================================================================== 82 | Given cs (class propery with setter): 83 | public class MyClass 84 | { 85 | public string Prop 86 | { 87 | get 88 | { 89 | return "catch me if you can"; 90 | } 91 | set 92 | { 93 | } 94 | } 95 | } 96 | 97 | Do (run doge): 98 | :3\ 99 | \ 100 | 101 | Expect cs (class property with setter with summary block): 102 | public class MyClass 103 | { 104 | /// 105 | /// [TODO:description] 106 | /// 107 | public string Prop 108 | { 109 | get 110 | { 111 | return "catch me if you can"; 112 | } 113 | set 114 | { 115 | } 116 | } 117 | } 118 | 119 | # ============================================================================== 120 | # Class event 121 | # ============================================================================== 122 | Given cs (class event): 123 | public class MyClass 124 | { 125 | public event Del EventHappened; 126 | } 127 | 128 | Do (run doge): 129 | :3\ 130 | \ 131 | 132 | Expect cs (class event with summary block): 133 | public class MyClass 134 | { 135 | /// 136 | /// [TODO:description] 137 | /// 138 | public event Del EventHappened; 139 | } 140 | -------------------------------------------------------------------------------- /test/filetypes/cs/class.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Plain Class 3 | # ============================================================================== 4 | Given cs (plain class): 5 | public class Myclass 6 | { 7 | } 8 | 9 | Do (run doge): 10 | \ 11 | 12 | Expect cs (plain class with summary): 13 | /// 14 | /// [TODO:description] 15 | /// 16 | public class Myclass 17 | { 18 | } 19 | 20 | # ============================================================================== 21 | # Nested Class 22 | # ============================================================================== 23 | Given cs (plain class): 24 | public class Myclass 25 | { 26 | private class SubClass 27 | { 28 | } 29 | } 30 | 31 | Do (run doge): 32 | :3\ 33 | \ 34 | 35 | Expect cs (plain class with summary): 36 | public class Myclass 37 | { 38 | /// 39 | /// [TODO:description] 40 | /// 41 | private class SubClass 42 | { 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /test/filetypes/cs/enum.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Enum 3 | # ============================================================================== 4 | Given cs (enum): 5 | public enum TestEnum 6 | { 7 | One, 8 | Two, 9 | Three 10 | } 11 | 12 | Do (trigger doge): 13 | \ 14 | 15 | Expect cs (enum with summary): 16 | /// 17 | /// [TODO:description] 18 | /// 19 | public enum TestEnum 20 | { 21 | One, 22 | Two, 23 | Three 24 | } 25 | -------------------------------------------------------------------------------- /test/filetypes/groovy/class-methods.vader: -------------------------------------------------------------------------------- 1 | # Groovy tests should be equal to groovy tests. 2 | 3 | # ============================================================================== 4 | # Method without parameters. 5 | # ============================================================================== 6 | Given groovy (method without parameters): 7 | class Test { 8 | List createSortedList() {} 9 | 10 | void foo(); 11 | } 12 | 13 | Do (trigger doge): 14 | :2\ 15 | \ 16 | :9\ 17 | \ 18 | 19 | Expect groovy (method with 'TODO' and a @return tag): 20 | class Test { 21 | /** 22 | * [TODO:description] 23 | * 24 | * @return [TODO:description] 25 | */ 26 | List createSortedList() {} 27 | 28 | /** 29 | * [TODO:description] 30 | */ 31 | void foo(); 32 | } 33 | 34 | # ============================================================================== 35 | # Methods with parameters. 36 | # ============================================================================== 37 | Given groovy (methods with parameters): 38 | class Test { 39 | private static MstRelation MyParameterizedMethod(String p1, int p2, Boolean ...params) throws IOException, IndexOutOfBoundsException {} 40 | 41 | ListResultBean MyParameterizedMethod(String p1, int p2, Boolean... params) {} 42 | } 43 | 44 | Do (trigger doge): 45 | :2\ 46 | \ 47 | :16\ 48 | \ 49 | 50 | Expect groovy (generated comments with @param and @return tags): 51 | class Test { 52 | /** 53 | * [TODO:description] 54 | * 55 | * @param p1 [TODO:description] 56 | * @param p2 [TODO:description] 57 | * @param params [TODO:description] 58 | * 59 | * @return [TODO:description] 60 | * 61 | * @throws IOException [TODO:description] 62 | * @throws IndexOutOfBoundsException [TODO:description] 63 | */ 64 | private static MstRelation MyParameterizedMethod(String p1, int p2, Boolean ...params) throws IOException, IndexOutOfBoundsException {} 65 | 66 | /** 67 | * [TODO:description] 68 | * 69 | * @param p1 [TODO:description] 70 | * @param p2 [TODO:description] 71 | * @param params [TODO:description] 72 | * 73 | * @return [TODO:description] 74 | */ 75 | ListResultBean MyParameterizedMethod(String p1, int p2, Boolean... params) {} 76 | } 77 | 78 | # ============================================================================== 79 | # Methods with parameters. 80 | # ============================================================================== 81 | Given groovy (methods with parameters with '@Override'): 82 | class Test { 83 | @Override 84 | protected void MyParameterizedMethod(String p1, int p2) {} 85 | } 86 | 87 | Do (trigger doge): 88 | :2\ 89 | \ 90 | 91 | Expect groovy (generated comments with @param and @return tags inserted above the '@Override'): 92 | class Test { 93 | /** 94 | * [TODO:description] 95 | * 96 | * @param p1 [TODO:description] 97 | * @param p2 [TODO:description] 98 | */ 99 | @Override 100 | protected void MyParameterizedMethod(String p1, int p2) {} 101 | } 102 | -------------------------------------------------------------------------------- /test/filetypes/html/script-element.vader: -------------------------------------------------------------------------------- 1 | Given html (html5 doc with multiple script elements): 2 | 3 | 4 | 5 | Test 6 | 7 | 8 | 9 | 14 | 15 | 16 | 17 | Do (trigger doge): 18 | :9\ 19 | \ 20 | :17\ 21 | \ 22 | 23 | Expect html (generated comments at the javascript functions): 24 | 25 | 26 | 27 | Test 28 | 29 | 30 | 31 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /test/filetypes/java/class-methods.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Method without parameters. 3 | # ============================================================================== 4 | Given java (method without parameters): 5 | class Test { 6 | List createSortedList() {} 7 | 8 | void foo(); 9 | } 10 | 11 | Do (trigger doge): 12 | :2\ 13 | \ 14 | :9\ 15 | \ 16 | 17 | Expect java (method with 'TODO' and a @return tag): 18 | class Test { 19 | /** 20 | * [TODO:description] 21 | * 22 | * @return [TODO:description] 23 | */ 24 | List createSortedList() {} 25 | 26 | /** 27 | * [TODO:description] 28 | */ 29 | void foo(); 30 | } 31 | 32 | # ============================================================================== 33 | # Methods with parameters. 34 | # ============================================================================== 35 | Given java (methods with parameters): 36 | class Test { 37 | private static MstRelation MyParameterizedMethod(String p1, int p2, Boolean ...params) throws IOException, IndexOutOfBoundsException {} 38 | 39 | ListResultBean MyParameterizedMethod(String p1, int p2, Boolean... params) {} 40 | } 41 | 42 | Do (trigger doge): 43 | :2\ 44 | \ 45 | :16\ 46 | \ 47 | 48 | Expect java (generated comments with @param and @return tags): 49 | class Test { 50 | /** 51 | * [TODO:description] 52 | * 53 | * @param p1 [TODO:description] 54 | * @param p2 [TODO:description] 55 | * @param params [TODO:description] 56 | * 57 | * @return [TODO:description] 58 | * 59 | * @throws IOException [TODO:description] 60 | * @throws IndexOutOfBoundsException [TODO:description] 61 | */ 62 | private static MstRelation MyParameterizedMethod(String p1, int p2, Boolean ...params) throws IOException, IndexOutOfBoundsException {} 63 | 64 | /** 65 | * [TODO:description] 66 | * 67 | * @param p1 [TODO:description] 68 | * @param p2 [TODO:description] 69 | * @param params [TODO:description] 70 | * 71 | * @return [TODO:description] 72 | */ 73 | ListResultBean MyParameterizedMethod(String p1, int p2, Boolean... params) {} 74 | } 75 | 76 | # ============================================================================== 77 | # Methods with parameters. 78 | # ============================================================================== 79 | Given java (methods with parameters with '@Override'): 80 | class Test { 81 | @Override 82 | protected void MyParameterizedMethod(String p1, int p2) {} 83 | } 84 | 85 | Do (trigger doge): 86 | :2\ 87 | \ 88 | 89 | Expect java (generated comments with @param and @return tags inserted above the '@Override'): 90 | class Test { 91 | /** 92 | * [TODO:description] 93 | * 94 | * @param p1 [TODO:description] 95 | * @param p2 [TODO:description] 96 | */ 97 | @Override 98 | protected void MyParameterizedMethod(String p1, int p2) {} 99 | } 100 | -------------------------------------------------------------------------------- /test/filetypes/javascript/classes.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Classes without 'extends' or 'implements'. 3 | # ============================================================================== 4 | Given javascript (class without extends or implements): 5 | class Child {} 6 | 7 | export class Child {} 8 | 9 | Do (trigger doge): 10 | \ 11 | :7\ 12 | \ 13 | 14 | Expect javascript (generated comment with nothing but the text 'TODO'): 15 | /** 16 | * [TODO:description] 17 | */ 18 | class Child {} 19 | 20 | /** 21 | * [TODO:description] 22 | */ 23 | export class Child {} 24 | 25 | # ============================================================================== 26 | # Classes with 'extends' without 'implements'. 27 | # ============================================================================== 28 | Given javascript (class with extends without implements): 29 | class Child extends Parent {} 30 | 31 | export default class Child extends React.Component {} 32 | 33 | Do (trigger doge): 34 | \ 35 | :7\ 36 | \ 37 | 38 | Expect javascript (generated comment with @extends): 39 | /** 40 | * [TODO:description] 41 | * @extends Parent 42 | */ 43 | class Child extends Parent {} 44 | 45 | /** 46 | * [TODO:description] 47 | * @extends React.Component 48 | */ 49 | export default class Child extends React.Component {} 50 | 51 | # ============================================================================== 52 | # Classes without 'extends' with 'implements'. 53 | # ============================================================================== 54 | Given javascript (class without extends with implements): 55 | class Child implements CustomInterfaceName {} 56 | 57 | export class Child implements CustomInterfaceName {} 58 | 59 | Do (trigger doge): 60 | \ 61 | :7\ 62 | \ 63 | 64 | Expect javascript (generated comment with @implements tag): 65 | /** 66 | * [TODO:description] 67 | * @implements CustomInterfaceName 68 | */ 69 | class Child implements CustomInterfaceName {} 70 | 71 | /** 72 | * [TODO:description] 73 | * @implements CustomInterfaceName 74 | */ 75 | export class Child implements CustomInterfaceName {} 76 | 77 | # ============================================================================== 78 | # Classes with 'extends' and 'implements'. 79 | # ============================================================================== 80 | Given javascript (class with extends and with implements): 81 | class Child extends React.Component implements CustomInterfaceName {} 82 | 83 | export class Child extends React.Component implements CustomInterfaceName {} 84 | 85 | Do (trigger doge): 86 | \ 87 | :9\ 88 | \ 89 | 90 | Expect javascript (generated comment with @extends and @implements tags): 91 | /** 92 | * [TODO:description] 93 | * @extends React.Component 94 | * @implements CustomInterfaceName 95 | */ 96 | class Child extends React.Component implements CustomInterfaceName {} 97 | 98 | /** 99 | * [TODO:description] 100 | * @extends React.Component 101 | * @implements CustomInterfaceName 102 | */ 103 | export class Child extends React.Component implements CustomInterfaceName {} 104 | -------------------------------------------------------------------------------- /test/filetypes/javascript/es7.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Class method with decorators 3 | # ============================================================================== 4 | Given javascript (class method with decorators): 5 | class Test { 6 | @Get() 7 | @UseGuards(LocalAuthGuard([ 8 | 'foo', 9 | 'bar' 10 | ])) 11 | @SkipJwtAuth() 12 | async login( 13 | @CurrentUser() { id }: User, 14 | @Req() req: Request 15 | ): Promise {} 16 | } 17 | 18 | Do (trigger doge): 19 | :8\ 20 | \ 21 | 22 | Expect javascript (generated comment with @async, @param and @returns tags): 23 | class Test { 24 | /** 25 | * [TODO:description] 26 | * 27 | * @async 28 | * @param {User} [TODO:name] - [TODO:description] 29 | * @param {[TODO:type]} [TODO:name].id - [TODO:description] 30 | * @param {Request} req - [TODO:description] 31 | * @returns {Promise} [TODO:description] 32 | */ 33 | @Get() 34 | @UseGuards(LocalAuthGuard([ 35 | 'foo', 36 | 'bar' 37 | ])) 38 | @SkipJwtAuth() 39 | async login( 40 | @CurrentUser() { id }: User, 41 | @Req() req: Request 42 | ): Promise {} 43 | } 44 | -------------------------------------------------------------------------------- /test/filetypes/javascript/functions-inside-objects.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Anonymous functions inside objects without parameters. 3 | # ============================================================================== 4 | Given javascript (anonymous function inside object without parameters): 5 | var myObj = { 6 | myFunc: function(/* inline comment */) { 7 | // 8 | }, 9 | myArrowFunc: (/* inline comment */) => { 10 | return 1; 11 | }, 12 | }; 13 | 14 | Do (trigger doge): 15 | :2\ 16 | \ 17 | :9\ 18 | \ 19 | 20 | Expect javascript (generated comment with @returns tags): 21 | var myObj = { 22 | /** 23 | * [TODO:description] 24 | * 25 | */ 26 | myFunc: function(/* inline comment */) { 27 | // 28 | }, 29 | /** 30 | * [TODO:description] 31 | * 32 | * @returns {[TODO:type]} [TODO:description] 33 | */ 34 | myArrowFunc: (/* inline comment */) => { 35 | return 1; 36 | }, 37 | }; 38 | 39 | 40 | # ============================================================================== 41 | # Async named functions with parameters with/without type hints. 42 | # ============================================================================== 43 | Given javascript (functions with punctation with parameters with/without type hints): 44 | var myObj = { 45 | 'my-func': async function test($p1: string = 'value', p2: array = [], p3, p4 /* inline comment */) { 46 | return $p1; 47 | }, 48 | 'my-arrow-func': async ($p1: string = 'value', p2: array = [], p3, p4 /* inline comment */): ( 1 | 2 | 3 ) => { 49 | return 1; 50 | }, 51 | }; 52 | 53 | Do (trigger doge): 54 | :2\ 55 | \ 56 | :15\ 57 | \ 58 | 59 | Expect javascript (generated comment with @async, @param and @returns tags): 60 | var myObj = { 61 | /** 62 | * [TODO:description] 63 | * 64 | * @async 65 | * @param {string} [$p1] - [TODO:description] 66 | * @param {array} [p2] - [TODO:description] 67 | * @param {[TODO:type]} p3 - [TODO:description] 68 | * @param {[TODO:type]} p4 - [TODO:description] 69 | * @returns {Promise<[TODO:type]>} [TODO:description] 70 | */ 71 | 'my-func': async function test($p1: string = 'value', p2: array = [], p3, p4 /* inline comment */) { 72 | return $p1; 73 | }, 74 | /** 75 | * [TODO:description] 76 | * 77 | * @async 78 | * @param {string} [$p1] - [TODO:description] 79 | * @param {array} [p2] - [TODO:description] 80 | * @param {[TODO:type]} p3 - [TODO:description] 81 | * @param {[TODO:type]} p4 - [TODO:description] 82 | * @returns {Promise<1 | 2 | 3>} [TODO:description] 83 | */ 84 | 'my-arrow-func': async ($p1: string = 'value', p2: array = [], p3, p4 /* inline comment */): ( 1 | 2 | 3 ) => { 85 | return 1; 86 | }, 87 | }; 88 | -------------------------------------------------------------------------------- /test/filetypes/javascript/ignored-expressions.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function calls that should not generate documentation 3 | # ============================================================================== 4 | Given javascript (function call): 5 | AdminPermissionModel.create(item); 6 | 7 | Do (trigger doge): 8 | \ 9 | 10 | Expect javascript (to not have generated a docblock): 11 | AdminPermissionModel.create(item); 12 | 13 | # ============================================================================== 14 | # Member expressions with no function_name 15 | # ============================================================================== 16 | Given javascript (member expression with no function name): 17 | class Foo {} 18 | Foo.propTypes = {}; 19 | 20 | Do (trigger doge): 21 | :2\ 22 | \ 23 | 24 | Expect javascript (to not have generated a docblock): 25 | class Foo {} 26 | Foo.propTypes = {}; 27 | -------------------------------------------------------------------------------- /test/filetypes/javascript/jsx.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Functions that contain JSX. 3 | # ============================================================================== 4 | Given javascript (function that contains JSX): 5 | const Test = ({ someVal }) => { 6 | return ( 7 |
8 |
{true && someVal ? {someVal} : null}
9 | 10 | 11 |
12 | ); 13 | }; 14 | 15 | const SomeWrapperComponent = ({ onSubmit, previewImages, onPreviewFileDelete, ...rest }) => { 16 | return ( 17 |
18 |
19 | ({ 21 | id: image?.id 22 | }))} 23 | onDelete={onPreviewFileDelete} 24 | /> 25 |
26 |
27 | ); 28 | }; 29 | 30 | 31 | Do (trigger doge): 32 | \ 33 | :18\ 34 | \ 35 | 36 | Expect javascript (generated comment with a description, @param and @returns tags): 37 | /** 38 | * [TODO:description] 39 | * 40 | * @param {[TODO:type]} [TODO:name] - [TODO:description] 41 | * @param {[TODO:type]} [TODO:name].someVal - [TODO:description] 42 | * @returns {[TODO:type]} [TODO:description] 43 | */ 44 | const Test = ({ someVal }) => { 45 | return ( 46 |
47 |
{true && someVal ? {someVal} : null}
48 | 49 | 50 |
51 | ); 52 | }; 53 | 54 | /** 55 | * [TODO:description] 56 | * 57 | * @param {[TODO:type]} [TODO:name] - [TODO:description] 58 | * @param {[TODO:type]} [TODO:name].onSubmit - [TODO:description] 59 | * @param {[TODO:type]} [TODO:name].previewImages - [TODO:description] 60 | * @param {[TODO:type]} [TODO:name].onPreviewFileDelete - [TODO:description] 61 | * @returns {[TODO:type]} [TODO:description] 62 | */ 63 | const SomeWrapperComponent = ({ onSubmit, previewImages, onPreviewFileDelete, ...rest }) => { 64 | return ( 65 |
66 |
67 | ({ 69 | id: image?.id 70 | }))} 71 | onDelete={onPreviewFileDelete} 72 | /> 73 |
74 |
75 | ); 76 | }; 77 | -------------------------------------------------------------------------------- /test/filetypes/lua/functions.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Functions without parameters. 3 | # ============================================================================== 4 | Given lua (function without parameters): 5 | function myFunc() -- inline comment 6 | end 7 | 8 | Do (trigger doge): 9 | \ 10 | 11 | Expect lua (generated comment with nothing but the summary and description 'TODO'): 12 | -- [TODO:summary] 13 | -- [TODO:description] 14 | function myFunc() -- inline comment 15 | end 16 | 17 | # ============================================================================== 18 | # Functions with parameters. 19 | # ============================================================================== 20 | Given lua (function with parameters): 21 | function myFunc(p1, p2, p3, p4) -- inline comment 22 | end 23 | 24 | Do (trigger doge): 25 | \ 26 | 27 | Expect lua (generated comment with @param tags): 28 | -- [TODO:summary] 29 | -- [TODO:description] 30 | -- @param p1 [TODO:description] 31 | -- @param p2 [TODO:description] 32 | -- @param p3 [TODO:description] 33 | -- @param p4 [TODO:description] 34 | function myFunc(p1, p2, p3, p4) -- inline comment 35 | end 36 | 37 | # ============================================================================== 38 | # Functions as a variable value. 39 | # ============================================================================== 40 | Given lua (function as a variable value with parameters): 41 | local myFunc = function(p1, p2) 42 | end 43 | 44 | Do (trigger doge): 45 | \ 46 | 47 | Expect lua (generated comment with @param tags): 48 | -- [TODO:summary] 49 | -- [TODO:description] 50 | -- @param p1 [TODO:description] 51 | -- @param p2 [TODO:description] 52 | local myFunc = function(p1, p2) 53 | end 54 | -------------------------------------------------------------------------------- /test/filetypes/lua/object-methods.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Methods declared with a ':'. 3 | # ============================================================================== 4 | Given lua (method declared with a ':' with parameters): 5 | function a.b:c (p1, p2) 6 | end 7 | 8 | Do (trigger doge): 9 | \ 10 | 11 | Expect lua (generated comment with @param tags): 12 | -- [TODO:summary] 13 | -- [TODO:description] 14 | -- @param p1 [TODO:description] 15 | -- @param p2 [TODO:description] 16 | function a.b:c (p1, p2) 17 | end 18 | 19 | # ============================================================================== 20 | # Methods declared with a '.'. 21 | # ============================================================================== 22 | Given lua (method declared with a '.' with parameters): 23 | a.b.c = function (self, p1, p2) 24 | end 25 | 26 | Do (trigger doge): 27 | \ 28 | 29 | Expect lua (generated comment with @param tags): 30 | -- [TODO:summary] 31 | -- [TODO:description] 32 | -- @param p1 [TODO:description] 33 | -- @param p2 [TODO:description] 34 | a.b.c = function (self, p1, p2) 35 | end 36 | 37 | # ============================================================================== 38 | # Method calls that should not generate anything. 39 | # ============================================================================== 40 | Given lua (method with parameters called with ':' syntax): 41 | myobj:foo(n) 42 | 43 | Do (trigger doge): 44 | \ 45 | 46 | Expect lua (no changes): 47 | myobj:foo(n) 48 | 49 | # ------------------------------------------------------------------------------ 50 | 51 | Given lua (method with parameters called with '.' syntax): 52 | myobj.foo(myobj, n) 53 | 54 | Do (trigger doge): 55 | \ 56 | 57 | Expect lua (generated comment with @param tags): 58 | myobj.foo(myobj, n) 59 | -------------------------------------------------------------------------------- /test/filetypes/php/class-properties.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Class properties 3 | # 4 | # Should resolve its corresponding type defined in the constructor. 5 | # ============================================================================== 6 | Given php (class properties above and below the constructor which should resolve its corresponding type via the constructor): 7 | migrationName = $name; 18 | $this->migration = $migration; 19 | $this->response = $response; 20 | } 21 | 22 | private $response; 23 | 24 | private $random; 25 | 26 | } 27 | 28 | Do (trigger doge): 29 | :6\ 30 | \ 31 | :11\ 32 | \ 33 | :16\ 34 | \ 35 | :29\ 36 | \ 37 | :34\ 38 | \ 39 | 40 | Expect php (generated comments at all properties and constructor function): 41 | migrationName = $name; 65 | $this->migration = $migration; 66 | $this->response = $response; 67 | } 68 | 69 | /** 70 | * @var \Symfony\Component\HttpFoundation\Response 71 | */ 72 | private $response; 73 | 74 | /** 75 | * @var [TODO:type] 76 | */ 77 | private $random; 78 | 79 | } 80 | -------------------------------------------------------------------------------- /test/filetypes/python/class-methods.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Class method __init__(). 3 | # ============================================================================== 4 | Given python (class method __init__() with parameters): 5 | class MyClass(object): 6 | 7 | def __init__(self: MyClass): 8 | pass 9 | 10 | Do (trigger doge): 11 | :3\ 12 | \ 13 | 14 | Expect python (generated comment with no :param tags): 15 | class MyClass(object): 16 | 17 | def __init__(self: MyClass): 18 | """ 19 | [TODO:description] 20 | """ 21 | pass 22 | # ============================================================================== 23 | # Class method with advanced type hints. 24 | # ============================================================================== 25 | Given python (class method with advanced type hints): 26 | class MyClass(object): 27 | 28 | def myMethod(self: MyClass, p1: Sequence[T]) -> Generator[int, float, str]: 29 | pass 30 | 31 | Do (trigger doge): 32 | :3\ 33 | \ 34 | 35 | Expect python (generated comment with :param tags): 36 | class MyClass(object): 37 | 38 | def myMethod(self: MyClass, p1: Sequence[T]) -> Generator[int, float, str]: 39 | """ 40 | [TODO:description] 41 | 42 | :param p1: [TODO:description] 43 | :return: [TODO:description] 44 | """ 45 | pass 46 | 47 | # ============================================================================== 48 | # Class method parameters with *args and **kwargs. 49 | # ============================================================================== 50 | Given python (class method parameters with *args and **kwargs): 51 | class MyClass(object): 52 | 53 | def call(cls, foo: str, **kwargs: dict[str, str]) -> str: 54 | pass 55 | 56 | Do (trigger doge): 57 | :3\ 58 | \ 59 | 60 | Expect python (generated comment with :param tags): 61 | class MyClass(object): 62 | 63 | def call(cls, foo: str, **kwargs: dict[str, str]) -> str: 64 | """ 65 | [TODO:description] 66 | 67 | :param foo: [TODO:description] 68 | :param kwargs: [TODO:description] 69 | :return: [TODO:description] 70 | """ 71 | pass 72 | -------------------------------------------------------------------------------- /test/filetypes/python/classes-doc-doxygen.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Classes with attributes 3 | # ============================================================================== 4 | Given python (class with two attributes): 5 | class Foo: 6 | bar = 1 7 | baz: int = 2 8 | 9 | Do (run doge): 10 | :let b:doge_doc_standard='doxygen'\ 11 | \ 12 | 13 | Expect python (class with docstring describing all attributes): 14 | class Foo: 15 | """! @brief [TODO:description]""" 16 | bar = 1 17 | baz: int = 2 18 | -------------------------------------------------------------------------------- /test/filetypes/python/classes-doc-google.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Classes with attributes 3 | # ============================================================================== 4 | Given python (class with two attributes): 5 | class Foo: 6 | bar = 1 7 | baz: int = 2 8 | 9 | Do (run doge): 10 | :let b:doge_doc_standard='google'\ 11 | \ 12 | 13 | Expect python (class with docstring describing all attributes): 14 | class Foo: 15 | """ 16 | [TODO:description] 17 | 18 | Attributes: 19 | bar ([TODO:type]): [TODO:description] 20 | baz: [TODO:description] 21 | """ 22 | bar = 1 23 | baz: int = 2 24 | -------------------------------------------------------------------------------- /test/filetypes/python/classes-doc-numpy.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Classes with attributes 3 | # ============================================================================== 4 | Given python (class with two attributes): 5 | class Foo: 6 | bar = 1 7 | baz: int = 2 8 | 9 | Do (run doge): 10 | :let b:doge_doc_standard='numpy'\ 11 | \ 12 | 13 | Expect python (class with docstring describing all attributes): 14 | class Foo: 15 | """ 16 | [TODO:description] 17 | 18 | Attributes 19 | ---------- 20 | bar : [TODO:type] 21 | [TODO:description] 22 | baz 23 | [TODO:description] 24 | """ 25 | bar = 1 26 | baz: int = 2 27 | -------------------------------------------------------------------------------- /test/filetypes/python/classes-doc-sphinx.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Classes with attributes 3 | # ============================================================================== 4 | Given python (class with two attributes): 5 | class Foo: 6 | bar = 1 7 | baz: int = 2 8 | 9 | Do (run doge): 10 | :let b:doge_doc_standard='sphinx'\ 11 | \ 12 | 13 | Expect python (class with docstring describing all attributes): 14 | class Foo: 15 | """ 16 | [TODO:description] 17 | 18 | Attributes: 19 | bar ([TODO:type]): [TODO:description] 20 | baz: [TODO:description] 21 | """ 22 | bar = 1 23 | baz: int = 2 24 | -------------------------------------------------------------------------------- /test/filetypes/python/classes.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Classes with attributes 3 | # ============================================================================== 4 | Given python (class with two attributes): 5 | class Foo: 6 | bar = 1 7 | baz: int = 2 8 | 9 | Do (run doge): 10 | \ 11 | 12 | Expect python (class with docstring describing all attributes): 13 | class Foo: 14 | """ 15 | [TODO:description] 16 | 17 | Attributes: 18 | bar ([TODO:type]): [TODO:description] 19 | baz: [TODO:description] 20 | """ 21 | bar = 1 22 | baz: int = 2 23 | -------------------------------------------------------------------------------- /test/filetypes/ruby/classes.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Class methods without parameters. 3 | # ============================================================================== 4 | Given ruby (class method without parameters): 5 | class Test 6 | def self.foo 7 | val = 1 8 | end 9 | end 10 | 11 | Do (trigger doge): 12 | :2\ 13 | \ 14 | 15 | Expect ruby (generated comment with nothing but the text 'TODO'): 16 | class Test 17 | # [TODO:description] 18 | def self.foo 19 | val = 1 20 | end 21 | end 22 | 23 | # ============================================================================== 24 | # Class methods with parameters. 25 | # ============================================================================== 26 | Given ruby (class method with parameters): 27 | class Test 28 | def self.foo(x, y, z) 29 | val = 1 30 | end 31 | end 32 | 33 | Do (trigger doge): 34 | :2\ 35 | \ 36 | 37 | Expect ruby (generated comment with @param tags): 38 | class Test 39 | # [TODO:description] 40 | # @param x [[TODO:type]] [TODO:description] 41 | # @param y [[TODO:type]] [TODO:description] 42 | # @param z [[TODO:type]] [TODO:description] 43 | def self.foo(x, y, z) 44 | val = 1 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /test/filetypes/rust/functions.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Functions with parameters. 3 | # ============================================================================== 4 | Given rust (impl methods with parameters): 5 | struct Person { 6 | name: String, 7 | } 8 | 9 | impl Person { 10 | fn new(name: &str) -> Person { 11 | Person { 12 | name: name.to_string(), 13 | } 14 | } 15 | 16 | pub fn hello(&self) -> u8 { 17 | return 0; 18 | } 19 | } 20 | 21 | Do (trigger doge): 22 | :6\ 23 | \ 24 | :23\ 25 | \ 26 | 27 | Expect rust (generated comments with Arguments and Examples sections): 28 | struct Person { 29 | name: String, 30 | } 31 | 32 | impl Person { 33 | /// [TODO:description] 34 | /// 35 | /// # Arguments 36 | /// 37 | /// * `name` - [TODO:description] 38 | /// 39 | /// # Examples 40 | /// 41 | /// ``` 42 | /// [TODO:write some example code] 43 | /// ``` 44 | fn new(name: &str) -> Person { 45 | Person { 46 | name: name.to_string(), 47 | } 48 | } 49 | 50 | /// [TODO:description] 51 | /// 52 | /// # Examples 53 | /// 54 | /// ``` 55 | /// [TODO:write some example code] 56 | /// ``` 57 | pub fn hello(&self) -> u8 { 58 | return 0; 59 | } 60 | } 61 | 62 | # ============================================================================== 63 | # Functions parameter destruction 64 | # ============================================================================== 65 | Given rust (function with destructured params): 66 | pub fn do_thing((i, j): (u8, u8)) -> u8 { 67 | i * j 68 | } 69 | 70 | Do (trigger doge): 71 | \ 72 | 73 | Expect rust (generated comments): 74 | /// [TODO:description] 75 | /// 76 | /// # Examples 77 | /// 78 | /// ``` 79 | /// [TODO:write some example code] 80 | /// ``` 81 | pub fn do_thing((i, j): (u8, u8)) -> u8 { 82 | i * j 83 | } 84 | 85 | # ============================================================================== 86 | # Functions with errors and safety section 87 | # ============================================================================== 88 | Given rust (impl methods with Errors and Safety section): 89 | #[debug] 90 | #[foo( 91 | bar=1, 92 | baz=2 93 | )] 94 | pub unsafe fn foo(foo: usize) -> Result<(), FooError> { 95 | fs::read_to_string("file.txt") 96 | .unwrap_or_else(|err| panic!("Failed to read filepath: {:?}", err)); 97 | } 98 | 99 | Do (trigger doge): 100 | :6\ 101 | \ 102 | 103 | Expect rust (generated comments with Arguments, Safety, Errors and Examples sections): 104 | /// [TODO:description] 105 | /// 106 | /// # Arguments 107 | /// 108 | /// * `foo` - [TODO:description] 109 | /// 110 | /// # Panics 111 | /// 112 | /// [TODO:describe scenarios in which the function could panic] 113 | /// 114 | /// # Errors 115 | /// 116 | /// [TODO:describe error types and what triggers them] 117 | /// 118 | /// # Safety 119 | /// 120 | /// [TODO:explain why the function is unsafe] 121 | /// 122 | /// # Examples 123 | /// 124 | /// ``` 125 | /// [TODO:write some example code] 126 | /// ``` 127 | #[debug] 128 | #[foo( 129 | bar=1, 130 | baz=2 131 | )] 132 | pub unsafe fn foo(foo: usize) -> Result<(), FooError> { 133 | fs::read_to_string("file.txt") 134 | .unwrap_or_else(|err| panic!("Failed to read filepath: {:?}", err)); 135 | } 136 | -------------------------------------------------------------------------------- /test/filetypes/scala/classes.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Subtype classes that extend traits 3 | # ============================================================================== 4 | Given scala (subtype class): 5 | trait Pet: 6 | val name: String 7 | 8 | class Cat(val name: String) extends Pet 9 | 10 | Do (trigger doge): 11 | :4\ 12 | \ 13 | 14 | Expect scala (generated comment): 15 | trait Pet: 16 | val name: String 17 | 18 | /** [TODO:description] 19 | * 20 | * @param name [TODO:description] 21 | */ 22 | class Cat(val name: String) extends Pet 23 | 24 | # ============================================================================== 25 | # Case class 26 | # ============================================================================== 27 | Given scala (case class with params): 28 | protected case class LoremIpsum(name: String, age: Int) extends B with C with D 29 | 30 | Do (trigger doge): 31 | \ 32 | 33 | Expect scala (generated comment): 34 | /** [TODO:description] 35 | * 36 | * @param name [TODO:description] 37 | * @param age [TODO:description] 38 | */ 39 | protected case class LoremIpsum(name: String, age: Int) extends B with C with D 40 | 41 | Given scala (case class without params): 42 | protected case class LoremIpsum() 43 | 44 | Do (trigger doge): 45 | \ 46 | 47 | Expect scala (generated comment): 48 | /** [TODO:description] */ 49 | protected case class LoremIpsum() 50 | 51 | # ============================================================================== 52 | # Classes that extend traits 53 | # ============================================================================== 54 | Given scala (classes that extend traits): 55 | trait Iterator[A]: 56 | def next(): A 57 | 58 | class IntIterator(to: Int) extends Iterator[Int] {} 59 | 60 | class IntIterator(to: Int) extends Iterator[Int]: 61 | def x: Int = _x 62 | def x_=(newValue: Int): Unit = 63 | if newValue < bound then 64 | _x = newValue 65 | else 66 | printWarning() 67 | end IntIterator 68 | 69 | Do (trigger doge): 70 | :4\ 71 | \ 72 | :10\ 73 | \ 74 | :15\ 75 | \ 76 | :20\ 77 | \ 78 | 79 | Expect scala (generated comment): 80 | trait Iterator[A]: 81 | def next(): A 82 | 83 | /** [TODO:description] 84 | * 85 | * @param to [TODO:description] 86 | */ 87 | class IntIterator(to: Int) extends Iterator[Int] {} 88 | 89 | /** [TODO:description] 90 | * 91 | * @param to [TODO:description] 92 | */ 93 | class IntIterator(to: Int) extends Iterator[Int]: 94 | /** [TODO:description] 95 | * 96 | * @return [TODO:description] 97 | */ 98 | def x: Int = _x 99 | /** [TODO:description] 100 | * 101 | * @param newValue [TODO:description] 102 | * @return [TODO:description] 103 | */ 104 | def x_=(newValue: Int): Unit = 105 | if newValue < bound then 106 | _x = newValue 107 | else 108 | printWarning() 109 | end IntIterator 110 | -------------------------------------------------------------------------------- /test/filetypes/scala/functions.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Function with return type 3 | # ============================================================================== 4 | Given scala (function with return type): 5 | def urlBuilder(ssl: Boolean = true, domainName: String): (String, String) => String = {} 6 | 7 | Do (trigger doge): 8 | \ 9 | 10 | Expect scala (generated comment): 11 | /** [TODO:description] 12 | * 13 | * @param ssl [TODO:description] 14 | * @param domainName [TODO:description] 15 | * @return [TODO:description] 16 | */ 17 | def urlBuilder(ssl: Boolean = true, domainName: String): (String, String) => String = {} 18 | 19 | # ============================================================================== 20 | # Function without return type 21 | # ============================================================================== 22 | Given scala (function without return type): 23 | def main(args: Array[String]) = println("Hello, Scala developer!") 24 | 25 | Do (trigger doge): 26 | \ 27 | 28 | Expect scala (generated comment): 29 | /** [TODO:description] 30 | * 31 | * @param args [TODO:description] 32 | * @return [TODO:description] 33 | */ 34 | def main(args: Array[String]) = println("Hello, Scala developer!") 35 | -------------------------------------------------------------------------------- /test/filetypes/scala/lambda_expressions.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Lambda expressions 3 | # ============================================================================== 4 | Given scala (lambda expressions): 5 | (x: Int) => x + 1 6 | 7 | val getTheAnswer = () => 42 8 | 9 | Do (trigger doge): 10 | \ 11 | :8\ 12 | \ 13 | 14 | Expect scala (generated comment): 15 | /** [TODO:description] 16 | * 17 | * @param x [TODO:description] 18 | * @return [TODO:description] 19 | */ 20 | (x: Int) => x + 1 21 | 22 | /** [TODO:description] 23 | * 24 | * @return [TODO:description] 25 | */ 26 | val getTheAnswer = () => 42 27 | -------------------------------------------------------------------------------- /test/filetypes/sh/functions.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Regular functions. 3 | # ============================================================================== 4 | Given sh (regular functions): 5 | function foo { 6 | echo "foo" 7 | } 8 | 9 | function bar() { 10 | echo "bar" 11 | } 12 | 13 | baz() { 14 | echo "baz" 15 | } 16 | 17 | Do (trigger doge): 18 | \ 19 | :16\ 20 | \ 21 | :31\ 22 | \ 23 | 24 | Expect sh (generated comments with a descriptios and 'Globals', 'Arguments' and 'Returns' keywords): 25 | ################################################################################ 26 | # [TODO:description] 27 | # Globals: 28 | # [TODO:variable name] 29 | # Arguments: 30 | # $1: [TODO:description for each parameter] 31 | # Outputs: 32 | # [TODO:description for each output variable] 33 | # Returns: 34 | # [TODO:description] 35 | ################################################################################ 36 | function foo { 37 | echo "foo" 38 | } 39 | 40 | ################################################################################ 41 | # [TODO:description] 42 | # Globals: 43 | # [TODO:variable name] 44 | # Arguments: 45 | # $1: [TODO:description for each parameter] 46 | # Outputs: 47 | # [TODO:description for each output variable] 48 | # Returns: 49 | # [TODO:description] 50 | ################################################################################ 51 | function bar() { 52 | echo "bar" 53 | } 54 | 55 | ################################################################################ 56 | # [TODO:description] 57 | # Globals: 58 | # [TODO:variable name] 59 | # Arguments: 60 | # $1: [TODO:description for each parameter] 61 | # Outputs: 62 | # [TODO:description for each output variable] 63 | # Returns: 64 | # [TODO:description] 65 | ################################################################################ 66 | baz() { 67 | echo "baz" 68 | } 69 | -------------------------------------------------------------------------------- /test/filetypes/svelte/hello-world.vader: -------------------------------------------------------------------------------- 1 | Given svelte (hello world example with template and script tag): 2 | 7 | 8 | 13 | 14 | 15 | 27 | 28 | Do (trigger doge): 29 | :16\ 30 | \ 31 | :27\ 32 | \ 33 | 34 | Expect svelte (generated comment with generated comment inside 47 | 48 | 70 | -------------------------------------------------------------------------------- /test/filetypes/svelte/table-component.vader: -------------------------------------------------------------------------------- 1 | Given svelte (table layout component with script, style and template elements): 2 | 22 | 23 | 36 | 37 | 65 | 66 | Do (trigger doge): 67 | :24\ 68 | \ 69 | 70 | Expect svelte (generated comment with generated comment inside 110 | 111 | 139 | -------------------------------------------------------------------------------- /test/filetypes/typescript/class-methods.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Functions with destructured parameters. 3 | # ============================================================================== 4 | Given typescript (functions with destructured parameters): 5 | class Test { 6 | @Test() 7 | @Test() 8 | test({ idUser, userModel }: { idUser: ObjectId, userModel: string }, p2?: boolean, p3?, p4 = false) {} 9 | 10 | @Test() 11 | async test(@Body() { idUser, userModel }: { error: string } & { idUser: ObjectId, userModel: string }, p2?: boolean, p3?, p4 = false): UserA & UserB { 12 | err = new CustomException(); 13 | throw err; 14 | throw new CustomException(); 15 | } 16 | } 17 | 18 | Do (trigger doge): 19 | :4\ 20 | \ 21 | :17\ 22 | \ 23 | 24 | Expect typescript (generated comment with a description, @param and @returns tags): 25 | class Test { 26 | /** 27 | * [TODO:description] 28 | * 29 | * @param {[TODO:type]} [TODO:name] - [TODO:description] 30 | * @param {[TODO:type]} [TODO:name].idUser - [TODO:description] 31 | * @param {[TODO:type]} [TODO:name].userModel - [TODO:description] 32 | * @param {boolean} [p2] - [TODO:description] 33 | * @param {[TODO:type]} [p3] - [TODO:description] 34 | * @param {[TODO:type]} [p4] - [TODO:description] 35 | */ 36 | @Test() 37 | @Test() 38 | test({ idUser, userModel }: { idUser: ObjectId, userModel: string }, p2?: boolean, p3?, p4 = false) {} 39 | 40 | /** 41 | * [TODO:description] 42 | * 43 | * @async 44 | * @param {[TODO:type]} [TODO:name] - [TODO:description] 45 | * @param {[TODO:type]} [TODO:name].idUser - [TODO:description] 46 | * @param {[TODO:type]} [TODO:name].userModel - [TODO:description] 47 | * @param {boolean} [p2] - [TODO:description] 48 | * @param {[TODO:type]} [p3] - [TODO:description] 49 | * @param {[TODO:type]} [p4] - [TODO:description] 50 | * @throws {[TODO:name]} - [TODO:description] 51 | * @throws {CustomException} - [TODO:description] 52 | * @returns {Promise} [TODO:description] 53 | */ 54 | @Test() 55 | async test(@Body() { idUser, userModel }: { error: string } & { idUser: ObjectId, userModel: string }, p2?: boolean, p3?, p4 = false): UserA & UserB { 56 | err = new CustomException(); 57 | throw err; 58 | throw new CustomException(); 59 | } 60 | } 61 | 62 | # ============================================================================== 63 | # Functions with destructured parameters. 64 | # ============================================================================== 65 | Given typescript (constructor with decorator and scoped parameters): 66 | class Test { 67 | constructor( 68 | @InjectModel(User.name) private readonly $model: Model, 69 | @InjectModel('User') private readonly model: Model 70 | ) {} 71 | } 72 | 73 | Do (trigger doge): 74 | :2\ 75 | \ 76 | 77 | Expect typescript (generated comment with a description, @param and @returns tags): 78 | class Test { 79 | /** 80 | * [TODO:description] 81 | * 82 | * @param {Model} $model - [TODO:description] 83 | * @param {Model} model - [TODO:description] 84 | */ 85 | constructor( 86 | @InjectModel(User.name) private readonly $model: Model, 87 | @InjectModel('User') private readonly model: Model 88 | ) {} 89 | } 90 | -------------------------------------------------------------------------------- /test/filetypes/typescript/class-properties.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Class with multiple properties 3 | # ============================================================================== 4 | Given typescript (class with multiple properties): 5 | class TestClass { 6 | foo 7 | private bar; 8 | baz: int 9 | private bax: str = "test"; 10 | } 11 | 12 | Do (run doge): 13 | :2\ 14 | \ 15 | :7\ 16 | \ 17 | :12\ 18 | \ 19 | :17\ 20 | \ 21 | 22 | Expect typescript (each class prop has a docblock): 23 | class TestClass { 24 | /** 25 | * [TODO:description] 26 | * @type {[TODO:type]} 27 | */ 28 | foo 29 | /** 30 | * [TODO:description] 31 | * @type {[TODO:type]} 32 | */ 33 | private bar; 34 | /** 35 | * [TODO:description] 36 | * @type {int} 37 | */ 38 | baz: int 39 | /** 40 | * [TODO:description] 41 | * @type {str} 42 | */ 43 | private bax: str = "test"; 44 | } 45 | 46 | # ------------------------------------------------------------------------------ 47 | 48 | Given typescript (class with multiple properties with omit_redundant_param_types=1): 49 | class TestClass { 50 | foo 51 | private bar; 52 | baz: int 53 | private bax: str = "test"; 54 | } 55 | 56 | Do (run doge): 57 | :let g:doge_javascript_settings['omit_redundant_param_types'] = 1\ 58 | :2\ 59 | \ 60 | :6\ 61 | \ 62 | :10\ 63 | \ 64 | :14\ 65 | \ 66 | :let g:doge_javascript_settings['omit_redundant_param_types'] = 0\ 67 | 68 | Expect typescript (each class prop has a docblock): 69 | class TestClass { 70 | /** 71 | * [TODO:description] 72 | */ 73 | foo 74 | /** 75 | * [TODO:description] 76 | */ 77 | private bar; 78 | /** 79 | * [TODO:description] 80 | */ 81 | baz: int 82 | /** 83 | * [TODO:description] 84 | */ 85 | private bax: str = "test"; 86 | } 87 | -------------------------------------------------------------------------------- /test/filetypes/vue/table-component.vader: -------------------------------------------------------------------------------- 1 | Given vue (table layout component with script, style and template elements): 2 | 8 | 9 | 23 | 24 | 26 | 27 | Do (trigger doge): 28 | :10\ 29 | \ 30 | :21\ 31 | \ 32 | 33 | Expect vue (generated comment with generated comment inside 64 | 65 | 67 | -------------------------------------------------------------------------------- /test/options/doge_buffer_mappings.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Tests the functionality for the g:doge_buffer_mappings option. 3 | # ============================================================================== 4 | Given php (PHP function without parameters where g:doge_buffer_mappings = 1): 5 | 10 | :2\ 11 | \ 12 | Lorem ipsum 13 | \ 14 | void 15 | \ 16 | Lorem ipsum 17 | 18 | # Trigger an additional to deactivate vim-doge. 19 | \ 20 | 21 | Then (all buffer mappings should not exists anymore): 22 | AssertEqual 0, hasmapto('(doge-comment-jump-forward)', 'nis') 23 | AssertEqual 0, hasmapto('(doge-comment-jump-backward)', 'nis') 24 | 25 | Expect php (generated comment with a description and @return tag): 26 | 37 | -------------------------------------------------------------------------------- /test/options/doge_comment_jump_wrap.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Tests the functionality for the g:doge_comment_jump_wrap option. 3 | # ============================================================================== 4 | Given php (PHP function without parameters where g:doge_comment_jump_wrap = 1): 5 | 10 | :let g:doge_comment_interactive = 1\ 11 | :2\ 12 | \ 13 | \ 14 | \ 15 | 16 | # Trigger 2 additional characters. 17 | # The cursor should stay on the last TODO item. 18 | \ 19 | \ 20 | 21 | Then (the last TODO item should be selected): 22 | AssertEqual 5, line('.') 23 | AssertEqual 24, col('.') 24 | 25 | Expect php (generated comment with a description and @return tag): 26 | 37 | :let g:doge_comment_interactive = 1\ 38 | :2\ 39 | \ 40 | # Trigger 2 characters. 41 | # The cursor should stay on the first TODO item. 42 | \ 43 | \ 44 | 45 | Then (the first TODO item should be selected): 46 | AssertEqual 3, line('.') 47 | AssertEqual 4, col('.') 48 | 49 | Expect php (generated comment with a description and @return tag): 50 | 62 | :let g:doge_comment_interactive = 1\ 63 | :2\ 64 | \ 65 | \ 66 | \ 67 | \ 68 | 69 | Then (the first TODO item should be selected): 70 | AssertEqual 3, line('.') 71 | AssertEqual 4, col('.') 72 | 73 | Expect php (generated comment with @param and @return tags): 74 | 85 | :let g:doge_comment_interactive = 1\ 86 | :2\ 87 | \ 88 | \ 89 | \ 90 | \ 91 | 92 | Then (the first TODO item should be selected): 93 | AssertEqual 3, line('.') 94 | AssertEqual 4, col('.') 95 | 96 | Expect php (generated comment with @param and @return tags): 97 | 108 | -------------------------------------------------------------------------------- /test/undo-cursor-pos.vader: -------------------------------------------------------------------------------- 1 | # ============================================================================== 2 | # Make sure that pressing 'u' after generating a docblock doesn't jump to the 3 | # top of the file. 4 | # 5 | # See https://github.com/kkoomen/vim-doge/issues/309 6 | # ============================================================================== 7 | Given javascript(function): 8 | function foo() { 9 | // 10 | } 11 | 12 | function bar() { 13 | // 14 | } 15 | 16 | Do (trigger doge): 17 | :call cursor(5,8)\ 18 | \ 19 | u 20 | 21 | Expect javascript (no changes): 22 | function foo() { 23 | // 24 | } 25 | 26 | function bar() { 27 | // 28 | } 29 | 30 | Then (the cursor should be at the same pos as before generating the comment): 31 | AssertEqual 5, line('.') 32 | AssertEqual 8, col('.') 33 | -------------------------------------------------------------------------------- /test/vimrc: -------------------------------------------------------------------------------- 1 | " vint: -ProhibitSetNoCompatible 2 | 3 | if expand('$CI') == 'true' 4 | set runtimepath^=$PWD 5 | set runtimepath^=$PWD/vader.vim 6 | else 7 | set runtimepath^=$PWD 8 | set runtimepath^=$PWD/../vader.vim 9 | endif 10 | 11 | " Set a variable to indicate we're inside a test env. 12 | let g:doge_test_env = 1 13 | 14 | " Since the key is not an easy way for Vader we'll use . 15 | let g:doge_mapping = '' 16 | 17 | " Disable the continues comment cyling since this breaks existing tests. 18 | let g:doge_comment_jump_wrap = 0 19 | 20 | " Disable the lazyredraw check since this breaks existing tests. 21 | let g:doge_lazyredraw = 0 22 | 23 | " Disable interactive mode in tests, because it will break existing tests and we 24 | " want to test this manually. 25 | let g:doge_comment_interactive = 0 26 | 27 | " The following is just an example 28 | filetype plugin indent on 29 | syntax on 30 | 31 | if !has('win32') 32 | set shell=/bin/sh 33 | set shellcmdflag=-c 34 | endif 35 | 36 | set nocompatible 37 | set tabstop=2 38 | set softtabstop=2 39 | set shiftwidth=2 40 | set expandtab 41 | set backspace=2 42 | set ttimeoutlen=0 43 | set nowrap 44 | set ttyfast 45 | set autoindent 46 | set smartindent 47 | set smarttab 48 | 49 | augroup vim_doge_tests 50 | autocmd! 51 | 52 | " Force 2 spaces for Python to prevent other filetypes inherit these settings. 53 | autocmd FileType python setlocal tabstop=2 shiftwidth=2 softtabstop=2 54 | augroup END 55 | 56 | " The encoding must be explicitly set for tests for Windows. 57 | execute 'set encoding=utf-8' 58 | 59 | " @see https://github.com/vim/vim/issues/3117 60 | if !has('patch-8.1.201') 61 | silent! python3 1 62 | endif 63 | 64 | if !exists(expand('~/.vim/')) && !has('win32') 65 | call mkdir(expand('~/.vim/'), 'p') 66 | endif 67 | --------------------------------------------------------------------------------