diff --git a/NEWS.md b/NEWS.md
index 31e9c11e..2659a517 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,8 @@
+## Unreleased
+--------------------------------------------------------------------------------
+* Added ability to hide all code cells when rendering Jupyter notebooks.
+* Added ability to selectively hide code cells tagged with 'hide_input' when rendering Jupyter notebooks.
+
`rsconnect-jupyter` 1.4.1
--------------------------------------------------------------------------------
* UI now shows more error details for troubleshooting.
diff --git a/rsconnect_jupyter/__init__.py b/rsconnect_jupyter/__init__.py
index b094c175..5f5cb19b 100644
--- a/rsconnect_jupyter/__init__.py
+++ b/rsconnect_jupyter/__init__.py
@@ -150,6 +150,8 @@ def post(self, action):
disable_tls_check = data["disable_tls_check"]
cadata = data.get("cadata", None)
extra_files = data.get("files", [])
+ hide_all_input = data.get("hide_all_input", False)
+ hide_tagged_input = data.get("hide_tagged_input", False)
model = self.contents_manager.get(path=nb_path)
if model["type"] != "notebook":
@@ -163,7 +165,9 @@ def post(self, action):
if app_mode == "static":
try:
- bundle = make_notebook_html_bundle(os_path, sys.executable)
+ bundle = make_notebook_html_bundle(
+ os_path, sys.executable, hide_all_input=hide_all_input, hide_tagged_input=hide_tagged_input
+ )
except Exception as exc:
self.log.exception("Bundle creation failed")
raise web.HTTPError(500, u"Bundle creation failed: %s" % exc)
@@ -172,7 +176,13 @@ def post(self, action):
raise web.HTTPError(400, "environment is required for jupyter-static app_mode")
try:
- bundle = make_notebook_source_bundle(os_path, Environment(**environment_dict), extra_files)
+ bundle = make_notebook_source_bundle(
+ os_path,
+ Environment(**environment_dict),
+ extra_files,
+ hide_all_input=hide_all_input,
+ hide_tagged_input=hide_tagged_input,
+ )
except Exception as exc:
self.log.exception("Bundle creation failed")
raise web.HTTPError(500, u"Bundle creation failed: %s" % exc)
diff --git a/rsconnect_jupyter/static/connect.js b/rsconnect_jupyter/static/connect.js
index 4c593df3..5b2a44e2 100644
--- a/rsconnect_jupyter/static/connect.js
+++ b/rsconnect_jupyter/static/connect.js
@@ -1067,6 +1067,17 @@ define([
' ',
' ',
' ',
+ '
',
+ ' ',
+ '
',
+ ' ',
+ ' ',
+ ' ',
+ '
',
+ ' ',
+ ' ',
+ ' ',
+ '
',
' ',
'
',
'
',
@@ -1345,7 +1356,8 @@ define([
function bindCheckbox(id) {
// save/restore value in server settings
- var $box = $('#' + id.replace('_', '-'));
+ // var $box = $('#' + id.replace('_', '-'));
+ var $box = $('#' + id);
if (selectedEntryId) {
var updatedEntry = config.servers[selectedEntryId];
@@ -1360,8 +1372,10 @@ define([
updateCheckboxStates();
});
}
- bindCheckbox('include_files');
- bindCheckbox('include_subdirs');
+ // bindCheckbox('include_files');
+ // bindCheckbox('include_subdirs');
+ bindCheckbox('hide_all_input');
+ bindCheckbox('hide_tagged_input');
// setup app mode choices help icon
(function() {
@@ -1382,6 +1396,24 @@ define([
$('#rsc-publish-source > label').append(helpIcon);
})();
+ // setup hide input help icon
+ (function() {
+ var msg =
+ 'Hiding input code cells results in rendering only the output of code cells on publication.
Hide Input Documentation';
+
+ var helpIcon = $(
+ [
+ '
',
+ ''
+ ].join('')
+ )
+ .data('content', msg)
+ .data('html', true)
+ .popover();
+
+ $('#hide-input-wrapper').append(helpIcon);
+ })();
+
var form = publishModal.find('form').on('submit', function(e) {
e.preventDefault();
publishModal.find('.form-group').removeClass('has-error');
@@ -1790,7 +1822,6 @@ define([
// lazily load the config when clicked since Jupyter's init
// function is racy w.r.t. loading of notebook metadata
maybeCreateConfig();
-
closeMenu();
// save before publishing so the server can pick up changes
diff --git a/rsconnect_jupyter/static/main.css b/rsconnect_jupyter/static/main.css
index 262819a0..8506156a 100644
--- a/rsconnect_jupyter/static/main.css
+++ b/rsconnect_jupyter/static/main.css
@@ -130,3 +130,8 @@ p {
font-size: .7em;
text-align: right;
}
+
+
+#hide-input-wrapper {
+ display:flex;
+}
diff --git a/rsconnect_jupyter/static/rsconnect.js b/rsconnect_jupyter/static/rsconnect.js
index 82c6f6cc..a831c176 100644
--- a/rsconnect_jupyter/static/rsconnect.js
+++ b/rsconnect_jupyter/static/rsconnect.js
@@ -447,7 +447,9 @@ define([
environment: environment,
files: files,
disable_tls_check: entry.disableTLSCheck || false,
- cadata: self.getCAData(entry.server)
+ cadata: self.getCAData(entry.server),
+ hide_all_input: entry.hide_all_input,
+ hide_tagged_input: entry.hide_tagged_input
};
var xhr = Utils.ajax({
diff --git a/setup.cfg b/setup.cfg
index 2246e777..d22375cd 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -16,10 +16,10 @@ project_urls =
[options]
install_requires =
- rsconnect-python>=1.5.0
+ rsconnect-python>=1.5.4
notebook
nbformat
- nbconvert>=5.0
+ nbconvert>=5.6.1
six
ipython
setup_requires =