Skip to content
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

New CustomScript addon #431

Merged
merged 5 commits into from
Nov 18, 2024
Merged

New CustomScript addon #431

merged 5 commits into from
Nov 18, 2024

Conversation

humitos
Copy link
Member

@humitos humitos commented Nov 13, 2024

This is a new addon that allow users to inject a specific JavaScript file to all the versions to all the documentation pages to allow them to fix issues in old "frozen" (not able to re-build) versions.

Requires readthedocs/readthedocs.org#11758

This is a new addon that allow users to inject a specific JavaScript file to all
the versions to all the documentation pages to allow them to fix issues in old
"frozen" (not able to re-build) versions.

Requires readthedocs/readthedocs.org#11758
Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code here looks great, I did raise some questions at readthedocs/readthedocs.org#11758 -- namely the feature naming could be reflected here.

@humitos humitos changed the title New UserJsFile addon New CustomScript addon Nov 14, 2024
humitos added a commit to readthedocs/readthedocs.org that referenced this pull request Nov 18, 2024
We talked about giving users a way to inject a JavaScript file they
control using our Cloudflare Worker infrastructure to allow them
manipulate frozen documentations.

This could be used in different ways to fix bugs or add features to a
particular frozen set of docs or even to all the versions. The user can
make usage of API data to filter by version or not
(e.g. `if (versions.current == "v3.0") { .. do something ...} `)

The script could live in Read the Docs itself using a relative URL, or
outside it, using an absolute URL.


### Example using Sphinx

1. [Tell Sphinx to include `static`
folder](https://github.com/readthedocs/test-builds/blob/full-feature/docs/conf.py#L25)
2. [Include a `readthedocs.js` file in your
project](https://github.com/readthedocs/test-builds/blob/full-feature/docs/static/readthedocs.js)
3. Make `AddonsConfig.userjsfile_src` to be
`/en/full-feature/readthedocs.js` from addons admin UX

The console will render the following:


![Screenshot_2024-11-11_18-13-59](https://github.com/user-attachments/assets/9fa46525-3b20-4d88-9950-f0a93a1199ab)

Related #11474
Related readthedocs/addons#431
@humitos humitos merged commit 0b605f6 into main Nov 18, 2024
4 checks passed
@humitos humitos deleted the humitos/userjsfile-addon branch November 18, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants