Repository navigation
Description
The following is a sketch of my thinking on an ideal configuration for a 1.0 release.
This doesn't take into account any compatibility concerns, I just wanted to start by outlining my thoughts on how we could get something really restricted, simple and consistent.
Build process
Simplify the build process and specify it properly so that we can describe it in the documentation, and so that process is obvious to end users.
- Copy media files from theme dir.
- Copy media files from docs dir.
- Build static pages from theme dir. (HTML, JSON, XML files. Templated, passed global context.)
- Build static pages from docs dir. (HTML, JSON, XML files. Templated, passed global context.)
- Build documentation pages.
Template directories are <docs_dir>/templates and <theme_dir>/templates. Anything in those directories not considered as static build pages. Base template for documentation pages is base.html unless overridden with template: ... in the page metadata.
Notes:
- Move
sitemap.xmlinto themes, for simpler, more consistent build process. - Move
search_index.jsonand search assets into themes for simpler more consistent build process. (search info in provided in context, use something like{{ as_json(search) }}in the template. - Need to strictly specify how markdown paths are mapped to html paths.
Template context
Properly separate the global and per-page context. Only build the global context once. Scope the context more nicely.
Global context
site_title
homepage_url
media:
extra_javascript
extra_css
build:
utc_time
mkdocs_version
extra:
<variables from 'extra' config>
search
nav
Per page context
Per-page context should be scoped on the page context variable:
page
Eg:
Use: {{ page.title }}, {{ page.meta }}, {{ page.toc }}, {{ page.previous_url }}
Not : {{ page_title }} and {{ meta }}, {{ toc }}, {{ previous_url }}.
Notes:
- Include a
{{ url(pathname) }}function instead of using{{ base_url }}/pathname. - Do we provide something like an
{{ is_active(nav_element) }}in order to keepnavitself entirely static? - We should be able to avoid the "walking" of the nav that we currently do.
Structure
Define the API & structure for the following:
nav-homepage,pages,items.page-title,meta,toc,markdown,html,file,next,previous,parent.section-title,children.toc- list oftitle,url,children.search- TODOfiles- TODO
Configuration
Better scoping of the configuration, separation of behavioral and non-behavioral configuration, and remove unneeded config where possible...
Core configuration.
title: required
url: None
theme: 'mkdocs'
pages: all markdown files in docs directory
Project directories.
docs_dir: 'docs'
build_dir: 'build'
theme_dir: use directory for 'theme' setting
Command configuration.
Keep these options scoped to individual commands.
For consistency we could also ensure that the flags that we include for each command strictly correspond to the available command line options.
build:
strict: False
local: False
serve:
host: 127.0.0.1
port: 8000
livereload: True
deploy:
service: None
Any other deploy settings depend on the service setting. For 'github-pages' these would be:
remote_name: Automatically determined
remote_branch: Automatically determined
commit_message: 'Documentation build'
Extensions.
extensions:
...
Theme control.
None of these are behavioral to MkDocs, just passed to the theme context.
We would document these against themes, not as built-in config.
This list is just the set of items that the built-in themes happen to use.
extra:
author
description
favicon
repo_url
repo_name
copyright
google_analytics
Note that we would want some functions like get_url(<filename>) and get_host(<url>) passed to the templates in order for logic around these to be confined to the templates.
Notes:
extra_css,extra_javascriptandextra_templatesare not required. We always include any CSS, JS or static pages in the docs dir. There's no need for the user to define them in settings.- I've currently dropped
use_directory_urls- open to further discussion here. - Haven't thought about anything regarding extensions or markdown_extensions, so that should be considered incomplete.
- Haven't thought about how
deployoptions would map to command line arguments if they depend on the service. - Here I've renamed
site_title,site_url,site_author,site_descriptionto justtitle,url,authoranddescription. Open to discussion of course. - Need to specify the default
pagesstyle strictly.
Activity
[-]Configuration refactoring[/-][+]Specifying 1.0 behavior.[/+]tkirill commentedon Jul 4, 2015
Would #316 be represented in 1.0 specification? It is a nice feature, we're waiting for it since we started using mkdocs.
lovelydinosaur commentedon Jul 5, 2015
Seems totally reasonable, yes. Tho keep in mind that none of this has been discussed or agreed with @d0ugal yet. :)
lovelydinosaur commentedon Jul 7, 2015
Although I'm presenting this in the whole I suspect that there's scope for an incremental approach here. I'm currently working on a proof of concept to demonstrate how it'd fit together.
I'd also be more amenable to introducing a fuller extension API if we had a nicely specified core.
lovelydinosaur commentedon Jul 7, 2015
TODO: Update this removing explicit
urlcontext anywhere, and always use eg{% url(page.next) %},{% url(page) %},{% canonical(nav.homepage) %}etc.d0ugal commentedon Jul 7, 2015
@tkirill As you rightly guessed in #627, I hope to finish that and allow #316 - which should happen in theory before this. Unless this can be done in a backwards compatible way.
lovelydinosaur commentedon Jul 7, 2015
So, there's likely to be plenty in here to disagree with, bikeshed over, or whatever.
I'm going to start by trying to make the internal structural changes that I think would help, but keeping the context, config and everything else fully compatible.
There's a start on this in the
restructurebranch, see this directory for the interesting bits: https://github.com/mkdocs/mkdocs/tree/restructure/mkdocs/structurelovelydinosaur commentedon Jul 7, 2015
Top level build using that structure currently looks like...
That only generates everything in memory - doesn't yet perform the writing the output files.
lovelydinosaur commentedon Jul 9, 2015
I've updated the
restructurebranch to perform a build using its new structure...https://github.com/mkdocs/mkdocs/blob/restructure/mkdocs/commands/build.py
I think my initial plan would be to update it so that it works without any changing of the context/config etc, so that it's essentially just an alternative to #627.
lovelydinosaur commentedon Jul 9, 2015
Note that there's still some stuff there that's incomplete (eg search), and it currently changes the context and config around a bit, but all works just fine and I think it's a lot cleaner that what we currently have.
lovelydinosaur commentedon Jul 9, 2015
Also note that I've not yet deleted any of the legacy
nav.pyetc. modules from that branch, but those would be able to disappear now.jonathanunderwood commentedon Jul 25, 2015
Hopefully Issue #697 can be fixed ahead of 1.0 too :)
dgmorrisjr commentedon Sep 6, 2017
Regarding your statement above: "I've currently dropped use_directory_urls - open to further discussion here." What does this mean for the default behavior in the absence of the option? For more complex documentation structures, will the generated documentation point to the folder? or point directly to the index.html file? The reason I ask is that currently, the default behavior is to point to the directory. In our project's particular situation, we use MKDocs to generate our documentation that's deployed as part of our system. But prior to deployment, we have "submit" our documentation to various review boards. Therefore, they require a copy of the documentation that can behave properly when browsing documentation from the local filesystem. Being able to set that option saves us TONs of time by removing the need for us to "duplicate" documentation.
waylan commentedon Sep 6, 2017
@dgmorrisjr this is a very old discussion. Most of the items discussed here have been addressed individually in their own issues more recently. There is currently no plans to remove support for
use_directory_urls. While @tomchristie has never used or needed them, there are many many users who do (and those users have been very vocal in other discussions), including myself. For more up-to-date info on the future plans for MkDocs, see the 1.0 milestone and associated tickets.dgmorrisjr commentedon Sep 6, 2017
waylan commentedon Jun 29, 2018
Closing this at it is no longer relevant to the current codebase.