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
Embed: refactor view #7955
Conversation
- 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: |
There was a problem hiding this comment.
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
7473fca
to
3494f5f
Compare
Need to rebase to master to have a better diff :D |
) | ||
|
||
|
||
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): |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
Based on #7947