Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SNOW-1694712] Remove _emit_ast and _ast from docs. #2701

Merged
merged 5 commits into from
Dec 5, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@
"_themes",
]

# Override default RTD css to get a larger width
# def setup(app):
# app.add_stylesheet('theme_overrides.css')

html_theme_options = {
# 'analytics_id': 'UA-XXXXXXX-1',
}
Expand Down Expand Up @@ -287,6 +283,30 @@ def process_modin_accessors(args):
return list(map(process_modin_accessors, items))
return items

def process_signature(app, what, name, obj, options, signature, return_annotation):

# Names to remove from signature (AST related):
names_to_remove = ['_emit_ast', '_ast']

def remove_from_signature(signature, name_to_remove):
if name_to_remove not in signature:
return signature

if signature.startswith('(') and signature.endswith(')'):
# temporarily remove parentheses, add after removing name_to_remove parts.
signature = signature[1:-1]
parts = [p for p in signature.split(',') if name_to_remove not in p]
signature = ','.join(parts)

return '(' + signature + ')'
sfc-gh-lspiegelberg marked this conversation as resolved.
Show resolved Hide resolved
else:
return signature

if signature and any(name_to_remove in signature for name_to_remove in ['_emit_ast', '_ast']):
sfc-gh-lspiegelberg marked this conversation as resolved.
Show resolved Hide resolved
for name_to_remove in names_to_remove:
signature = remove_from_signature(signature, name_to_remove)

return (signature, return_annotation)

def setup(app):
# Make sure modin.pandas namespace is properly set up
Expand All @@ -300,7 +320,7 @@ def setup(app):
# WARNING: [autosummary] failed to import modin.pandas.Series.str.slice.
# Possible hints:
# * AttributeError: 'property' object has no attribute 'slice'
# * ImportError:
# * ImportError:
# * ModuleNotFoundError: No module named 'modin.pandas.Series'
#
# Because we're replacing the `property` object, we also need to set the __doc__ of the new
Expand All @@ -323,6 +343,10 @@ def setup(app):
app.add_autodocumenter(ModinAccessorAttributeDocumenter)
app.add_directive("autosummary", ModinAutosummary)

# For Snowpark IR, in phase0 a hidden parameter _emit_ast is introduced. Once phase1 completes,
# this parameter will be removed. Automatically remove _emit_ast for now from docs to avoid confusion.
app.connect("autodoc-process-signature", process_signature)


# We overwrite the existing "autosummary" directive in order to properly resolve names for modin
# accessor classes. We cannot simply declare an alternative directive like "automodinsummary" to use
Expand Down Expand Up @@ -370,3 +394,4 @@ def linkcode_resolve(domain, info):
f"https://github.com/snowflakedb/snowpark-python/blob/"
f"v{release}/{os.path.relpath(fn, start=os.pardir)}{linespec}"
)

Loading