Skip to content

Commit

Permalink
Exclude TYPE_CHECKING from docs (#5261)
Browse files Browse the repository at this point in the history
This would be an attempt to fix #5231
  • Loading branch information
tonybruguier authored Apr 19, 2022
1 parent aa303dc commit f1d900f
Showing 1 changed file with 43 additions and 7 deletions.
50 changes: 43 additions & 7 deletions dev_tools/docs/build_api_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ def filter_unwanted_inherited_methods(path, parent, children):
return filtered_children


def filter_type_checking(path, parent, children):
filtered_children = []
for name, obj in children:
if name != 'TYPE_CHECKING':
filtered_children.append((name, obj))
return filtered_children


def main(unused_argv):
generate_cirq()
generate_cirq_google()
Expand All @@ -93,7 +101,11 @@ def generate_cirq():
code_url_prefix=FLAGS.code_url_prefix + "/cirq-core/cirq",
search_hints=FLAGS.search_hints,
site_path=FLAGS.site_path,
callbacks=[public_api.local_definitions_filter, filter_unwanted_inherited_methods],
callbacks=[
public_api.local_definitions_filter,
filter_unwanted_inherited_methods,
filter_type_checking,
],
extra_docs=_doc.RECORDED_CONST_DOCS,
)
doc_controls.decorate_all_class_attributes(
Expand All @@ -110,7 +122,11 @@ def generate_cirq_aqt():
code_url_prefix=FLAGS.code_url_prefix + "/cirq-aqt/cirq_aqt",
search_hints=FLAGS.search_hints,
site_path=FLAGS.site_path,
callbacks=[public_api.local_definitions_filter, filter_unwanted_inherited_methods],
callbacks=[
public_api.local_definitions_filter,
filter_unwanted_inherited_methods,
filter_type_checking,
],
extra_docs=_doc.RECORDED_CONST_DOCS,
)
doc_controls.decorate_all_class_attributes(
Expand All @@ -128,7 +144,11 @@ def generate_cirq_ionq():
code_url_prefix=FLAGS.code_url_prefix + "/cirq-ionq/cirq_ionq",
search_hints=FLAGS.search_hints,
site_path=FLAGS.site_path,
callbacks=[public_api.local_definitions_filter, filter_unwanted_inherited_methods],
callbacks=[
public_api.local_definitions_filter,
filter_unwanted_inherited_methods,
filter_type_checking,
],
extra_docs=_doc.RECORDED_CONST_DOCS,
)
doc_controls.decorate_all_class_attributes(
Expand All @@ -146,7 +166,11 @@ def generate_cirq_pasqal():
code_url_prefix=FLAGS.code_url_prefix + "/cirq-pasqal/cirq_pasqal",
search_hints=FLAGS.search_hints,
site_path=FLAGS.site_path,
callbacks=[public_api.local_definitions_filter, filter_unwanted_inherited_methods],
callbacks=[
public_api.local_definitions_filter,
filter_unwanted_inherited_methods,
filter_type_checking,
],
extra_docs=_doc.RECORDED_CONST_DOCS,
)
doc_controls.decorate_all_class_attributes(
Expand All @@ -164,7 +188,11 @@ def generate_cirq_rigetti():
code_url_prefix=FLAGS.code_url_prefix + "/cirq-rigetti/cirq_rigetti",
search_hints=FLAGS.search_hints,
site_path=FLAGS.site_path,
callbacks=[public_api.local_definitions_filter, filter_unwanted_inherited_methods],
callbacks=[
public_api.local_definitions_filter,
filter_unwanted_inherited_methods,
filter_type_checking,
],
extra_docs=_doc.RECORDED_CONST_DOCS,
)
doc_controls.decorate_all_class_attributes(
Expand All @@ -182,7 +210,11 @@ def generate_cirq_google():
code_url_prefix=FLAGS.code_url_prefix + "/cirq-google/cirq_google",
search_hints=FLAGS.search_hints,
site_path=FLAGS.site_path,
callbacks=[public_api.local_definitions_filter, filter_unwanted_inherited_methods],
callbacks=[
public_api.local_definitions_filter,
filter_unwanted_inherited_methods,
filter_type_checking,
],
private_map={
# Opt to not build docs for these paths for now since they error.
"cirq_google.cloud.quantum.QuantumEngineServiceClient": ["enums"],
Expand All @@ -202,7 +234,11 @@ def generate_cirq_web():
code_url_prefix=FLAGS.code_url_prefix + "/cirq-web/cirq_web",
search_hints=FLAGS.search_hints,
site_path=FLAGS.site_path,
callbacks=[public_api.local_definitions_filter, filter_unwanted_inherited_methods],
callbacks=[
public_api.local_definitions_filter,
filter_unwanted_inherited_methods,
filter_type_checking,
],
extra_docs=_doc.RECORDED_CONST_DOCS,
)
doc_controls.decorate_all_class_attributes(
Expand Down

0 comments on commit f1d900f

Please sign in to comment.