From c6fbf477742d516c75f9bd16a96b257dc22b4da3 Mon Sep 17 00:00:00 2001 From: Chris Holdgraf Date: Thu, 5 Jul 2018 17:51:51 -0700 Subject: [PATCH] adding copy buttons to code blocks --- docs/_static/custom.css | 22 ++++++++++++++++++++++ docs/_static/custom.js | 25 +++++++++++++++++++++++++ docs/conf.py | 6 ++++++ docs/guides/admin.rst | 9 +++++---- docs/guides/install.rst | 2 +- docs/guides/notebook-interfaces.rst | 9 ++++----- docs/troubleshooting/logs.rst | 7 ++++--- docs/tutorials/google.rst | 3 +++ 8 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 docs/_static/custom.css create mode 100644 docs/_static/custom.js diff --git a/docs/_static/custom.css b/docs/_static/custom.css new file mode 100644 index 0000000..39e93a9 --- /dev/null +++ b/docs/_static/custom.css @@ -0,0 +1,22 @@ +button.copybtn { + webkit-transition: opacity .3s ease-in-out; + -o-transition: opacity .3s ease-in-out; + transition: opacity .3s ease-in-out; + opacity: 0; + padding: 2px 6px; + position: absolute; + right: 4px; + top: 4px; +} + +div.highlight:hover .copybtn, div.highlight .copybtn:focus { + opacity: .3; +} + +div.highlight .copybtn:hover { + opacity: 1; +} + +div.highlight { + position: relative; +} diff --git a/docs/_static/custom.js b/docs/_static/custom.js new file mode 100644 index 0000000..31ce145 --- /dev/null +++ b/docs/_static/custom.js @@ -0,0 +1,25 @@ +// Set up copy/paste for code blocks +function addCopyButtonToCode(){ + // get all elements + var allCodeBlocksElements = $( "div.highlight pre" ); + + allCodeBlocksElements.each(function(ii) { + // add different id for each code block + + // target + var currentId = "codeblock" + (ii + 1); + $(this).attr('id', currentId); + + //trigger + var clipButton = ''; + $(this).after(clipButton); + }); + + new Clipboard('.btn'); +} + +$(document).ready(function () { + // Highlight current page in sidebar + console.log('hi'); + addCopyButtonToCode(); +}); diff --git a/docs/conf.py b/docs/conf.py index b3c8d22..3395052 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,6 +10,12 @@ version = '' # The full version, including alpha/beta/rc tags release = 'v0.1' +# Add custom CSS/Javascript +def setup(app): + app.add_javascript("custom.js") + app.add_stylesheet("custom.css") + app.add_javascript("https://cdn.jsdelivr.net/npm/clipboard@1/dist/clipboard.min.js") + # Enable MathJax for Math extensions = ['sphinx.ext.mathjax'] diff --git a/docs/guides/admin.rst b/docs/guides/admin.rst index 1b38cee..3aa82f7 100644 --- a/docs/guides/admin.rst +++ b/docs/guides/admin.rst @@ -7,9 +7,9 @@ In The Littlest JupyterHub, we try to allow users to do as many administrative tasks as possible within JupyterHub itself. Admin users can: 1. Have full root access with passwordless ``sudo`` -2. Install systemwide packages with ``apt`` -3. Install ``conda`` / ``pip`` packages for all JupyterHub -4. Change amount of RAM / CPU available to each user and more! +2. Install system-wide packages with ``apt`` +3. Install ``conda`` / ``pip`` packages for all JupyterHub users +4. Change the amount of RAM / CPU available to each user, and more! By default, there are no admin users. You should add some after installation. @@ -17,7 +17,8 @@ Adding admin users ================== Admin users are specified in the `YAML `_ -config file at ``/opt/tljh/config.yaml``. +config file at ``/opt/tljh/config.yaml``. This file is created upon installing +tljh. 1. Open the ``config.yaml`` file for editing. diff --git a/docs/guides/install.rst b/docs/guides/install.rst index 0a873a2..11e3555 100644 --- a/docs/guides/install.rst +++ b/docs/guides/install.rst @@ -15,7 +15,7 @@ The quick way to install The Littlest JupyterHub (tljh) is: This takes 2-5 minutes to run. When completed, you can access your new JupyterHub at the public IP of your server! -You should probably add yourself as an `admin user `_ +You should probably add yourself as an `admin user `_ after installation. Slightly less quick installation diff --git a/docs/guides/notebook-interfaces.rst b/docs/guides/notebook-interfaces.rst index 96c41fa..d9c7f04 100644 --- a/docs/guides/notebook-interfaces.rst +++ b/docs/guides/notebook-interfaces.rst @@ -10,7 +10,7 @@ interfaces you can use: 1. `JupyterLab `_ 2. `nteract `_ -Both these interfaces are also shipped with TLJH by default. You can try them +Both these interfaces are also shipped with tljh by default. You can try them temporarily, or set them to be the default interface whenever you login. Trying alternate interface tempoarily @@ -20,13 +20,12 @@ When you log in & start your server, by default the URL in your browser will be something like ``/user//tree``. The ``/tree`` is what tells the notebook server to give you the classic notebook interface. -If you change ``/tree`` to ``/lab``, you will get the JupyterLab interface. - -If you change ``/tree`` to ``/nteract``, you will get the nteract interface. +* **For the JupyterLab interface**: change ``/tree`` to ``/lab``. +* **For the nteract interface**: change ``/tree`` to ``/nteract`` You can play around with them and see what fits your use cases best. -Changing default notebook interface +Changing the default user interface ----------------------------------- You can change the default interface users get when they log in by modifying diff --git a/docs/troubleshooting/logs.rst b/docs/troubleshooting/logs.rst index 5f0d0c5..1ffebd6 100644 --- a/docs/troubleshooting/logs.rst +++ b/docs/troubleshooting/logs.rst @@ -7,7 +7,7 @@ Looking at Logs They contain a forensic record of what individual pieces of software were doing before things went bad, and can help us understand the problem so we can fix it. -TLJH collects logs from JupyterHub, Configurable HTTP Proxy & from each individual +TLJH collects logs from JupyterHub, Configurable HTTP Proxy, & from each individual user's notebook server. All the logs are accessible via `journalctl `_. .. warning:: @@ -58,8 +58,9 @@ problems after that. sudo journalctl -u jupyter- -This command displays logs from the given user's notebook server. See :ref:`journalctl_tips` -for tips on navigating the logs. +This command displays logs from the given user's notebook server. You can get a +list of all users from the "users" button at the top-right of the Admin page. +See :ref:`journalctl_tips` for tips on navigating the logs. .. _journalctl_tips: diff --git a/docs/tutorials/google.rst b/docs/tutorials/google.rst index 2bd18ac..931555b 100644 --- a/docs/tutorials/google.rst +++ b/docs/tutorials/google.rst @@ -82,6 +82,9 @@ Let's create the server on which we can run JupyterHub. .. image:: ../images/providers/google/machine-type-advanced.png :alt: Select a customized VM size + For more guidance on the different options available to you, as well as + pricing considerations on Google Cloud, see the `GCP Choosing a VM Guide `_. + #. Under **Boot Disk**, click the **Change** button. This lets us change the operating system and the size of your disk.