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

Add Cairo snippet extractor #108

Merged
merged 8 commits into from
Jul 23, 2024
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ It takes the code of an Exercism submission and creates a snippet for it (shown
## Customizing snippet extraction

By default, the snippet extractor extracts the first ten "interesting" (non-empty) lines of code.
Whilst the default behavior is useful, we recommend customing snippet generation for most languages.
Whilst the default behavior is useful, we recommend customizing snippet generation for most languages.

### Customization

Expand Down
5 changes: 5 additions & 0 deletions lib/languages/cairo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
!e
use
//
///
//!
15 changes: 15 additions & 0 deletions tests/cairo/extended/code.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! we will need this, trust me!
use lib::some_function;

// Hmmmmmmmm

/// This comment is explaing
/// a lot!!!
mod two_fer { // we don't really
// have actual multiline
// comments!!
fn two_fer(name: ByteArray) -> ByteArray {
// There might be a comment here
return "One for " + name + ", one for me."; // A comment after a valid line
}
} // module two_fer
5 changes: 5 additions & 0 deletions tests/cairo/extended/expected_snippet.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod two_fer {
fn two_fer(name: ByteArray) -> ByteArray {
return "One for " + name + ", one for me.";
}
}
7 changes: 7 additions & 0 deletions tests/cairo/full/code.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use lib::some_function;

mod two_fer {
fn two_fer(name: ByteArray) -> ByteArray {
return "One for " + name + ", one for me.";
}
}
5 changes: 5 additions & 0 deletions tests/cairo/full/expected_snippet.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mod two_fer {
fn two_fer(name: ByteArray) -> ByteArray {
return "One for " + name + ", one for me.";
}
}