From d9c4bb7b860aa5d12c21bebaf10e3e20a4400572 Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Wed, 6 Oct 2021 13:58:49 +0200 Subject: [PATCH 1/3] EmbedAPIv3: docs for endpoint and guide updated --- docs/api/v3.rst | 39 +++++++++++++++++++++++++++++++ docs/guides/embedding-content.rst | 29 ++++++++++------------- readthedocs/embed/v3/views.py | 2 +- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/docs/api/v3.rst b/docs/api/v3.rst index 6c42647ab96..ad56ca16d85 100644 --- a/docs/api/v3.rst +++ b/docs/api/v3.rst @@ -1826,6 +1826,45 @@ Remote Repository listing :requestheader Authorization: token to authenticate. +Embed +----- + +.. http:get:: /api/v3/embed/ + + Retrieve HTML-formatted content from documentation page or section. + + **Example request**: + + .. prompt:: bash $ + + curl https://readthedocs.org/api/v3/embed/?url=https://docs.readthedocs.io/en/latest/features.html%23read-the-docs-features + + **Example response**: + + .. sourcecode:: js + + { + "url": "https://docs.readthedocs.io/en/latest/features.html#read-the-docs-features", + "fragment": "read-the-docs-features", + "content": "
\n

Read the Docs ...", + "external": false + } + + :>json string url: URL of the document. + :>json string fragment: fragmet part of the URL used to query the page. + :>json string content: HTML content of the section. + :>json string external: whether or not the page is hosted on Read the Docs or externally. + + :query string url: full URL of the document (with optional fragment) to fetch content from. + :query string doctool: *optional* documentation tool key name used to generate the target documentation (e.g. ``sphinx``) + :query string doctoolversion: *optional* documentation tool version used to generate the target documentation (e.g. ``4.2.0``). + + .. note:: + + Passing ``?doctool=`` and ``?doctoolversion=`` may make the response to behave better, + since the endpoint will know more about the exact structure of the HTML and can make better decisions. + + Additional APIs --------------- diff --git a/docs/guides/embedding-content.rst b/docs/guides/embedding-content.rst index 3ce97910fb9..9207d0f3026 100644 --- a/docs/guides/embedding-content.rst +++ b/docs/guides/embedding-content.rst @@ -1,7 +1,8 @@ Embedding Content From Your Documentation ========================================= -Read the Docs allows you to embed content from any of the projects we host. +Read the Docs allows you to embed content from any of the projects we host and specific allowed external domains +(currently, :djangosetting:`RTD_EMBED_API_EXTERNAL_DOMAINS`) This allows reuse of content across sites, making sure the content is always up to date. There are a number of uses cases for embedding content, @@ -57,12 +58,11 @@ from our own docs and will populate the content of it into the ``#help-container