Reveal

The reveal hides content until a ‘Show’ button is pressed.

Synopsis

The general format of the reveal directive is:

.. reveal:: unique_id
   :optional: parameter value

   + --- Content area ---
   |
   | one or more lines of initially hidden content
   | which can include any Runestone or Sphinx supported directives.
   |
   + --------------------

Required Arguments

unique id

A unique identifier after a space and the :: in the reveal directive. Valid identifiers must not contain spaces. You should also avoid the characters `` ` , ``,, :, and *.

content area

The reveal directive must contain at least one line of content.

Optional Arguments

showtitle

String. Define a label for the ‘show’ button. Default is Show.

hidetitle

String. Define a label for the ‘hide’ button. Default is Hide.

This option only applies if the modal option is not used.

modal

Boolean. If defined, the revealed content is presented in a modal dialog. Default is false.

The default behavior reveals content in-line.

modaltitle

String. Title of modal dialog window. Default is “Message from the author”.

This option only applies if the modal option is used.

instructoronly

Boolean. If provided the content and reveal button will only be visible to instructors. The proposed use of this is to provide an instructor guide embedded in the book.

Languages supported

Not applicable.

Sphinx configuration options

No directive specific configuration options exist.

Internationalization

tbd.

Known limitations

None.

Examples

.. reveal:: re-ex1

   This content starts out hidden.

   - *Any* valid `Sphinx markup <http://www.sphinx-doc.org>`__ can be included.
   - Hidden content can be shown by using the Show button.
   - When shown, a Hide button appears at the end of the hidden content.

This content starts out hidden.

  • Any valid Sphinx markup can be included.

  • Hidden content can be shown by using the Show button.

  • When shown, a Hide button appears at the end of the hidden content.

Both show and hide buttons are easy to customize:

.. reveal:: re-ex2
    :showtitle: Reveal Content
    :hidetitle: Hide Content

    The reveal block can contain other Runestone directives:

    .. activecode:: ac-reveal-ex

        print ("Hello, world")

The reveal block can contain other Runestone directives:

Very useful for in class presentations, or for in book exercises where you want to keep a solution hidden. Display inline, or in a dialog, as you prefer.

Given the following C++ statements:

.. code-block:: cpp

   int  val = 0;
   int& ir  = val;
   auto x   = ir;

What type is x?

.. reveal:: reveal-ex3
   :modal:
   :modaltitle: Understanding auto type deduction

   If you said, ``int``, excellent job!

   ``ir`` is a reference to ``val``, 
   which makes ``ir`` just another name for ``val``. 
   ``auto x = ir;`` is exactly the same as if we had written 
   ``auto x = val;`` here.

Given the following C++ statements:

int  val = 0;
int& ir  = val;
auto x   = ir;

What type is x?

If you said, int, excellent job!

ir is a reference to val, which makes ir just another name for val. auto x = ir; is exactly the same as if we had written auto x = val; here.

Next Section - Tab Groups