Skip to content

Performance

使用 git sparse-checkout 加快文档构建速度

¥Using git sparse-checkout for faster documentation builds

利用 GitHub Actions 中的 git sparse-checkout,我们可以加快存储库中的文档构建速度,将签出时间从 20 到 30 秒缩短到仅 2 秒。

¥Leveraging git sparse-checkout in GitHub Actions enabled us to speed up documentation builds in our repository, cutting checkout times from 20 to 30 seconds to just 2 seconds.

在持续集成 (CI) 工作流中,开发一种高效的文档构建方法至关重要,尤其是在像我们这样拥有数千条提交记录的大型代码库中工作时。当然,我们希望快速高效地构建文档,确保快速高效的工作流程。在使用出色的git-committersgit-revision-date-localized插件在每页底部显示文档贡献者日期时,我们需要设置fetch-depth: 0 ,这导致代码库的检出时间需要 20 到 30 秒。通过利用GitHub Actions中的git sparse-checkout功能,检出时间缩短至 2 秒。

¥Developing an efficient approach to build documentation in CI workflows is essential, especially when working in large repositories with thousands of commits, like ours. Of course, we want to build documentation quickly and efficiently, ensuring fast and productive workflows. When using both the wonderful git-committers and git-revision-date-localized plugins to display document contributors and dates at the bottom of each page, we are required to set fetch-depth: 0, which resulted in checkout times of 20 to 30 seconds on our repository. By leveraging git sparse-checkout within GitHub Actions, check out time was brought down to 2 seconds.

搜索:更好、更快、更小

¥Search: better, faster, smaller

这是我们如何彻底重建客户端搜索的故事,在提供更好的用户体验的同时,使其变得更快、更小。

¥This is the story of how we managed to completely rebuild client-side search, delivering a significantly better user experience while making it faster and smaller at the same time.

Material for MkDocs 的搜索功能是迄今为止其最优秀、最受欢迎的资产之一:多语言离线功能,以及最重要的:全客户端。它提供了一种解决方案,使您的文档用户能够立即找到他们正在搜索的内容,而无需管理额外的服务器。然而,即使已经进行了多次迭代,仍有一些改进空间,因此我们从头开始重建了搜索插件和集成。本文将揭示新搜索的内部原理、它为何比以前的版本更强大,以及即将推出的功能。

¥The search of Material for MkDocs is by far one of its best and most-loved assets: multilingual, offline-capable, and most importantly: all client-side. It provides a solution to empower the users of your documentation to find what they're searching for instantly without the headache of managing additional servers. However, even though several iterations have been made, there's still some room for improvement, which is why we rebuilt the search plugin and integration from the ground up. This article shines some light on the internals of the new search, why it's much more powerful than the previous version, and what's about to come.