Skip to content

Commit

Permalink
Make optional parts of LanguageInfo actually optional! (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan authored Oct 1, 2024
1 parent af8f1f3 commit e68ad31
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
12 changes: 6 additions & 6 deletions crates/amalthea/src/wire/language_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ pub struct LanguageInfo {
/// The file extension for script files in the language
pub file_extension: String,

/// Pygments lexer (for highlighting), if different than name
pub pygments_lexer: String,
/// Pygments lexer (for highlighting), if different than `name`
pub pygments_lexer: Option<String>,

/// Codemirror mode (for editing), if different than name
pub codemirror_mode: String,
/// Codemirror mode (for editing), if different than `name`
pub codemirror_mode: Option<String>,

/// Nbconvert exporter, if not default
pub nbconvert_exporter: String,
/// Nbconvert exporter, if not the default 'script' exporter
pub nbconvert_exporter: Option<String>,

/// Posit extension
pub positron: Option<LanguageInfoPositron>,
Expand Down
6 changes: 3 additions & 3 deletions crates/amalthea/tests/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ impl ShellHandler for Shell {
version: String::from("1.0"),
file_extension: String::from(".ech"),
mimetype: String::from("text/echo"),
pygments_lexer: String::new(),
codemirror_mode: String::new(),
nbconvert_exporter: String::new(),
pygments_lexer: None,
codemirror_mode: None,
nbconvert_exporter: None,
positron: None,
};
Ok(KernelInfoReply {
Expand Down
6 changes: 3 additions & 3 deletions crates/ark/src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ impl ShellHandler for Shell {
version: kernel_info.version.clone(),
file_extension: String::from(".R"),
mimetype: String::from("text/r"),
pygments_lexer: String::new(),
codemirror_mode: String::new(),
nbconvert_exporter: String::new(),
pygments_lexer: None,
codemirror_mode: None,
nbconvert_exporter: None,
positron: Some(LanguageInfoPositron {
input_prompt: kernel_info.input_prompt.clone(),
continuation_prompt: kernel_info.continuation_prompt.clone(),
Expand Down
3 changes: 3 additions & 0 deletions crates/ark/tests/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ fn test_kernel_info() {

assert_match!(frontend.recv_shell(), Message::KernelInfoReply(reply) => {
assert_eq!(reply.content.language_info.name, "R");
assert_eq!(reply.content.language_info.pygments_lexer, None);
assert_eq!(reply.content.language_info.codemirror_mode, None);
assert_eq!(reply.content.language_info.nbconvert_exporter, None);
});

frontend.recv_iopub_busy();
Expand Down
6 changes: 3 additions & 3 deletions crates/echo/src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ impl ShellHandler for Shell {
version: String::from("1.0"),
file_extension: String::from(".ech"),
mimetype: String::from("text/echo"),
pygments_lexer: String::new(),
codemirror_mode: String::new(),
nbconvert_exporter: String::new(),
pygments_lexer: None,
codemirror_mode: None,
nbconvert_exporter: None,
positron: None,
};
Ok(KernelInfoReply {
Expand Down

0 comments on commit e68ad31

Please sign in to comment.