Repository navigation
Pages Refactor - #1504
Pages Refactor#1504
Conversation
This is only the contents of the 'structure' dir from mkdocs#689. Still needs to be implemented in the build process after being updated.
Some notes regarding various decisions made here: And paths which start with a slash are assumed to be relative to the docs_dir root. This behavior fixes mkdocs#192. However, the slash not being present in the output may surprise some users who are trying to create a link relative to the server root when the mkdocs root is not at the server root. Still need to address links to files from the theme. I note that in the homepage of our docs we link to `/img/favicon.ico`, which is a file provided by the theme. It appears that the previous behavior was to treat links which started with a slash as not local links and therefore a check was not necessary. This then provided a workaround to avoid the warning when linking to theme provided files. * Page.url is the url relative to the site_dir * Page.canonical_url is the relative url joined with site_url or None if site_url is not defined (the default). * Page.abs_url is the path component of the canonical url or None if canonical_url is None. Note that new behavior is slightly different than before. Previously abs_url ignored site_url and was always url with '' prepended. With the new behavior, is site_url includes a subdir, that subdir will be included in the abs_url. When not on a server, there is no sensable "absolute_url" for a page. Therefore, we shouldn't try to define one. The thinking is that users generating docs to be browsed in the local file system (`file://`) should leave the site_url setting unset, while users who will be serving their docs from a server should be setting the site_url. And if the site_url point sot a subdir of the server, the abs_url will stil be absolute from the server root as it uses the "path" of the canonical_url of the page. Note that without the magical url context all URLs must be prepended by `{{ base_url }}/` in the templates. While this requires a change in third party themes, it is more consistent. The rest of the tests should probably be updated to use this. Also load nav from files in get_navigation() rather than in config validation. That way we only walk docs_dir once. Note that the two failing tests need to be moved to the nav_tests to ensure get_navigation() returns the proper nav structure when no nav config is provided and the file structure is relied upon. And add `files` keyword to `nav` event. Previously pages and nav were synonymous. As that is no longer the case, a plugin may need access to the files collection to properly manipulate the nav.
|
Thanks for the summary and poke. Much appreciated! I will have a look at this over the weekend. What is time frame for 1.0 rollout? |
|
Sounds great and looks good to me! |
|
The time frame for 1.0 is "when it's done." This PR should resolve about half of the open issues on the 1.0 milestone. Most everything else is just housekeeping type stuff, so I expect by the end of summer. That said, this is being worked in in my spare time so no guarantees. |
|
Wasn't a criticism, rather it was to place changes on our end on my TODO list radar in a timely fashion. Sounds good to me. The more time you need the better from my standpoint :) |
|
Holy smokes |
|
We're getting a test failure in the "integration tests" which do a "strict" build of the MkDocs documentation (the same issue is causing the linkchecker test to fail) . Of course, a "strict" build errors if any warnings are issued. And a build of the MkDocs documentation currently includes the following warning: That warning is correct. However, the image does exist in the generated site as it comes from the theme. #872 requests the ability to validate image links in documentation pages and this refactor makes that very easy to implement (it appears that I missed listing that feature and issue in the release notes). The tricky part is when the link points to an internal file which comes from an external source (external links are ignored in this check). Should we include the non-template theme files in the check? A comment I inserted in the code seems to indicate I had intended to do something about this at one point. Perhaps we should even include non-template theme files in the I was thinking I could deal with this later, but didn't consider that it would cause the Integration tests to fail. |
|
Re #1504 and this change:
does this implement the behavior you described in this comment?
|
No. I never said that and why would we do that. README.md is an optional alternate index file for those people who want it. |
I missed a couple minor things.
|
Thanks @waylan. Looking forward to trying this out. |
When a byte string and a unicode string are both passed to os.path (join ect) then returned value is always a byte string. Therefore, we need every path string to be unicode. This ensures valudation checks that and if the byte string uses the file system encoding, decodes it. For any other encoding, a validation error is raised.
|
While working on this, I discovered a weird error which I reported in #1516. As the error also exists in master, it appears to not be related to this work, so I'll address that separately. |
I almost missed reimplmenting this.
This relimplements mkdocs#1272 on the current code in master. Thanks to @funkyfuture for the original work on this. Also removes some unused code after mkdocs#1504. Closes mkdocs#1272.
This relimplements #1272 on the current code in master. Thanks to @funkyfuture for the original work on this. Also removes some unused code after #1504. Closes #1272.
|
FYI to those following this, especially theme authors, the above described behavior for URLs and the use of |
|
Thanks for all the updates @waylan, these are all awesome and welcome changes. Is there a way to test a dev build or an ETA of when this will be available as a stable release? |
|
@timani this will be included in the next release (1.0) when the 1.0 Milestone is complete (we are almost there). In the meantime, you can always install the latest in the master branch directly from GitHub: |
|
great! I'll subscribe to the 1.0 Milestone I also see 1.0 Beta is already out so that should do the trick thanks @waylan |
Probably still needs some tweaks, but I believe this is fully functional. I wanted to get this in front of others for review, especially third party theme authors (@squidfunk, @notpushkin, @chrissimpkins, @hfagerlund, @cjsheets, @michaeltlombardi).
Some of the backward incompatible changes do not have a graceful upgrade path, but the underlying structure is so drastic that its really any way to support both the old and new. As this is intended to be included in the 1.0 release, there is no requirement to maintain compatibility (we are making a major release) and we need to get this correct now as we will be stuck with it throughout the 1.x release cycle.
The documentation changes and release notes provide a decent summary of the changes made. I've copied the release notes below. Some additional information, including notes regarding some of the decisions made are included in the commit message for the second commit. The first commit is from @tomchristie's work in #689, which this builds off of.