-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add more context data to embed API #7117
Comments
In the v3 of this API we are only allowing
What would be the use case for this? I imagine that a set of English documentation should use Embed API with English URLs, Spanish docs should use Spanish URLs, and so on. What's a useful case to do In case the front-end shows different languages on the same URL, the client could tweak the URL to change Besides, this is a Read the Docs-specific feature that won't have any effect on external sites. (In case we really want this behavior on the Embed API, we should think about implementing this at the core of Read the Docs: hitting a Japanese version of a documentation's page that does not exist but the English/source language does, it should redirect to it. Example: https://docs.readthedocs.io/ja/development/install.html -> https://docs.readthedocs.io/en/development/install.html) |
How are we planning on returning localized embed content to the user? The embedding source needs to specifically ask for the language as part of the URL?
To clarify, I mentioned that this was for project dashboard page -- I'm using the embed client directly. It sounds like you're mostly considering the use case of my suggestions for hoverxref. My use case was that I would like localized embedded content in the dashboard UI -- not in our docs. Currently, it sounds like what you're describing is that I would:
So hopefully that illustrates the problem a bit more. If there is no spanish locale, with content at
I'm describing a I only suggested a |
Yes.
Yes. It will return 404.
Me too. The only way of using Embed APIv3 is passing |
I think some of this confusion comes from how you are using the endpoint in hoverxref and how customers would be using the endpoint directly, or via a JS client. Did we combine the concept of 2 or more API endpoints into one at some point? I'm not exactly sure where my use case -- reusing documentation metadata like TOC and heading, available from Sphinx -- is supposed to be sourced from now. It might help to talk through the use case I have, as a user of the embed data directly.
I'm confused then, what is the URL
So this is confusing then, it doesn't seem like there is anything Sphinx specific about Overall, this isn't a huge blocker. Users shouldn't need to use this endpoint directly. We should have a JS client library, and that client should handle reconstruction of URLs with variable language/versions. This does seem a bit unnecessary though. It seems like we're duplicating application logic in JS because of a constraint we introduced in the middle to make the endpoint driven by |
We move away from it because:
Because of these points (and maybe others that I don't have in mind now), we thought it would be good to simplify its usage to the general case that support all the cases we had. The simpler to better to me, and I think that's the usage of (re multiple arguments, we are talking about this at #8222 (comment) as well --just linking as reference here-- it's a 🌶️ topic, hehe) |
So I thought about this a bit more after our discussion. The above does make sense, though I might have an broader interpretation of how these endpoints might be used because I'm considering a different feature -- driven by a common JS client library that we would maintain. If we were to support application resolution of default locale/version with our embed API endpoint, two endpoints seems like it would be the best direction -- one endpoint for querying embed data on your RTD project (supporting language/version/path), one endpoint for your RTD project to query embed data other projects. I thought a bit through how I might author a client JS library, and what usage would look like, and I came back to the conclusion that an endpoint that only supports For illustration, this is what I would like to maintain in my application, as a potential user of Read the Docs toctree embedded inside my application: I would bring a JS client library into my application's HTML. An illustration of what a template in my application HTML could look like would be: <div
data-embed="toc"
data-embed-url="https://docs.readthedocs.io/{{ request.user.locale }}/{{ settings.VERSION }}/features/foo.html"
data-embed-fallback-url="https://docs.readthedocs.io/en/stable/features/foo.html">
</div> This is actually fairly clean, it's not bad compared to other options. While manipulating the URL and fallback URL directly isn't great, the endpoint doesn't matter too much if we are not going to support resolving to a default locale/version in our API endpoints. If we are pushing this resolution onto a client JS library, the best we can do is to try a URL, and retry the fallback URL if we get a 404. The above example does require 2 requests whenever the preferred URL doesn't exist, and only supports the combinations Multiple requests can be avoided by resolving locale/version at the API endpoint, if we are to implement this. Multiple requests isn't awful, but does double latency. |
Anyways, that leaves heading nesting on my list, and we weren't clear on that one, because it sounded hard to do by parsing HTML. |
I think we moved away from the idea of showing "automatic section links" in our new dashboard, and we changed this pattern to use links manually added in the template itself. I think we can close this issue without implementing it in the new Embed APIv3. |
Well, we moved away mostly because this feature was removed in the API and we couldn't continue building on top. For now, we're manually adding links and link text to the application, and these are bound to break or page titles/etc will go out of sync. I still think there is a really good user feature that we're not developing here. The feature I've wanted to give users is a way to specify a page name in an external site and our API and some JS turn that page name into a link to the page, with the page title resolved. This is basically intersphinx in HTML, for external sites. It would be great if the page TOC was surfaced too, but that is sounding hard. But maybe the best direction here would instead be an embedded search result feature for external sites. In this case, the user would instead only provide a search term, and client-side JS would hit our API to get the results and output the page and page links. This would return hits to specific sections, and would automatically get up to date page title information/etc. This wouldn't involve parsing anything we're not parsing already, and would make users more familiar with our search. This might be an entry point for using our addons JS on external sites even -- for example, an embedded search block web component that can open our search as you type feature. Maybe it's even already possible to build on top of search like this? |
IMHO (and pretty personal also), I think my understanding of what you are describing looks complex comparing the value / use case we are talking about here: "show some help links (with page titles in sync) in the dashboard". Maybe this issue could be treated as a new feature request and we can have a more high level conversation about it. That conversation may help me understand more the benefits of a feature like this and be more motivated to collaborate with the idea. Currently, the pattern we have for our own dashboard and our workflow seems enough. Mainly, because we don't update our documentation that often to get those page titles out of sync frequently. Even if they get out of sync, it's not a huge problem if the titles don't exactly match and also, they are easy to update. I wouldn't build this if it's just of us and we don't have customers asking for this feature with more details about their exact use-case. |
I'd say an embedded search feature would be a bit more than this use case though, as the point would also be to surface the documentation search UI.
Yeah this would definitely be more on the experimental side. But it would take a proof of concept either way I think. Users aren't always going to tell us what features to build, we'd need to give them something to use first for something like this. |
While implementing embed docs topics via the API for our project admin pages, I got to play with the API and found some pieces that I wanted.
These might make good additions as API return or potentially we just do this as a javascript client side (which is ultimately how I'm manipulating the content now).
https://docs.readthedocs.io/en/stable
always, but the embed API would use accept language header to lookup a translation, if it exists, and return the embed data from that translation.translation
argument or something for the accepted languageWe should decide if any of these are worth pursuing and decide where they might land -- either as API features or on the client side javascript library TBD.
The text was updated successfully, but these errors were encountered: