-
-
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
Documentation for RTD context sent to the Sphinx theme #3490
Conversation
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.
Raising some questions on the spec to start. I haven't looked at the copy so I'll mark this as changes required.
The overlap here that I discussed is that its currently difficult to take the information we're passing in to the theme and make calls against the API, as pks are missing from all of the lists of objects. This enables a landing page style project where templates can call our API and get subproject version and build information.
docs/theme-context.rst
Outdated
|
||
'readthedocs': { | ||
'version': { | ||
'name': str, |
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.
So on the version data, any reason not to just use a Version object serialized through DRF?
docs/theme-context.rst
Outdated
'epub': str | ||
} | ||
}, | ||
'project': { |
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.
Similar to above, I think we could just use a serialized Project instance here.
docs/theme-context.rst
Outdated
'single_version': bool, | ||
'versions': [ | ||
{ | ||
'slug': str, |
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.
More specifically, it is really helpful to be able to hit the API to fetch additional version/subproject information. If putting a fully serialized version object here doesn't make sense, we at least could use a version pk in this dict.
docs/theme-context.rst
Outdated
], | ||
'subprojects': [ | ||
{ | ||
'slug': str, |
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.
Similar to above regarding the list of versions, having more subproject fields here would be helpful for making a landing page, for example. This should either be a serialized Project, or at very least should include a pk.
If it makes sense, structuring this all as a DRF serializer might make sense, because we will eventually replace the footer html API endpoint with an endpoint that just returns the above context data. The client side JS will build up a navigation menu, not just copy HTML in. |
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.
I think the new spec looks good! There are some missing pieces we need to ensure get added however. I noted some grammar problems, but feel free to bring any of us in to clean that up. I noted so we can remember to clean that up before merge.
docs/theme-context.rst
Outdated
|
||
.. _html_context Sphinx setting: http://www.sphinx-doc.org/en/stable/config.html#confval-html_context | ||
|
||
Context injected by default |
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.
"by default" implies there is a non-default injection, which isn't user configurable. I think this can be dropped from the heading
docs/theme-context.rst
Outdated
Before calling `sphinx-build` to render your docs, Read the Docs injects some | ||
extra context in the templates by using the `html_context Sphinx setting`_ in | ||
the ``conf.py`` file. This extra context allows Read the Docs to add some | ||
features like "Edit on GitHub" and use a user custom Analytics code, among others. |
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.
Instead of describing the specific features, it's probably easiest to just say something along the lines of:
This extra context is used by the Read the Docs Sphinx theme to add additional features to the built documentation.
docs/theme-context.rst
Outdated
'MEDIA_URL': str, | ||
'PRODUCTION_DOMAIN': str, | ||
'READTHEDOCS': True | ||
} |
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 is missing subprojects
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.
Mjm, I finally removed the subprojects
because I supposed this was dynamic data that should be retrieved by JS. I wasn't really sure what to do here.
Isn't "dangerous" to make it static under this context? Won't this give us some problems in the future?
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.
I'm still not convinced on this argument about injecting dynamic data. It still seems like something that users could want for various reasons in their doc context, without having to render it via JS/API. "It might go out of date when a new version is built" doesn't seem like a compelling enough reason to not include the live data when the build happens. What if they just want to include a subset of the data that they know will always be valid, for example? Just because our user case requires fresh data, doesn't meal all use cases do.
We should warn users of the possible downsides of using this data, but not passing it in feels wrong to me.
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.
Good!
I re-structure the notes to be warnings and communicate the user some of the problems of using this static data and what would be the solution (using the API via JS). I wrote the idea, probably the English could be improved.
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.
I also added the subprojects
to the project
object; I'm not sure if I have to add the versions
also under this object or not.
docs/theme-context.rst
Outdated
.. note:: | ||
|
||
By design, Read the Docs passes only static information to `sphinx-build` | ||
to avoid versions to be inconsistent in case the project is updated after the version is built. |
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.
Grammar issue here at:
to avoid versions to be inconsistent
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.
I don't know how to fix it :)
"keep" instead of "to be"? :/
docs/theme-context.rst
Outdated
|
||
By design, Read the Docs passes only static information to `sphinx-build` | ||
to avoid versions to be inconsistent in case the project is updated after the version is built. | ||
In case you need more information than the context supplied here, you will |
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.
supplied -> supplies
docs/theme-context.rst
Outdated
|
||
.. note:: | ||
|
||
Take into account that the Read the Docs context is inject after your definition of ``html_context`` so, |
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.
is inject -> is injected
I worked on all the suggestions made by @agjohnson then only piece missing is the |
docs/theme-context.rst
Outdated
Before calling `sphinx-build` to render your docs, Read the Docs injects some | ||
extra context in the templates by using the `html_context Sphinx setting`_ in | ||
the ``conf.py`` file. This extra context is used by the Read the Docs Sphinx Theme | ||
to add additional features to the built documentation |
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.
Well, we use it, but the goal of this doc is to also make it usable by the user. I think we should communicate to the user why they should care about this doc, not why we use it. Do they really care why we use it? If so, it could easily be a section lower in the document explaining our usage, but not part of the introduction to the feature.
docs/theme-context.rst
Outdated
'htmlzip': str, | ||
'epub': str | ||
}, | ||
'resource_uri': '/api/v2/version/{pk}/' |
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.
is resource_uri
a standard term we use? I don't see it in our existing API v2 return values. Also, I think we should put a fully qualified URL (eg. https://readthedocs.org/api/v2/version/{pk}/`
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.
I took that name from the APIv1 http://docs.readthedocs.io/en/latest/api.html?highlight=resource_uri#get--api-v1-build-id-
But the standard way seems to be to add a links
object like:
"links": [
{
"href": "https://readthedocs.org/api/v2/version/{pk}/",
"rel": "self"
}
]
(I think we shouldn't make it a list, just a dict --but that is not standard)
docs/theme-context.rst
Outdated
'MEDIA_URL': str, | ||
'PRODUCTION_DOMAIN': str, | ||
'READTHEDOCS': True | ||
} |
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.
I'm still not convinced on this argument about injecting dynamic data. It still seems like something that users could want for various reasons in their doc context, without having to render it via JS/API. "It might go out of date when a new version is built" doesn't seem like a compelling enough reason to not include the live data when the build happens. What if they just want to include a subset of the data that they know will always be valid, for example? Just because our user case requires fresh data, doesn't meal all use cases do.
We should warn users of the possible downsides of using this data, but not passing it in feels wrong to me.
docs/theme-context.rst
Outdated
<p>This documentation was written by {{ author }} on {{ date }}.</p> | ||
|
||
|
||
.. note:: |
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.
Should probably be a warning
.
OK, I'm marking this one |
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.
LGTM, one small thing.
docs/theme-context.rst
Outdated
|
||
In this example, we are using ``pagename`` which is a Sphinx variable | ||
representing the name of the page you are on. More information about Sphinx | ||
variables can be found on `Sphinx documentation`_. |
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.
"on" --> "in the"
@agjohnson does everything look good now? |
docs/theme-context.rst
Outdated
Note that this dictionary is injected under the main key `readthedocs`: | ||
|
||
|
||
.. code:: python |
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.
Add a comment about where this info came from / how to update it
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 code will be injected (when this docs get coded) at this point: https://github.com/rtfd/readthedocs.org/blob/0c547f47fb9dffbeb17e4e9ccf205a10caf31189/readthedocs/doc_builder/backends/sphinx.py#L65
... and there is no way to "update" RTD values since they are injected at the bottom of the conf.py
after the values from the user.
So, do you think we should add that line of code to the docs? or you were thinking in another thing and I didn't get it? :)
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.
I was saying to add code comment for in the future we know where to generate the dictionary from.
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.
If I understood correctly, I already done this. Check my latest commit :)
Yep looks good |
I'm +1 on this, and think it would be a good thing to get moving, now that we have a spec :) The next steps are actually implementing the API described in the PR. |
Changes look good! There are a few more points to raise with the proposed feature decided on:
|
I'd say we can move this into a My thought was that this would be a new fancy addition that lives alongside the old API, which we'll keep around for a while. It isn't documented, so in theory we can remove it, but I think a lot of people depend on it, so I'd want to have numbers around usage and a long deprecation before we dropped it fully. |
We chatted about this some time ago and we say that we will mark the old one as deprecated and support both at the same time for a while. Then, remove the old one if that it's possible :/
If we don't remove what I've removed, we are documenting a chunk of the code that we want to remove :) --how to inject VCS in your template. Anyway, I could restore it and add a deprecation note pointing to what's planned to implement. What do you think?
Which one are those? We may probably want to remove them from the new specs if they are just for legacy compatibility.
How do we get these numbers? Also, also... In this issue was raised the ability to override our own configs, #2971, do we want to support this and rely on the user's configurations? |
I think
I'm not sure if we can. It's another ticket if we want to discuss it.
We should discuss that there. I think namespacing it in |
For now, that is my point I suppose. We aren't yet implementing any of these changes, and nothing should be deprecated yet (we have nothing in code to replace this context with yet). So until this happens, I'm suggesting our live docs don't reflect changes we want, it should reflect the reality of our production instance.
There aren't any settings that we're phasing out, I meant that as we move to a new schema for the context data we should probably mention that there is an old schema format, ie: I'm not sure we need to document things in depth, but we are a documentation company :) -- we should make not of these things that others are relying on. We won't be able to get rid of this context, or really deprecate it. We can't stop projects from relying on versions of our theme that rely on this context, so we're stuck with producing this context. We should treat this data as first class, just like the next generation of the schema. cc @humitos |
* build_date * HATEOAS for resources
1fa3325
to
4f911f4
Compare
This is an initial proposal for #3482 where I deleted the
vcs.rst
page since looks too obsolate for me and I added a new onetheme-context.rst
that explains all the information send to the Sphinx template but also propose a refactor of the data sent under a namespace. Besides, I removed a couple of unnecessary variables and reorder others.Closes #3482