Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gleam support #71

Merged
merged 2 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/languages/gleam.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
!e
//\p
///\p
////\p
import
74 changes: 74 additions & 0 deletions test/languages/gleam_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
require "test_helper"

module SnippetExtractor
module Languages
class GleamTest < Minitest::Test
def test_full_example
code = <<~CODE
//// This is a file
//// With some comments in it

// And a blank line ⬆️
// It has some imports like this:
import gleam/erlang
import gleam/erlang/process.{Subject}

/// And then eventually the code
pub fn two_fer(name: String) -> String {
todo
}
CODE

expected = <<~CODE
pub fn two_fer(name: String) -> String {
todo
}
CODE

assert_equal expected, ExtractSnippet.(code, :gleam)
end

def test_extended_example
code = <<~CODE
//// This is a file
//// With some comments in it

// And a blank line ⬆️
// It has some imports like this:
import gleam/erlang
import gleam/erlang/process.{Subject}

/// And then eventually the code
pub fn two_fer(name: String) -> String {
todo// with comments
}

// Here is a comment
/// And a documentation comment
pub type TwoFer {
TwoFer(name: String)
}

const a = 1
const b = 1
const c = 1 // More, but this is over 10 lines so it wont appear
CODE

expected = <<~CODE
pub fn two_fer(name: String) -> String {
todo
}

pub type TwoFer {
TwoFer(name: String)
}

const a = 1
const b = 1
CODE

assert_equal expected, ExtractSnippet.(code, :gleam)
end
end
end
end