Skip to content

Commit

Permalink
Merge pull request #2409 from posit-dev/dotnomad/support-jupyter-hide…
Browse files Browse the repository at this point in the history
…-options

Support Jupyter hide options in Connect manifest
  • Loading branch information
dotNomad authored Oct 28, 2024
2 parents 0fabcbe + 27ba458 commit fdc5cc0
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 1 deletion.
18 changes: 18 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion internal/bundles/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand Down
40 changes: 40 additions & 0 deletions internal/bundles/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 6 additions & 0 deletions internal/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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"`
Expand Down
15 changes: 15 additions & 0 deletions internal/schema/schemas/posit-publishing-schema-v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit fdc5cc0

Please sign in to comment.