nbdev icon indicating copy to clipboard operation
nbdev copied to clipboard

nbdev_readme fails with mysterious error if docstring contains "\"

Open nikolas-claussen opened this issue 1 year ago • 1 comments

nbdev_readme fails if I have a backslash in the docstring of any exported function, e.g.

#|  export
def f():
    """ 
    Example doctring $x \mapsto y$
    """
    return None

The resulting error message is very long and does not indicate the problem (although it does point to the offending function).

nikolas-claussen avatar Sep 30 '24 19:09 nikolas-claussen

Are you using python 3.12? The change in string parsing can yield warnings or errors with strings that contain backslashes. Those can normally be fixed simply by telling python it is a "raw" string, eg, just prepending the quotes with an r:

#|  export
def f():
    r""" 
    Example doctring $x \mapsto y$
    """
    return None

jlopezpena avatar Oct 25 '24 11:10 jlopezpena