2

I'm new to Sphinx documentation, and I am trying to convert a Jupyter Notebook into Sphinx docs using Nbsphinx. Especially, I want to hide the code cells (not their outputs), but I could not make it using templates that I found for Jupyter Nbconvert.

I expect the outputs from converted notebook on the Sphinx documentation, but no input.

barryhunter
  • 20,886
  • 3
  • 30
  • 43
KYigit
  • 39
  • 3
  • 1
    Hi, KYigit! Can you post the code you've tried so far? – crenshaw-dev May 31 '19 at 20:15
  • Hello, thank you so much for the prompt reply. Hre is the tpl code I use in "source/_templates" directory. {%- extends 'full.tpl' -%} {% block input_group -%}
    {{ super() }}
    {% endblock input_group %}
    – KYigit May 31 '19 at 20:27

1 Answers1

1

I added the following code to the first cell and it works well.

import IPython.core.display as di # Example: di.display_html('<h3>%s:</h3>' % str, raw=True)
di.display_html('<script>jQuery(function() {if (jQuery("body.notebook_app").length == 0) { jQuery(".input_area").toggle(); jQuery(".prompt").toggle();}});</script>', raw=True)'
KYigit
  • 39
  • 3
  • 1
    I have [the exact same issue](https://github.com/spatialaudio/nbsphinx/issues/285#issuecomment-543350301), but I don't really understand how to implement your answer. Can you elaborate? – Ratnanil Oct 18 '19 at 06:33
  • Of Course, you just add the code beginning with "import IPython....." to the first cell. Please note that you could use ''' instead of '. What this does is when the Sphinx runs it hides the code cell using java script. – KYigit Oct 19 '19 at 13:45
  • You have no idea on how precious this is. Thank you! – erickfis Oct 06 '21 at 12:16