GSOC 2019: Autobuild Documentation for Pull Requests¶
Building documentation for pull requests is one of the most requested features of Read the Docs. Similar to how a continuous integration system runs a test suite on every pull request, this change would build the documentation for each pull request and send build status notification to the providers’ Status API (e.g. Github Status API). This will let users check if the documentation build passed and also how the documentation looks before merging it to master.
As a student of Google Summer of Code (GSoC) 2019, I (Maksudul Haque) was tasked with building this feature. The main goal of my project was to make it possible to build documentation whenever a pull request was created, and send build status notification to the Providers’ Status API.
To see this feature in action you can click on one of the pull requests on readthedocs.org repository.
Google Summer of Code¶
Google Summer of Code is a global program where students work with an open source organization on a 3 month programming project. Autobuild Documentation for Pull Requests was one of the project ideas on Read the Docs Project Ideas for Google Summer of Code 2019. I applied for the project and got accepted.
I started working on this project since May 2019. All of my work on this project can be seen in the Pull Request Builder Board.
Background¶
Many of our users wanted a way to visualize the documentation update that was made in a pull request. They also want to know whether the documentation build will pass before merging the pull request to master. This would allow users to have more confidence on the pull request and make the pull request less likely to break the documentation after merging. So, to achieve this Read the Docs core team selected Autobuild Documentation for Pull Requests as one of the projects of Google Summer of Code 2019.
Pull Request Builder Features¶
Currently I have implemented these features and working on more upcoming features. Some of the major features are as follows:
- Creating External Versions: We create an external version when we receive a pull request webhook event for a project from GitHub and trigger a build for that version. External versions are short-lived versions that are separate from the project’s main documentation.
- Synchronizing External Versions: Whenever there is a new commit on the pull request, we synchronize the external version for that pull request and trigger a new documentation build with the latest changes.
- Deleting External Versions: Whenever the pull request is closed or merged, we delete the external Version associated with that pull request.
- Warning Banner for pull request documentation: While building documentation for pull requests we add a warning banner at the top of those documentations to let the users know that this documentation was generated for pull requests and is not the main documentation for the project.
We send build status reports to the status API of the provider (e.g. GitHub). When a build is triggered for a pull request we send build pending notification with the build URL and after the build has finished we send success notification if the build succeeded without any error or failure notification if the build failed. By going to the build URL provided in the status report users can view the build steps and also see the documentation generated by that build.
Currently, we only support GitHub and planning to extend to GitLab and BitBucket.
Getting Started¶
Building documentation for pull requests is currently in Beta testing and only supports Github repositories. If you want to dive in and enable this feature for your project you can email us with the URL of your ReadtheDocs project.
Future Improvements¶
We are planing to extend this feature to other platforms such as GitLab and BitBucket.
We are also planning to make this feature more customizable through our configuration file (.readthedocs.yaml
).
If you have any improvements or features in mind for building documentation for Pull requests we would love to know about it.
Please feel free to let us know by submitting an issue on GitHub.
Contributors Wanted¶
As Read the Docs is an open source project backed by a small team of developers, most of them are busy to keep things up and running only. Therefore, its quite hard for them to take time to implement new features. We would like to get more contributors to improve this feature. If you know a bit of Django and Python and interested to improve this feature you are always welcome to contribute. If you need any support to start contributing, you can get in touch with me or any other member of Read the Docs team. You can find all of us at #readthedocs freenode IRC channel or readthedocs gitter channel. I am saadmk11 at IRC and @saadmk11 at gitter.
Conclusion¶
To conclude, I would like to say this was a much needed feature for Read the Docs and also its users. This feature will improve our platform and make it a true Continuous Documentation platform. I think that many users will benefit from this feature. We will keep making improvements along the way for a better user experience.