From e68ad31879c65f9e65e238542c482491e44691ec Mon Sep 17 00:00:00 2001 From: Davis Vaughan Date: Tue, 1 Oct 2024 13:07:10 -0400 Subject: [PATCH] Make optional parts of `LanguageInfo` actually optional! (#553) --- crates/amalthea/src/wire/language_info.rs | 12 ++++++------ crates/amalthea/tests/shell/mod.rs | 6 +++--- crates/ark/src/shell.rs | 6 +++--- crates/ark/tests/kernel.rs | 3 +++ crates/echo/src/shell.rs | 6 +++--- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/crates/amalthea/src/wire/language_info.rs b/crates/amalthea/src/wire/language_info.rs index a158a841c..c11300ef2 100644 --- a/crates/amalthea/src/wire/language_info.rs +++ b/crates/amalthea/src/wire/language_info.rs @@ -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, - /// Codemirror mode (for editing), if different than name - pub codemirror_mode: String, + /// Codemirror mode (for editing), if different than `name` + pub codemirror_mode: Option, - /// Nbconvert exporter, if not default - pub nbconvert_exporter: String, + /// Nbconvert exporter, if not the default 'script' exporter + pub nbconvert_exporter: Option, /// Posit extension pub positron: Option, diff --git a/crates/amalthea/tests/shell/mod.rs b/crates/amalthea/tests/shell/mod.rs index b5f6cead5..d3c1317d0 100644 --- a/crates/amalthea/tests/shell/mod.rs +++ b/crates/amalthea/tests/shell/mod.rs @@ -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 { diff --git a/crates/ark/src/shell.rs b/crates/ark/src/shell.rs index 4d2068e85..b188e8862 100644 --- a/crates/ark/src/shell.rs +++ b/crates/ark/src/shell.rs @@ -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(), diff --git a/crates/ark/tests/kernel.rs b/crates/ark/tests/kernel.rs index 7e641e515..7b2382ed0 100644 --- a/crates/ark/tests/kernel.rs +++ b/crates/ark/tests/kernel.rs @@ -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(); diff --git a/crates/echo/src/shell.rs b/crates/echo/src/shell.rs index 27207e990..94dba6b0b 100644 --- a/crates/echo/src/shell.rs +++ b/crates/echo/src/shell.rs @@ -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 {