Skip to content

API: review /_/readthedocs-config/ endpoint #10211

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

Closed
humitos opened this issue Mar 30, 2023 · 0 comments · Fixed by #10216
Closed

API: review /_/readthedocs-config/ endpoint #10211

humitos opened this issue Mar 30, 2023 · 0 comments · Fixed by #10216
Assignees

Comments

@humitos
Copy link
Member

humitos commented Mar 30, 2023

Take a look at the structure of this response and think about how we want to adapt it to support the initial phase of the js client. See readthedocs/addons#26

# TODO: define how it will be the exact JSON object returned here
# NOTE: we could use the APIv3 serializers for some of these objects
# if we want to keep consistency. However, those may require some
# extra db calls that we probably want to avoid.
data = {
"comment": (
"THIS RESPONSE IS IN ALPHA FOR TEST PURPOSES ONLY"
" AND IT'S GOING TO CHANGE COMPLETELY -- DO NOT USE IT!"
),
"project": {
"slug": project.slug,
"language": project.language,
"repository_url": project.repo,
"programming_language": project.programming_language,
},
"version": {
"slug": version.slug,
"external": version.type == EXTERNAL,
},
"build": {
"id": build.pk,
},
"domains": {
"dashboard": settings.PRODUCTION_DOMAIN,
},
"readthedocs": {
"analytics": {
"code": settings.GLOBAL_ANALYTICS_CODE,
},
},
"features": {
"analytics": {
"code": project.analytics_code,
},
"external_version_warning": {
"enabled": True,
"query_selector": "[role=main]",
},
"non_latest_version_warning": {
"enabled": True,
"query_selector": "[role=main]",
"versions": list(
project.versions.filter(active=True)
.only("slug")
.values_list("slug", flat=True)
),
},
"doc_diff": {
"enabled": True,
# "http://test-builds-local.devthedocs.org/en/latest/index.html"
"base_url": resolver.resolve(
project=project,
version_slug=project.get_default_version(),
language=project.language,
filename=unresolved_url.filename,
),
"root_selector": "[role=main]",
"inject_styles": True,
# NOTE: `base_host` and `base_page` are not required, since
# we are constructing the `base_url` in the backend instead
# of the frontend, as the doc-diff extension does.
"base_host": "",
"base_page": "",
},
"flyout": {
"translations": [],
"versions": [
{
"slug": version.slug,
"url": f"/{project.language}/{version.slug}/",
}
for version in project.versions.filter(active=True).only("slug")
],
"downloads": [],
# TODO: get this values properly
"vcs": {
"url": "https://github.com",
"username": "readthedocs",
"repository": "test-builds",
"branch": version.identifier,
"filepath": "/docs/index.rst",
},
},
"search": {
"project": project.slug,
"version": version.slug,
"api_endpoint": "/_/api/v3/search/",
# TODO: figure it out where this data comes from
"filters": [
[
"Search only in this project",
f"project:{project.slug}/{version.slug}",
],
[
"Search subprojects",
f"subprojects:{project.slug}/{version.slug}",
],
],
"default_filter": f"subprojects:{project.slug}/{version.slug}",
},
},
}

Besides, consider making the initial changes that will allow us use our current APIv3 serializers so we can standardize the way we are communicating our data in a more generic way through all our endpoints.

The idea is to use "the same structure that would be returned by the APIv3 serializers, but without using them for now" due to https://github.com/readthedocs/readthedocs-ops/issues/1323

@humitos humitos self-assigned this Mar 30, 2023
@github-project-automation github-project-automation bot moved this to Planned in 📍Roadmap Mar 30, 2023
@humitos humitos moved this from Planned to Needs review in 📍Roadmap Apr 3, 2023
@github-project-automation github-project-automation bot moved this from Needs review to Done in 📍Roadmap Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant