import re


def rst_preprocess(file):
    """
    Preprocess reST file to support Sphinx like include directive. Includes are
    relative to the current working directory.
    """

    with open(file) as fp:
        return re.sub(
            "^\.\.\s+include:: (.*?)$",
            lambda x: (rst_preprocess(x.group(1)) or "").rstrip(),
            fp.read(),
            flags=re.MULTILINE)