docs: def compile_dir(env, src_path, dst_path, pattern=r'^.*\.html$', encoding='utf-8', base_dir=None):
    """Compiles a directory of Jinja2 templates to python code.
    
    :param env: a Jinja2 Environment instance.
    :param src_path: path to the source directory.
    :param dst_path: path to the destination directory.
    :param encoding: template encoding.
    :param base_dir: the base path to be removed from the compiled template filename.
    """
    from os import path, listdir, mkdir
    file_re = re.compile(pattern)
  
    if base_dir is None:
      base_dir = src_path
  
    for filename in listdir(src_path):
      src_name = path.join(src_path, filename)
      dst_name = path.join(dst_path, filename)
  
      if path.isdir(src_name):
        mkdir(dst_name)
        compile_dir(env, src_name, dst_name, encoding=encoding, base_dir=base_dir)
      elif path.isfile(src_name) and file_re.match(filename):
        compile_file(env, src_name, dst_name, encoding=encoding, base_dir=base_dir)