Exemplo n.º 1
0
def rtl_language_wrap(args):
    """Check that RTL languages wrap text elemenst in a directional div.

  Required for languages like Arabic to render correctly in Colab. Some care
  must be taken or any Markdown syntax within the div will break.

  Args:
    args: Nested dict of runtime arguments.

  Returns:
    Boolean: True if lint test passes, False if not.
  """
    docs_dir, _ = split_doc_path(args["path"])

    # Only applicable for RTL languages.
    if str(docs_dir) != "site/ar":
        return True

    cell_source = args["cell_source"]

    # Ignore the text cells for copyright and buttons.
    if (has_copyright_re.search(cell_source)
            or is_button_cell_re.search(cell_source)):
        return True

    if has_rtl_div_re.search(cell_source):
        return True
    else:
        fail(
            "Wrap all text elements in `<div dir=\"rtl\">...</div>` for Colab. But check this doesn't break any Markdown syntax within."
        )
Exemplo n.º 2
0
def china_hostname_url(args):
    """Chinese docs should use tensorflow.google.cn as the URL hostname.

  Replace hostname 'www.tensorflow.org' with 'tensorflow.google.cn'.

  Args:
    args: Nested dict of runtime arguments.

  Returns:
    Boolean: True if lint test passes, False if not.
  """
    docs_dir, _ = split_doc_path(args["path"])

    if str(docs_dir) == "site/zh-cn" or str(docs_dir) == "site/zh-tw":
        if has_tf_hostname_re.search(args["cell_source"]):
            return False
        else:
            return True
    else:
        return True
Exemplo n.º 3
0
def china_hostname_url(args):
    """Chinese docs should use tensorflow.google.cn as the URL hostname.

  Replace hostname 'www.tensorflow.org' with 'tensorflow.google.cn'.

  Args:
    args: Nested dict of runtime arguments.

  Returns:
    Boolean: True if lint test passes, False if not.
  """
    docs_dir, _ = split_doc_path(args["path"])

    # Only applicable for China docs.
    if str(docs_dir) != "site/zh-cn" and str(docs_dir) != "site/zh-tw":
        return True

    if has_tf_hostname_re.search(args["cell_source"]):
        fail(fix=fix.regex_replace_all,
             fix_args=[has_tf_hostname_re.pattern, "tensorflow.google.cn"])
    else:
        return True