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 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/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) +} 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,