Disabled examples#

This page is intended to show how to disable the automatic insertion of the TryExamples button in the documentation on a per-page basis. This is useful for methods that are not intended to be executed interactively or for those that may not work well in a WASM environment.

This page is ignored via a regex pattern in the try_examples.json file, like this:

{
  "global_min_height": "400px",
  "ignore_patterns": ["disabled_examples\/demo.html"]
}

and thus any examples on this page below will not have the TryExamples buttons displayed.

Example module#

Source code for disabled_example.py
"""Even though the docstrings in the function below contain Examples sections in
the NumPy style format, no TryExamples buttons will be displayed, as this page is
included in the ignore_patterns list in try_examples.json.
"""

def square_number(x):
    """Return the square of a number.

    Parameters
    ----------
    x : number
        The number to square.

    Returns
    -------
    number
        The square of the input number.

    Examples
    --------
    Square some numbers:

    >>> square_number(4)
    16
    >>> square_number(2.5)
    6.25

    Use with a list comprehension:

    >>> numbers = [1, 2, 3, 4, 5]
    >>> squares = [square_number(n) for n in numbers]
    >>> print(squares)
    [1, 4, 9, 16, 25]
    """
    return x * x

Rendered documentation#

Even though the docstrings in the function below contain Examples sections in the NumPy style format, no TryExamples buttons will be displayed, as this page is included in the ignore_patterns list in try_examples.json.

disabled_example.square_number(x)#

Return the square of a number.

Parameters:
xnumber

The number to square.

Returns:
number

The square of the input number.

Examples

Square some numbers:

>>> square_number(4)
16
>>> square_number(2.5)
6.25

Use with a list comprehension:

>>> numbers = [1, 2, 3, 4, 5]
>>> squares = [square_number(n) for n in numbers]
>>> print(squares)
[1, 4, 9, 16, 25]