Skip to content

Commit

Permalink
[SNOW-1694712] Remove _emit_ast and _ast from docs. (#2701)
Browse files Browse the repository at this point in the history
1. Which Jira issue is this PR addressing? Make sure that there is an
accompanying issue to your PR.

Fixes[SNOW-1694712](https://snowflakecomputing.atlassian.net/browse/SNOW-1694712)

2. Fill out the following pre-review checklist:

- [ ] I am adding a new automated test(s) to verify correctness of my
new code
- [ ] If this test skips Local Testing mode, I'm requesting review from
@snowflakedb/local-testing
   - [ ] I am adding new logging messages
   - [ ] I am adding a new telemetry message
   - [ ] I am adding new credentials
   - [ ] I am adding a new dependency
- [ ] If this is a new feature/behavior, I'm adding the Local Testing
parity changes.
- [x] I acknowledge that I have ensured my changes to be thread-safe.
Follow the link for more information: [Thread-safe Developer
Guidelines](https://github.com/snowflakedb/snowpark-python/blob/main/CONTRIBUTING.md#thread-safe-development)

4. Please describe how your code solves the related issue.

AST introduces in function signatures (private) parameters `_emit_ast`
and `_ast`. This PR modifies the sphinx-build to not emit these
parameters into the docs. To check that the generation is successful,
run e.e. from the `docs` folder
```
grep -rl --include "*.html" "_emit_ast" build/html
grep -rl --include "*.html" "_ast" build/html
```
  • Loading branch information
sfc-gh-lspiegelberg authored Dec 5, 2024
1 parent 6d56214 commit 41fb8d5
Showing 1 changed file with 30 additions and 5 deletions.
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 f'({signature})'
else:
return signature

if signature:
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}"
)

0 comments on commit 41fb8d5

Please sign in to comment.