def is_char_allowed(line_string, index):
    """Return True if char in index is allowed or don't exist.

    Parameters
    ==========
    line_string (string)
        represents a line of text.
    index (integer)
        the index of a character in the line string.

    Purpose
    =======

    Used to check whether a "todo" substring (a string
    from the TODO_WORDS constant) from line_string is
    a proper todo word.

    Such check is made indirectly, by checking the
    characters which reside in the adjacent indices
    of the substring. The following rules apply:

    A character sitting on an adjacent index is valid
    if either...

    a) it doesn't exist (not having an adjacent character
       is a valid condition for a todo word)
    b) it exists and is considered an allowed character
       (it must be in the ALLOWED_SURROUNDING_CHARACTERS
       string)

    For the substring to be considered valid, both the
    adjacent indices must be checked, which is why this
    function is called twice: one call per index.
    """
    ### in this context, if the index is negative, it means
    ### it doesn't exist, which is a valid condition, so
    ### we return True
    if index < 0:
        return True

    ### check whether the index points to a character in
    ### the line string
    try:
        char = line_string[index]

    ### if it doesn't, since this is a valid condition we
    ### pass in order to meet the 'return True' statement
    ### at the end of the function
    except IndexError:
        pass

    ### if there is such character, we check whether it
    ### is not allowed, in which case we return False

    else:

        if char not in ALLOWED_SURROUNDING_CHARS:
            return False

    ### if we reach this point, it means we didn't meet an
    ### invalidating condition, so we can return True
    return True
Return True if char in index is allowed or don't exist.

    Parameters
    ==========
    line_string (string)
        represents a line of text.
    index (integer)
        the index of a character in the line string.

    Purpose
    =======

    Used to check whether a "todo" substring (a string
    from the TODO_WORDS constant) from line_string is
    a proper todo word.

    Such check is made indirectly, by checking the
    characters which reside in the adjacent indices
    of the substring. The following rules apply:

    A character sitting on an adjacent index is valid
    if either...

    a) it doesn't exist (not having an adjacent character
       is a valid condition for a todo word)
    b) it exists and is considered an allowed character
       (it must be in the ALLOWED_SURROUNDING_CHARACTERS
       string)

    For the substring to be considered valid, both the
    adjacent indices must be checked, which is why this
    function is called twice: one call per index.
    
nodezator/syntaxman/syntaxes/comment.py