-
Notifications
You must be signed in to change notification settings - Fork 159
Add "Table of Content" to the Readme tab #4371
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
Comments
We probably want this in a side-bar. On mobile this could be omitted or dragged in from the side. |
Before it gets (hopefully) implemented into pub itself, here's a Firefox extension that achieves the same thing. |
@sigurdm Any update on whether this is planned? On desktops, the right side is reserved for metadata but the left side of the page is empty and can be used for this, similar to Wikipedia and Google Docs. I imagine this can cut down on a lot of unnecessary text on a lot of packages, and also prevent ToC's from becoming outdated due to "trivial" commits that forget to add a section to the header |
No updates on this. |
Are you looking for PRs? 👀 |
@isoos are we? I think the main issue is to decide on a design, more than the code. |
I think we need to separate at least two different aspects here:
@Levi-Lesches: I think the scope of this requires some discussions and preparations before we are even close to the PRs. Having said that, we are open to ideas and collaboration, do you have something specific in mind? |
Sure: On desktop, put the ToC on the left sidebar (currently empty, keeping the middle and right side as it is. On mobile: have a collapsible header (collapsed by default) at the top, right underneath the "Readme | Changelog | Example" etc menu but before the actual text of the README In terms of parsing, a simple tree hierarchy based on heading levels (#'s in the markdown) would work, the same way GitHub does it |
@Levi-Lesches: those are valid outlines, but I think they do need to be extended with more nuanced details, just to name a few out of my head:
Some of these are highly subjective, and very likely will be decided by the team internally, though suggestions here certainly could help. There are a few more considerations which probably are outside of the scope of a tracking issue here, e.g. how do we want to handle it on other Dart-team websites. If somebody is looking to contribute, I'd suggest to focus on the markdown parsing parts first, it has a better chance to get used first (esp. if it helps with the changelog parsing). |
Makes sense. If you're interested in my 2 cents:
Overall, my guiding principles here are:
I could give it a shot. What kind of function are we looking for? How about something like this: // app/lib/frontend/templates/views/shared/toc.dart
import "package:markdown/markdown" as md;
Iterable<TocNode> getTocFromMarkdown(md.Document markdownDoc); This file already has code for rendering a toc, specifically in the admin page of any package: Given that there's already an API here I can try to sneak in a PR soon |
I understand that you want to have something out fast, but our approach so far was more towards having a correct solution even for the complex use cases. This could be a behavior-shaping feature, where a bad (slightly off) first implementation may influence people towards habits that satisfy the tool, but not their intended audience. We could have rushed out a subpar implementation for this already, but decided against it., because it seems to provide more benefit on the long term if we understand the nuances here. Also, I wouldn't brush of things and push to the users, because there may be important reasons for such structures, e.g. inconsistent nesting can be often found in changelogs, as people may want to change their level for versions and their internal details, and it is not unseen in readmes either, but wouldn't want to change their older log entries. It is better to have an implementation that handles such cases and enables users, and does not put them in lose-lose situations. Please don't rush PRs. The |
In a recent user study, participants searched within a package's documentation to find a specific feature (e.g., Ctrl+F to search “highlight” within the documentation of “markdown” package). They usually did this when they failed to find useful information after quickly scanning the documentation. They also tried multiple keywords to make sure that they didn't miss any information (e.g., “highlight”, “syntax”, “code”). It showed that search was an easy way to find information from large data, but it could be difficult to find a good keyword.
But when the feature of interest was listed under “Features” section, users didn’t have to search again. It suggests that a standardized Readme format with better navigation UI (e.g., table of contents) might save some time for participants.
We can consider adding table of contents that's similar to the one on Go's package site:
The text was updated successfully, but these errors were encountered: