-
Notifications
You must be signed in to change notification settings - Fork 13
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
Fix namespacing problem #38
base: main
Are you sure you want to change the base?
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.
This approach seems reasonable. @agjohnson & @davidfischer, do y'all have thoughts on this approach to namespacing and overrides? We should likely standardize on something like this on our internal JS everywhere, so this can be a good test if it looks good.
@ericholscher |
I favor namespacing everything under |
@davidfischer can you expand a bit more on this? Is there a change to this PR needed? |
This screenshot illustrates what I'm talking about. If we suggest people define a new var READTHEDOCS = {
getInputField: function() {
var custom_search_bar = document.querySelector('.my-custom-search-bar');
return custom_search_bar;
}
} Rather than if the READTHEDOCS.getInputField: function() {
var custom_search_bar = document.querySelector('.my-custom-search-bar');
return custom_search_bar;
} This could open up a number of issues based on the order JS files are included. |
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.
Other than the comment above, I do want you to think about which functions you want users to override and which ones you don't. Only functions users might override should be on the READTHEDOCS
object. Functions like getInputField()
or fetchAndGenerateResults()
are ones that users or themes would definitely want to override. However, functions like createDomNode()
seem private/protected to search and not something the user would override.
@dojutsu-user Any update here? |
@ericholscher |
I will fix the conflicts and make this mergeable after merging of #42 |
@davidfischer Do you have anything in mind? |
@stsewd have you looked at this at all? |
I'm not sure to understand the use case for this. For the example in the docs, allowing to override For other customizations, I think we should provide classes/ids and document them so users can modify them using selectors in js/css. If we have a use case that can't be extended using that, I think we can consider allowing users to override some functionality. |
This is exactly the issue. The goal is to nest all the code under the |
@humitos Is this solved by our new module approach, I assume? |
In the new module, we don't have a global object. All the configs come from the API and cannot be edited, so this is not an issue there. We haven't defined the user API to interact with our extension yet. I have an issue opened to talk about these things and use the best/standard js-y approach we can: readthedocs/addons#13 I would appreciate feedback and ideas there 😄 |
Every function is now under
READTHEDOCS
object.Users have flexibility to override any of them. (Tested)