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

[MAINTENANCE] Use shortened dotted paths in api docs #6831

Merged
merged 6 commits into from Jan 19, 2023

Conversation

anthonyburdi
Copy link
Member

@anthonyburdi anthonyburdi commented Jan 18, 2023

Changes proposed in this pull request:

  • Use shortened paths in API docs. E.g. if a class is imported in a parent __init__.py file use that instead of the file with the class definition. For example, great_expectations.core.ExpectationSuite instead of great_expectations.core.expectation_suite.ExpectationSuite. This appears in API docs in the class definitions.

Definition of Done

  • My code follows the Great Expectations style guide
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added unit tests where applicable and made sure that new and existing tests are passing.
  • I have run any local integration tests and made sure that nothing is broken.

@netlify
Copy link

netlify bot commented Jan 18, 2023

Deploy Preview for niobium-lead-7998 ready!

Name Link
🔨 Latest commit 0a1c484
🔍 Latest deploy log https://app.netlify.com/sites/niobium-lead-7998/deploys/63c87edb1a84e60009c1531e
😎 Deploy Preview https://deploy-preview-6831--niobium-lead-7998.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@ghost
Copy link

ghost commented Jan 18, 2023

👇 Click on the image for a new way to code review
  • Make big changes easier — review code in small groups of related files

  • Know where to start — see the whole change at a glance

  • Take a code tour — explore the change with an interactive tour

  • Make comments and review — all fully sync’ed with github

    Try it now!

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@anthonyburdi anthonyburdi enabled auto-merge (squash) January 18, 2023 22:11
Comment on lines +377 to +379
def get_shortest_dotted_path(
definition: Definition, repo_root_path: pathlib.Path
) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Comment on lines +406 to +423
while path_parts:
# Keep traversing, shortening path if shorter path is found.
path_parts.pop()
# if __init__.py is found, ast parse and check for import of the class
init_path = repo_root_path / pathlib.Path(*path_parts, "__init__.py")
if init_path.is_file():

import_names = []
with open(init_path) as f:
file_contents: str = f.read()

import_names.extend(_get_import_names(file_contents))

# If name is found in imports, shorten path to where __init__.py is found
if definition.name in import_names:
shortest_path_prefix = str(".".join(path_parts))
shortest_path = f"{shortest_path_prefix}.{definition.name}"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Copy link
Contributor

@Shinnnyshinshin Shinnnyshinshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love it. Thank you @anthonyburdi

@anthonyburdi anthonyburdi merged commit e6983e0 into develop Jan 19, 2023
@anthonyburdi anthonyburdi deleted the m/dx-218/use_shortened_dotted_paths_in_api_docs branch January 19, 2023 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants