Skip to content

Commit

Permalink
feat: add support for scala (resolves #288)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoomen committed Aug 13, 2023
1 parent 0b0bbc3 commit 01e67ee
Show file tree
Hide file tree
Showing 17 changed files with 439 additions and 147 deletions.
108 changes: 0 additions & 108 deletions ftplugin/_scala.vim

This file was deleted.

16 changes: 16 additions & 0 deletions ftplugin/scala.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
" ==============================================================================
" The Scala documentation should follow the 'ScalaDoc' conventions.
" see https://docs.scala-lang.org/style/scaladoc.html
" ==============================================================================

let s:save_cpo = &cpoptions
set cpoptions&vim

let b:doge_parser = 'scala'
let b:doge_insert = 'above'

let b:doge_supported_doc_standards = ['scaladoc']
let b:doge_doc_standard = doge#buffer#get_doc_standard('scala')

let &cpoptions = s:save_cpo
unlet s:save_cpo
3 changes: 3 additions & 0 deletions helper/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.yaml]
indent_size = 2

[*.md]
trim_trailing_whitespace = false
12 changes: 11 additions & 1 deletion helper/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ tree-sitter-cpp = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev
tree-sitter-typescript = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "3429d8c" }
tree-sitter-php = { git = "https://github.com/tree-sitter/tree-sitter-php", rev = "d43130f" }
tree-sitter-r = { git = "https://github.com/r-lib/tree-sitter-r", rev = "c55f8b4" }
tree-sitter-scala = { git = "https://github.com/tree-sitter/tree-sitter-scala", rev = "f14629b" }
1 change: 1 addition & 0 deletions helper/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub fn load_doc_config_str<'a>(parser_name: &'a str, doc_name: &'a str) -> &'a s
"bash_google" => include_str!("bash/docs/google.yaml"),
"rust_rustdoc" => include_str!("rust/docs/rustdoc.yaml"),
"r_roxygen2" => include_str!("r/docs/roxygen2.yaml"),
"scala_scaladoc" => include_str!("scala/docs/scaladoc.yaml"),

_ => panic!("Unsupported {} doc: {}", parser_name, doc_name),
}
Expand Down
2 changes: 2 additions & 0 deletions helper/src/docblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::ruby::parser::RubyParser;
use crate::rust::parser::RustParser;
use crate::typescript::parser::TypescriptParser;
use crate::r::parser::RParser;
use crate::scala::parser::ScalaParser;


fn replace_indent_placeholders(docblock: &str, use_tabs: bool, indent: usize) -> String {
Expand Down Expand Up @@ -139,6 +140,7 @@ pub fn generate(
"cpp" => Box::new(CppParser::new(code, line, &node_types)) as Box<dyn BaseParser>,
"typescript" => Box::new(TypescriptParser::new(code, line, &node_types, options)) as Box<dyn BaseParser>,
"r" => Box::new(RParser::new(code, line, &node_types)) as Box<dyn BaseParser>,
"scala" => Box::new(ScalaParser::new(code, line, &node_types)) as Box<dyn BaseParser>,
_ => panic!("Unsupported parser: {}", &parser_name),
};

Expand Down
1 change: 1 addition & 0 deletions helper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ pub mod c;
pub mod cpp;
pub mod typescript;
pub mod r;
pub mod scala;
36 changes: 18 additions & 18 deletions helper/src/r/docs/roxygen2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ templates:
node_types:
- function_definition
template: |
#' [TODO:title of the function]
#'
#' [TODO:brief description]
{% if params %}
#'
{% for param in params %}
#' @param {{ param.name }} [TODO:description]{% if param.default_value %}. Default is {{ param.default_value }}.{% endif %}
{% endfor %}
{% endif %}
#'
#' @return [TODO:description]
#'
#' @examples
#' {{ func_name }}([TODO:parameters])
#'
#' @rdname {{ func_name }}
#'
#' @method {{ func_name }}
#' [TODO:title of the function]
#'
#' [TODO:brief description]
{% if params %}
#'
{% for param in params %}
#' @param {{ param.name }} [TODO:description]{% if param.default_value %}. Default is {{ param.default_value }}.{% endif %}
{% endfor %}
{% endif %}
#'
#' @return [TODO:description]
#'
#' @examples
#' {{ func_name }}([TODO:parameters])
#'
#' @rdname {{ func_name }}
#'
#' @method {{ func_name }}
45 changes: 45 additions & 0 deletions helper/src/scala/docs/scaladoc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# https://docs.scala-lang.org/style/scaladoc.html

templates:
lambda_expression:
node_types:
- lambda_expression
template: |
/** [TODO:description]
*
{% if params %}
{% for param in params %}
* @param {{ param.name }} [TODO:description]
{% endfor %}
{% endif %}
* @return [TODO:description]
*/
function:
node_types:
- function_definition
template: |
/** [TODO:description]
*
{% if params %}
{% for param in params %}
* @param {{ param.name }} [TODO:description]
{% endfor %}
{% endif %}
* @return [TODO:description]
*/
class:
node_types:
- class_definition
template: |
{% if params %}
/** [TODO:description]
*
{% for param in params %}
* @param {{ param.name }} [TODO:description]
{% endfor %}
*/
{% else %}
/** [TODO:description] */
{% endif %}
1 change: 1 addition & 0 deletions helper/src/scala/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod parser;
Loading

0 comments on commit 01e67ee

Please sign in to comment.