-
Notifications
You must be signed in to change notification settings - Fork 32
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
Merge in changes from upstream mkdocs-material repository #34
Conversation
9c700c3
to
9df1775
Compare
I have done some manual testing by browsing the documentation of this package itself. It is possible some bugs slipped through, though. It may be challenging for you to review the changes to the files from mkdocs-materials, but I also made a few changes to the Python files as well, notably to remove the references to basic.css and documentation_options.js that previously led to spurious console messages. |
Note: I did try to add |
Thanks for spotting the issue with the arrow in the nav menus. In mkdocs-material there is this Perhaps to address this very issue that you mention --- not sure since the commit message is rather vauge. However, that style causes the C/E/M/etc. icons next to API documentation headings in the table of contents to display badly --- it adds space between the icon and the text. I also noticed that in the documentation of mkdocs-material itself, there is a demonstration of the "icons" feature which is similar (see table of contents): The mkdocs-material documentation is produced with the non-public "insiders" version of the package, for which I don't have the source code, but from chrome dev tools I saw that the Therefore I removed it for this upgrade as well --- but I didn't think to check on the arrows. I will see what I can do to fix that. |
The HTML structure is different... upstream<a href="./" class="md-nav__link md-nav__link--active">
<span class="md-ellipsis"> Reference </span>
</a>
<label class="md-nav__link md-nav__link--active" for="__nav_4">
<span class="md-nav__icon md-icon"></span>
</label> in which the Compare that to this PR's doc bulid<label class="md-nav__link" for="__nav_3">
Examples and Uses
<span class="md-nav__icon md-icon"></span>
</label> The item's text is not wrapped in a I'd probably start with looking at the html template. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I managed to power through everything. Looks fine so far; I have to go more in depth on the
- base.html
- nav-item.html
- _nav.scss
I wrapped the titles in However, we might still want to tweak the overflow behavior. If you play with the current mkdocs-material documentation website in devtools to make one of the left or right toc entries very long, you will see that it wraps rather than truncates with ellipses. Possibly that would actually be better. One issue though with wrapping is that it doesn't work very well if you have a long title without any spaces, such as in API documentation. We could allow wrapping at any character, but that may be ugly. Or we could apply different styles depending on if there are any spaces, but I don't know if we want to do that. |
I noticed the furo theme does this also (which seems to be conceptually based on mkdocs-material or just material design in general). I just got done overhauling the breathe ext's docs for the furo theme. I would've recommended this theme, but there's still #14 ...
Initially I would favor an ellipsis, but we could try to inject a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be the first to admit that I don't fully grasp all the changes here, but I'm going on faith in that the theme's docs aren't broken.
FWIW, I did skim through all 246 files changed, and nothing stood out.
I'm verifying that it also doesn't break the tensorstore docs and then will merge it. |
FWIW, I tested this PR with my library also. The only difference I noticed was the right-side TOC adds "Table of contents" and an extra level of indentation. Basically the title heading is added to the right-side TOC. Before: After: This seems slightly different than Mkdocs for Material. The page's title heading does not appear on the right-side TOC here. |
@mhostetter Thanks for the feedback! its always best to do some field testing. I think you can now modify the secondary ToC's heading behavior in new conf.py options. Its possible that the mkdocs-material site is using this new feature as well. Those mkdocs visuals you're comparing are literally of the same commit that this PR is merging changes from. Personally, I like the indent changes. I'm excited about the tables' borders being much more distinctive now. |
@mhostetter Thanks for pointing out the toc issue --- there is now a confg option |
It looks like I'll need to update my CSS overrides about changing the default admonition colors also |
One thing would be to confirm that the toc still displays correctly if you have a sphinx document with multiple top-level headings. I'm not sure I would particularly recommend doing that but I think @2bndy5 made use of that possibility. |
Regarding the table header styling --- that seems to just be a change made in mkdocs-material itself. I think I agree that the old styling was nicer in how it emphasized the table header, but not sure we want to go down the rabbit hole trying to tweak such things. It is a bit unfortunate to have to tweak the md-nav__link styling, since those styles are actually extremely complicated, with different rules for different screen widths. Hopefully in the future when mkdocs-material merges back in the Insiders changes related to that we can reduce the divergence. |
Oh I didn't think to check that. That's fine; it would be a simple css rule in the docs that I use this theme for.
I can revert one of my docs to test this, but I have hacked most of the doc pages to only use 1 top level heading. I'll try it and report back...
yeah, I don't recall doing that on purpose. Sorry about that. |
Currently the left nav menu and the right nav menu are handled basically the same way --- are you suggesting one should wrap and the other should truncate? Truncation isn't really great since there isn't even a way to resize the window to have it visible --- perhaps this should be a theme option though. I am not sure what is going on with the extra spacing between words and apparent reordering --- perhaps you can investigate that more --- or can it be reproduced with the sphinx-immaterial docs themselves? As far as |
It appears that it wraps properly in Chrome but not in Firefox --- I guess the styles will need some additional tweaking to also work in Firefox. Still not clear what is going on with the weird spacing and reordering of terms in your documentation, though maybe something is causing those Note that the |
Some of the |
I found a fix for the wbr problem: .md-nav__link .md-ellipsis {
display: block; /* inheriting flex is the problem */
} I still have to verify that this doesn't break anything else... |
@jbms would it be too deviant to include the css map files with the theme while we're still fleshing out the kinks? I know the dart-sass pkg can do this, but I'm unsure if this theme is using a different sass compiler. |
I think the theme already includes |
My mistake, they are present in the docs builds, but the browsers don't seem to be using them. Both chorme and firefox still say all css originates from line 1 of main.sha.min.css. Turns out the paths used in the map files are relative to the theme's root (location of install). This basically renders them obsolete for distribution. |
Thanks --- with your fixes the nav items indeed appear to wrap correctly in Firefox and Chrome. In the reduced width mode where the nav menu is in the drop-down menu, I see the issue with the excessive line height that you mentioned. |
These are useful as demonstrations of how wrapping is handled.
I added one additional rule to ensure the I also added some example pages with long titles to this theme's documentation for testing purposes. |
lgtm |
I'd like to do another rebase to pull in fixes about mermaid.js (released as part of v8.2.5 10 days ago) in hopes of supporting an alternative to |
Sounds good, do you want to attempt it? I'm guessing there haven't been a lot of changes yet that will conflict. You will have to rerun npm install to update the package-lock.json file. |
I wouldn't mind attempting it. In fact I'll probably make a section in the CONTRIBUTING.md to outline the necessary steps and considerations.
Seen as how I've never tried to merge a commit from a separate repo, I'm eager to have any additional advice you may have. |
To be clear this is not at all a normal merge. If you aren't familiar with normal git merging then this will be extra confusing, but anyway let's see how it goes. In a normal git merge scenario, there is a common ancestor commit (as far as git is concerned) between the two branches being merged. However, I have not set up this repository to actually have mkdocs-material commits in the history for various reasons:
Normally git does a merge using the 3-way merge algorithm: it locates the common ancestor commit, so you have:
So suppose our For every file in the repository, git will consider 3 versions: the version in A, the version in B, and the version in C. If all 3 versions are the same, then the merge result will be that single version. If the version in B is the same as the version in A (i.e. modified only in C) then the version from C will be chosen automatically for the merge. Likewise if the version in C is the same as A (i.e. modified only in C), then the version from B will be chosen automatically. If all 3 versions are different, then git will attempt to merge the changes in B and C. This uses a configurable merge driver, but by default will attempt to merge automatically and if it fails to merge a portion of the file will leave conflict markers:
Additionally, it will put the git index into a special state to indicate that this file has a conflict. To complete the merge you have to manually edit the file to the desired state (deleting the conflict markers) and then Once resolving all conflicts you can do With the Since the git history does not indicate the common ancestor in the mkdocs-material repository, the script instead relies on the The script creates a temporary mkdocs-material repository, checks out the MKDOCS_MATERIAL_MERGE_BASE version, copies the changes from our repository into it and makes a temporary commit, then does the 3-way merge in that temporary repository, leaving conflict markers in files that have conflicts. It then copies back the merged result, including any conflict markers, into our repository. It will also update the MKDOCS_MATERIAL_MERGE_BASE file. Finally, any files that merged without conflicts are staged (added to the git index). Any remaining files that are listed as "modified" in the working tree are the files with merge conflicts and they will contain conflict markers. However, since this isn't a real merge, the git index will not indicate that these files have conflicts. But you will in any case need to resolve the conflicts, remove the conflict markers, and then stage these files and create a commit. As I mentioned, the merge excludes the One of the most common source of conflicts is changes to the rxjs imports in javascript files, since these all happen at the start of the file. These are pretty easy to resolve, you just need to figure out which symbols are actually used in the file. I have made a lot of changes to the search code, so if there are any upstream changes to the search code, it may take some significant effort to resolve. |
This also adds a script used for performing the update.