Building documentation using recent versions of mdBook is slightly broken
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- css, handlebars, javascript
- Domaine
- documentation, frontend
Piste de recherche
Commencez par le thème personnalisé dans src/theme/, en particulier src/theme/index.hbs autour de l’utilisation de {{#toc}}{{/toc}}, et comparez-le au comportement récent du thème mdBook. Construisez void-docs avec mdBook v0.4.43 et vérifiez les liens de la barre latérale ainsi que la mise en évidence du chapitre sélectionné par rapport à docs.voidlinux.org. Une modification complète devrait également prendre en compte la mise à jour du conteneur infra-mdbook et le revbumping de void-docs.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
This has been discussed in #voidlinux. Here is the original screen capture I posted there which showcases some of the problems:
https://github.com/user-attachments/assets/b90cbd47-aa59-4d7f-8afd-28b9919b9780
Trying to build void-docs with a recent version of mdBook (including v0.4.43 which is the version currently packaged in void-packages) will lead to the following quirks not present in https://docs.voidlinux.org/:
-
Sidebar's links become broken (see https://github.com/rust-lang/mdBook/issues/2685) (this is probably the most severe problem affecting the usability of the documentation)
-
The selected chapter is not highlighted like in https://docs.voidlinux.org/:
-
There are probably more issues (more minor or specific ones)
Local builds and the void-docs official package are affected.
Cause
This is caused by void-docs' custom theme which completely overrides mdBook's default sidebar logic. Void's substitute code relies on mdBook's toc helper, which endured a breaking change in newer versions of mdBook: https://github.com/rust-lang/mdBook/issues/2685
Relevant mdBook versions
void-docs' theme resides in src/theme/. Most of it was overhauled by 7281cedcdd99294c93d71f4ef33953bea22cc819. The commit description indicates that these files were made by taking mdBook's default theme files and modifying them to Void's needs.
The void-packages packaged version of mdBook was v0.4.14 at the time of making that commit, so mdBook v0.4.14 default theme files were most likely used as base for void-docs theme.
The Void infrastructure generates https://docs.voidlinux.org/ from the ghcr.io/void-linux/infra-mdbook:20231023R1 container (which is created from here using these files). The ghcr.io/void-linux/infra-mdbook:20231023R1 container includes mdBook v0.4.35, which doesn't suffer from the problem described in https://github.com/rust-lang/mdBook/issues/2685
Void's changes to mdBook's default theme
Here is a cleaned up diff (I had to reindent void-docs' theme) between mdBook v0.4.14 default theme files and void-docs' current theme files: void-docs-theme-changes.patch.txt
Possible solutions
The most straight forward solution to the sidebar problem would be to somehow convince the relative links generated in here by {{#toc}}{{/toc}} to be relative to path_to_root or to something similar. I personally do not know how to do that or whether it is possible.
Another solution would be to switch to mdBook's default sidebar logic. This would lead to less custom theme logic in void-docs. This would result in the following behavior changes:
-
The sidebar would become scrollable, it would no longer be static.
Most of the other features mentioned here can be relatively easily removed, but preserving the static nature of the sidebar would require heavy modification to mdBook's default sidebar logic (I assume, I haven't tried implementing it). In recent enough versions of mdBook, the sidebar is handled by
<!DOCTYPE HTML> <html lang="{{ language }}" class="{{ default_theme }} sidebar-visible" dir="{{ text_direction }}"> <head> <!-- ... --> <!-- Start loading toc.js asap --> <script src="{{ resource "toc.js" }}"></script> </head> <body> <div id="body-container"> <!-- ... --> <nav id="sidebar" class="sidebar" aria-label="Table of contents"> <!-- populated by js --> <mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox> <noscript> <iframe class="sidebar-iframe-outer" src="{{ path_to_root }}toc.html"></iframe> </noscript> <div id="sidebar-resize-handle" class="sidebar-resize-handle"> <div class="sidebar-resize-indicator"></div> </div> </nav> <!-- ... --> </div> </body> </html>A JS version is managed by
toc.jsand a non-JS one is built by mdBook and outputted intotoc.html.The
toc.jsfile would likely have to be modified to preserve the original UI. This file is not one of the files overrideable by mdBook theme, so a custom one would have to be created, modified and shipped alongside the (unused)toc.js. -
Collapse/uncollapse animations would be added.
These are easy to patch out.
-
The selected chapter would also have to be remodified.
-
The UI on mobile devices would presumably also be affected (I haven't tested it)
The non-JS toc.html file mentioned above might be usable as a replacement to {{#toc}}{{/toc}} if void-docs wishes to steer away from mdBook's default sidebar logic.
Things to consider after solving this issue
The ghcr.io/void-linux/infra-mdbook container will have to be updated.
Once that's done, this line will have to be updated to point to the new container. I am not closely familiar with Void's infrastructure, more steps may be necessary.
The void-docs package should be revbumped once this issue gets resolved.
- Langage dominant
- CSS
- Étoiles
- 220
- Forks
- 214
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de void-linux/void-docs
-
Eduroam with NetworkManagerOuverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
void-linux/void-docs#912 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
void-linux/void-docs#849 · 2 commentaires ·
-
Network configuration documentation issuesPeut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouvertebug good first issue
Difficulté 1/5 Moins d'une heure Accessibilité débutants 75/100
void-linux/void-docs#595 · 1 commentaire ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 62/100
void-linux/void-docs#532 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
void-linux/void-docs#899 · 5 commentaires · 2 réactions ·
Toutes les issues de void-linux/void-docs
Issues similaires
-
triage
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Portkey-AI/gateway#1844 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
XRPLF/xrpl-dev-portal#4000 ·
Les mainteneurs répondent en général sous 1 jour
-
docs: clarify replacement for outdated Terms of Service URL in readme.mdPeut-être pris @mohitjoshi-hey l’a pris aujourd’hui. Ouverte
Difficulté 1/5 1-3 heures Accessibilité débutants 66/100
-
documentation good first issue
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
Les mainteneurs répondent en général sous 1 jour
-
good first issue hacktoberfest pipeline
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
TanbirRamim/open-source-radar#111 ·
Les mainteneurs répondent en général sous 1 jour