indent_example

View page source

Indent Example

Discussion

The file below demonstrates a single indentation for an entire xrst page. (See xrst_indent for an example that has different indentation for different parts of a page.) Note that underling headings works even though it is indented.

Python Docstring

This example input is a python docstring for the factorial function defined in this file, but it is documenting indentation instead of the function. Note that the xrst commands are in the docstring. See Python Docstring for an alternative way to have xrst include a docstring without having xrst commands in the docstring.

This Example File

'''
This is doctring documentation for the module corresponding to this file.
'''
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2020-26 Bradley M. Bell
# ----------------------------------------------------------------------------
def factorial(n) :
    r"""
    {xrst_begin indent_example}
    {xrst_spell docstring}

    Indent Example
    ##############

    Discussion
    **********
    The file below demonstrates a single indentation for an entire xrst page.
    (See :ref:`example_ad_double@xrst_indent` for an example
    that has different indentation for different parts of a page.)
    Note that underling headings works even though it is indented.

    Python Docstring
    ****************
    This example input is a python docstring for the factorial function
    defined in this file, but it is documenting indentation instead
    of the function. Note that the xrst commands are in the docstring.
    See :ref:`docstring_example@Python Docstring` for an alternative
    way to have xrst include a docstring without having xrst commands
    in the docstring.

    This Example File
    *****************
    {xrst_literal}

    {xrst_end indent_example}
    """
    if n == 1 :
        return 1
    return n * factorial(n-1)