diff --git a/doc-build/third_party/hf-doc-builder/src/doc_builder/autodoc.py b/doc-build/third_party/hf-doc-builder/src/doc_builder/autodoc.py
index 5d79bdb2..dc6d1105 100644
--- a/doc-build/third_party/hf-doc-builder/src/doc_builder/autodoc.py
+++ b/doc-build/third_party/hf-doc-builder/src/doc_builder/autodoc.py
@@ -18,9 +18,9 @@
import importlib
import inspect
-import types
import json
import re
+import types
from .convert_md_to_mdx import convert_md_docstring_to_mdx
from .convert_rst_to_mdx import convert_rst_docstring_to_mdx, find_indent, is_empty_line
@@ -47,7 +47,8 @@ def find_object_in_package(object_name, package):
try:
importlib.import_module(f"{package.__name__}.{split}")
submodule = getattr(module, split, None)
- except ImportError:
+ except ImportError as e:
+ print(f"In find_object_in_package: {e}")
pass
module = submodule
if module is None:
@@ -203,7 +204,7 @@ def regex_closure(object_doc, regex):
url = source_link
else:
url = ""
-
+
if len(name.split()) > 1:
obj_type = name.split()[0]
obj_name = name.split()[1]
@@ -211,24 +212,24 @@ def regex_closure(object_doc, regex):
obj_type = ""
obj_name = name
- title_str = f"
\n"
+ title_str = f'\n'
svelte_str += title_str
sig_list = []
for item in signature:
- name = item['name']
- value = item['val']
-
+ name = item["name"]
+ value = item["val"]
+
if value:
- sig_list.append(f'{name}{value}')
+ sig_list.append(f"{name}{value}")
else:
sig_list.append(name)
-
- sig_str = ', '.join(sig_list)
+
+ sig_str = ", ".join(sig_list)
# param_sig_str = param_sig_str.replace('`', '\`')
sig_str = f"{{`{sig_str}`}}\n"
- svelte_str += r'{}'.format(sig_str)
+ svelte_str += r"{}".format(sig_str)
# if is_getset_desc:
# svelte_str += ""
@@ -238,11 +239,11 @@ def regex_closure(object_doc, regex):
groups = _re_parameter_group.split(parameters)
group_default = groups.pop(0)
group_default = repr(group_default)
- group_default = group_default.replace('`', '\`')
+ group_default = group_default.replace("`", "\`")
parameters_str += f"{{{group_default}}}\n"
-
+
# ignore for React + MDX
- #
+ #
# n_groups = len(groups) // 2
# for idx in range(n_groups):
# id = idx + 1
@@ -257,30 +258,30 @@ def regex_closure(object_doc, regex):
returntype = ""
if return_description is None:
return_description = ""
-
+
if returntype or return_description:
- svelte_str += f"\n"
+ svelte_str += f'\n'
if yieldtype is None:
yieldtype = ""
if yield_description is None:
yield_description = ""
if yieldtype or yield_description:
- svelte_str += f"\n"
+ svelte_str += f'\n'
if raise_description is None:
raise_description = ""
if raisederrors is None:
raisederrors = ""
if raisederrors or raise_description:
- svelte_str += f"\n"
+ svelte_str += f'\n'
svelte_str += "\n"
-
- svelte_str += '\n'
- svelte_str += '
'
+
+ svelte_str += "
\n"
+ svelte_str += '
'
svelte_str += f"\n{object_doc}\n"
- svelte_str += '
\n'
+ svelte_str += "
\n"
return svelte_str
@@ -330,10 +331,10 @@ def add_example_svelte_blocks(match):
id_str = "" if example_id == 1 else f"-{example_id}"
example_anchor = f"{object_anchor}.example{id_str}"
content = match.group(1)
-
+
content = repr(content)
- content = content.replace('`', '\`')
- return f'\n'
+ content = content.replace("`", "\`")
+ return f"\n"
object_doc = _re_example_codeblock.sub(add_example_svelte_blocks, object_doc)
return object_doc
@@ -468,9 +469,7 @@ def document_object(object_name, package, page_info, full_name=True, anchor_name
# tokenizers obj do NOT have `__module__` attribute & can NOT be used with inspect.getsourcelines
source_link = None
is_getset_desc = is_getset_descriptor(obj)
- component = get_signature_component(
- signature_name, anchor_name, signature, object_doc, source_link, is_getset_desc
- )
+ component = get_signature_component(signature_name, anchor_name, signature, object_doc, source_link, is_getset_desc)
documentation = "\n" + component + "\n"
return documentation, check
@@ -566,7 +565,7 @@ def autodoc(object_name, package, methods=None, return_anchors=False, page_info=
)
if check is not None:
errors.append(check)
- documentation += f'\n' + method_doc + ""
+ documentation += f"\n" + method_doc + ""
if return_anchors:
# The anchor name of the method might be different from its
method = find_object_in_package(f"{anchors[0]}.{method}", package=package)
@@ -575,7 +574,7 @@ def autodoc(object_name, package, methods=None, return_anchors=False, page_info=
anchors.append(anchor_name)
else:
anchors.append((anchor_name, method_name))
- documentation = f'\n' + documentation + "\n"
+ documentation = f"\n" + documentation + "\n"
return (documentation, anchors, errors) if return_anchors else documentation