Repository navigation
Internal refactoring. - #689
lovelydinosaur wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
This is duplicated in the urls.py, would it be better to expand/change the is_markdown utility method and use that? or maybe just have a set of constants somewhere for these lists.
|
Looks like a good start, but obviosuly still tons to do. So I just gave it a quick once over. My primary concern with wide sweeping refactors like this is what we might break. I tend to do these things in much smaller steps. |
Likewise. Clearly breaking the rules here. |
Likewise. Clearly breaking all the rules here. |
Maybe we can treat this branch as an incubator and slowly move changes into master? Trying to think of a decent workflow. Next week I hope to have time for MkDocs as I'll be at EuroPython and plan on sprinting. However, it will be tricky to do much without conflicting badly with this work and I don't want to cause you a massive headache. I'd be happy to help drive this forward too, but not sure I can easily do that yet. Open to ideas. |
|
How can I help push this work forward? |
|
@d0ugal Possibilities:
Alternatively
|
If we call the next release 1.0, then I am happy to break things so long as we provide users with clear docs to upgrade. I wouldn't be happy about a I can try and look at some of the check list items - I guess I'll send a pull request against this branch if I get something together. |
My preference would be to work on a 1.0 release that provides an easy upgrade path for users of the existing themes. - I can make a pull request that doesn't respect all the backwards compat of this one for us to consider working on. |
|
I think this work is really valuable, and needs to happen at some point - but to tidy up a bit I'll close this as it has fallen out of date. Happy for a new PR to be opened. |
This is only the contents of the 'structure' dir from mkdocs#689. Still needs to be implemented in the build process after being updated.
This is only the contents of the 'structure' dir from mkdocs#689. Still needs to be implemented in the build process after being updated.
This is only the contents of the 'structure' dir from mkdocs#689. Still needs to be implemented in the build process after being updated.
This is only the contents of the 'structure' dir from mkdocs#689. Still needs to be implemented in the build process after being updated.
This is only the contents of the 'structure' dir from mkdocs#689. Still needs to be implemented in the build process after being updated.
Internal handling of pages, files and navigation has been completely refactored. The changes included in the refactor are summarized below. * Support for hidden pages. All Markdown pages are now included in the build regardless of whether they are included in the navigation configuration (fixes #699). * The navigation can now include links to external sites (fixes #989, fixes #1373, & fixes #1406). * Page data (including titles) is properly determined for all pages before any page is rendered (fixes #1347). * Automatically populated navigation now sorts index pages to the top. In other words, The index page will be listed as the first child of a directory, while all other documents are sorted alphanumerically by file name after the index page (fixes #73 & fixes #1042). * A `README.md` file is now treated as an index file within a directory and will be rendered to `index.html` (fixes #608). * The URLs for all files are computed once and stored in a files collection. This ensures all internal links are always computed correctly regardless of the configuration. This also allows all internal links to be validated, not just links to other Markdown pages. (fixes #842 & fixes #872). * An `on_files` plugin event has been added, which could be used to include files not in the `docs_dir`, exclude files, redefine page URLs (i.e. implement extensionless URLs), or to manipulate files in various other ways. Backward incompatible changes are highlighted in the release notes included with this commit. Some notes regarding various decisions follow in no particular order: This started out as the contents of the 'structure' dir from @tomchristie's work in #689. All paths must be all Unicode all the time. 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 validation checks that and if the byte string uses the file system encoding, decodes it. For any other encoding, a validation error is raised. Paths which start with a slash are assumed to be relative to the docs_dir root. This behavior fixes #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. The URLs available on a page are: * 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, if 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. Links being ignored in raw HTML is now documented. Fixes #991. All related tests that require temp dirs use the `mkdocs.tests.base.tempdir` decorator. Note that any unrelated tests have not yet been updated. That can happen separately from this. The one test in `mkdocs.tests.structure.page_tests` (test_BOM) is unique enough to not use the decorator.
Builds site in memory.
Presents a clean internal API, that is more comprehensible, allows us to make improvements more easily, and paves path to fully documented build behaviors and context available to themes.
In broader context this is a big step towards #683, but at this point I just want to present a fully compatible internal refactoring that should allow us to sort out a bunch of issues.
TODO:
page.urlandnav.is_activestates on each page.404.html, search and other template pages.use_directory_urls.extra_css,extra_javascript,extra_templates.abs_urlis used.utils.pages.Resolves:
#653 - Relative paths to media sometimes broken.
#316 - Determine default titles from page table of contents.
#192 - Allow absolute URL links in source pages.
#608 - Allow README.md or others as homepage.
Makes these viable:
#658 - Validate links to anchors.
#167 - Only warn on properly stale files in site dir.
#699 - Build all markdown files.
No ticket - Support HTML files in nav.
No ticket - Support alternate layout eg
/path/to/file.htmlvspath/to/file/index.html.