readthedocs / addons

JavaScript client to integrate with Read the Docs nicely
https://readthedocs-addons.readthedocs.io/
MIT License
20 stars 5 forks source link

File tree diff client #409

Open stsewd opened 2 weeks ago

stsewd commented 2 weeks ago

With https://github.com/readthedocs/readthedocs.org/pull/11646/, we are now exposing the file tree diff information to addons, but we still need to have a way to show the results to users.

What I'm thinking here is to have a small list of the changed files (the first 2 or 3 files of each category), and then have a "show all files" button that will open a popup with the list of the files, this list will have some options to filter the results (modified, added, deleted) and a search bar.

We can also expose a button that suggest how to create a redirect for files that were deleted.

ericholscher commented 2 weeks ago

I think to start, even just outputting the data to the console, or as a <details> tag in the PR build warning seem like a good initial implantation. Just something where we can start surfacing the data to start playing with in dev.

TheTripleV commented 1 week ago

This is nice to have. We currently have a sphinx extension that does this for us with git. https://github.com/wpilibsuite/sphinxext-delta

It injects a new main toctree section that lists all the pages that have changed.

https://frc-docs--2680.org.readthedocs.build/en/2680/index.html

is an example of a PR build with the "pr changed files" toctree added. We're currently fixing failures in this extension because RTD doesn't inject all the html context anymore.

humitos commented 2 days ago

I checked the API response returned at https://docs--11716.org.readthedocs.build/en/11716/

        "filetreediff": {
            "diff": {
                "added": [
                    {
                        "file": "guides/management/2fa.html"
                    }
                ],

It seems the file attribute is not a valid URL, but the path of the file on disk that changed. We will need to resolve all those paths into valid URLs in the backend and expose them to the frontend to generate the links from JavaScript. We can probably add a url attribute in the API response as well.

In this particular case, the URL we are looking for here would be /en/11716/guides/management/2fa.html.