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

Embed: refactor view #7955

Merged
merged 5 commits into from Mar 2, 2021
Merged

Embed: refactor view #7955

merged 5 commits into from Mar 2, 2021

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Feb 24, 2021

  • Use version.is_sphinx_type to choose between mkdocs or sphinx
  • Avoid nested code
  • Check for multiple queries inside a loop instead of several if's
  • Clean links only to the end result node, not to the whole body

Based on #7947

stsewd and others added 3 commits February 23, 2021 19:01
- Make them more readable by splitting the html from the json file,
  similarly to what we do with the search tests.
- Don't do two calls to storage, just open the file.
- Remove unused requests adaptor (probably was something used before
  storage)

Didn't bother to split the mkdocs json file,
since that mkdocs doesn't output that kind of format anymore,
we should start reading from the html file itself.
Co-authored-by: Manuel Kaufmann <humitos@gmail.com>

if not section and headers:
# If no section is sent, return the content of the first one
# TODO: This will always be the full page content,
# lets do something smarter here
section = list(headers[0].keys())[0].lower()

if section:
Copy link
Member Author

Choose a reason for hiding this comment

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

Here only this big if was removed and the query_obj changed, everything else is the same.

- Use version.is_sphinx_type to choose between mkdocs or sphinx
- Avoid nested code
- Check for multiple queries inside a loop instead of several if's
- Clean links only to the end result node, not to the whole body
Base automatically changed from refactor-embed-tests to master February 24, 2021 23:35
@stsewd
Copy link
Member Author

stsewd commented Feb 24, 2021

Need to rebase to master to have a better diff :D

@stsewd stsewd requested a review from a team February 24, 2021 23:49
@stsewd stsewd mentioned this pull request Feb 25, 2021
)


class EmbedAPI(SettingsOverrideObject):
_default_class = EmbedAPIBase


def do_embed(project, version, doc, section=None, path=None, url=None):
def do_embed(*, project, version, doc=None, path=None, section=None, url=None):
Copy link
Member

Choose a reason for hiding this comment

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

We are changing the signature of the function here. doc was required previously and now it's not. Why it's not required anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

doc is the pagename, that's sphinx specific (isn't required when the project is mkdocs type as you can see below), and isn't required to get the response if path and section are given.

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

This looks good to me.

@stsewd stsewd merged commit d452f12 into master Mar 2, 2021
@stsewd stsewd deleted the refactor-embed-view branch March 2, 2021 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants