Search code examples
jupyter-notebookjuliacode-documentation

Documentation with some text highlighted in gray


The option to document functions in Julia is straightforward, which is welcoming. Is it possible to have certain keywords in the documentation highlighted when using a Jupyter notebook?

For e.g.

"""
function ph(phoenix_one, phoenix-two)

      phoenix_one is an array of tuples containing information on height and weight, and phoenix-two contains position data.
"""
function ph(phoenix_one, phoenix-two)
    return phoenix_one + phoenix-two
end

when ?ph is called

The expectation is:

phoenix_one is an array of tuples containing information on height and weight, and phoenix-two contains position data.

instead of

phoenix_one is an array of tuples containing information on height and weight, and phoenix-two contains position data.

That is with some keywords highlighted.


Solution

  • Here is the way to do it (use backticks + note the layout of the docstring)

    """
        ph(phoenix_one, phoenix_two)
    
    `phoenix_one` is an array of tuples containing information on height and weight,
    and phoenix-two contains position data.
    """
    function ph(phoenix_one, phoenix_two)
        return phoenix_one + phoenix_two
    end
    

    enter image description here