From 52f8eea6e5c36c79d87e2a2531b01fb747c94f14 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 22 Oct 2024 15:39:40 -0700 Subject: [PATCH 1/3] Support Jupyter hide options from rsconnect deploy --- internal/bundles/manifest.go | 7 ++++++- internal/config/types.go | 6 ++++++ .../schemas/posit-publishing-schema-v3.json | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/internal/bundles/manifest.go b/internal/bundles/manifest.go index eec79e9f5..9b25650c0 100644 --- a/internal/bundles/manifest.go +++ b/internal/bundles/manifest.go @@ -159,7 +159,6 @@ func NewManifestFromConfig(cfg *config.Config) *Manifest { AppMode: contentType, Entrypoint: cfg.Entrypoint, }, - Jupyter: nil, Environment: nil, Packages: make(PackageMap), Files: make(ManifestFileMap), @@ -176,6 +175,12 @@ func NewManifestFromConfig(cfg *config.Config) *Manifest { }, } } + if cfg.Jupyter != nil { + m.Jupyter = &Jupyter{ + HideAllInput: cfg.Jupyter.HideAllInput, + HideTaggedInput: cfg.Jupyter.HideTaggedInput, + } + } if cfg.Quarto != nil { m.Quarto = &Quarto{ Version: cfg.Quarto.Version, diff --git a/internal/config/types.go b/internal/config/types.go index 4b2407b46..d54ecce27 100644 --- a/internal/config/types.go +++ b/internal/config/types.go @@ -96,6 +96,7 @@ type Config struct { Tags []string `toml:"tags,omitempty" json:"tags,omitempty"` Python *Python `toml:"python,omitempty" json:"python,omitempty"` R *R `toml:"r,omitempty" json:"r,omitempty"` + Jupyter *Jupyter `toml:"jupyter,omitempty" json:"jupyter,omitempty"` Quarto *Quarto `toml:"quarto,omitempty" json:"quarto,omitempty"` Environment Environment `toml:"environment,omitempty" json:"environment,omitempty"` Secrets []string `toml:"secrets,omitempty" json:"secrets,omitempty"` @@ -127,6 +128,11 @@ type R struct { PackageManager string `toml:"package_manager,omitempty" json:"packageManager"` } +type Jupyter struct { + HideAllInput bool `toml:"hide_all_input,omitempty" json:"hideAllInput"` + HideTaggedInput bool `toml:"hide_tagged_input,omitempty" json:"hideTaggedInput"` +} + type Quarto struct { Version string `toml:"version" json:"version"` Engines []string `toml:"engines" json:"engines"` diff --git a/internal/schema/schemas/posit-publishing-schema-v3.json b/internal/schema/schemas/posit-publishing-schema-v3.json index ea32fca1c..c611823a5 100644 --- a/internal/schema/schemas/posit-publishing-schema-v3.json +++ b/internal/schema/schemas/posit-publishing-schema-v3.json @@ -133,6 +133,21 @@ } } }, + "jupyter": { + "type": "object", + "additionalProperties": false, + "description": "Additional rendering options for Jupyter Notebooks.", + "properties": { + "hide_all_input": { + "type": "boolean", + "description": "Hide all input cells when rendering output." + }, + "hide_tagged_input": { + "type": "boolean", + "description": "Hide input code cells with the 'hide_input' tag when rendering output." + } + } + }, "quarto": { "type": "object", "additionalProperties": false, From 647423bca94384db03d2003236ec2915ac5c6c33 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 22 Oct 2024 15:44:46 -0700 Subject: [PATCH 2/3] Add unit test for manifest with Jupyter options --- internal/bundles/manifest_test.go | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/internal/bundles/manifest_test.go b/internal/bundles/manifest_test.go index 257a0bc29..4af1b543d 100644 --- a/internal/bundles/manifest_test.go +++ b/internal/bundles/manifest_test.go @@ -161,3 +161,43 @@ func (s *ManifestSuite) TestNewManifestFromConfig() { Files: map[string]ManifestFile{}, }, m) } + +func (s *ManifestSuite) TestNewManifestFromConfigWithJupyterOptions() { + cfg := &config.Config{ + Schema: schema.ConfigSchemaURL, + Type: "jupyter-notebook", + Entrypoint: "notebook.ipynb", + Title: "Some Notebook", + HasParameters: true, + Python: &config.Python{ + Version: "3.4.5", + PackageFile: "requirements.in", + PackageManager: "pip", + }, + Jupyter: &config.Jupyter{ + HideAllInput: true, + }, + } + m := NewManifestFromConfig(cfg) + s.Equal(&Manifest{ + Version: 1, + Metadata: Metadata{ + AppMode: "jupyter-static", + Entrypoint: "notebook.ipynb", + HasParameters: true, + }, + Python: &Python{ + Version: "3.4.5", + PackageManager: PythonPackageManager{ + Name: "pip", + PackageFile: "requirements.in", + }, + }, + Jupyter: &Jupyter{ + HideAllInput: true, + HideTaggedInput: false, + }, + Packages: map[string]Package{}, + Files: map[string]ManifestFile{}, + }, m) +} From 27ba4586731aa5e0086f9c5ad3ba0826e1e3f70a Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Tue, 22 Oct 2024 16:01:43 -0700 Subject: [PATCH 3/3] Add documentation for new Jupyter options --- docs/configuration.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/configuration.md b/docs/configuration.md index 4a5dbd4a4..20400cade 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -146,6 +146,24 @@ package_file = "renv.lock" package_manager = "renv" ``` +## Jupyter settings + +### hide_all_input + +Hide all input cells when rendering output. + +### hide_tagged_input + +Hide input code cells with the 'hide_input' tag when rendering output. + +Example: + +```toml +[jupyter] +hide_all_input = false +hide_tagged_input = false +``` + ## Quarto settings #### engines