Skip to content

Specifying 1.0 behavior. #683

Closed
Closed

Description

@lovelydinosaur

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.xml into themes, for simpler, more consistent build process.
  • Move search_index.json and 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 keep nav itself 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 of title, url, children.
  • search - TODO
  • files - 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_javascript and extra_templates are 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 deploy options would map to command line arguments if they depend on the service.
  • Here I've renamed site_title, site_url, site_author, site_description to just title, url, author and description. Open to discussion of course.
  • Need to specify the default pages style strictly.

Activity

  1. changed the title [-]Configuration refactoring[/-] [+]Specifying 1.0 behavior.[/+] on Jul 3, 2015
  2. tkirill commented on Jul 4, 2015

    @tkirill

    Would #316 be represented in 1.0 specification? It is a nice feature, we're waiting for it since we started using mkdocs.

  3. lovelydinosaur commented on Jul 5, 2015

    @lovelydinosaur
    CollaboratorAuthor

    Seems totally reasonable, yes. Tho keep in mind that none of this has been discussed or agreed with @d0ugal yet. :)

  4. lovelydinosaur commented on Jul 7, 2015

    @lovelydinosaur
    CollaboratorAuthor

    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.

  5. lovelydinosaur commented on Jul 7, 2015

    @lovelydinosaur
    CollaboratorAuthor

    TODO: Update this removing explicit url context anywhere, and always use eg {% url(page.next) %}, {% url(page) %}, {% canonical(nav.homepage) %} etc.

  6. d0ugal commented on Jul 7, 2015

    @d0ugal
    Contributor

    @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.

  7. lovelydinosaur commented on Jul 7, 2015

    @lovelydinosaur
    CollaboratorAuthor

    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 restructure branch, see this directory for the interesting bits: https://github.com/mkdocs/mkdocs/tree/restructure/mkdocs/structure

  8. lovelydinosaur commented on Jul 7, 2015

    @lovelydinosaur
    CollaboratorAuthor

    Top level build using that structure currently looks like...

    config = {
        'docs_dir': 'docs',
        'pages': pages_config
    }
    files = get_files(config['docs_dir'])
    nav = get_navigation(config['pages'], files)
    build_pages(files)
    

    That only generates everything in memory - doesn't yet perform the writing the output files.

  9. lovelydinosaur commented on Jul 9, 2015

    @lovelydinosaur
    CollaboratorAuthor

    I've updated the restructure branch 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.

  10. lovelydinosaur commented on Jul 9, 2015

    @lovelydinosaur
    CollaboratorAuthor

    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.

  11. lovelydinosaur commented on Jul 9, 2015

    @lovelydinosaur
    CollaboratorAuthor

    Also note that I've not yet deleted any of the legacy nav.py etc. modules from that branch, but those would be able to disappear now.

  12. jonathanunderwood commented on Jul 25, 2015

    @jonathanunderwood

    Hopefully Issue #697 can be fixed ahead of 1.0 too :)

  13. added this to the 1.0.0 milestone on Dec 2, 2016
  14. dgmorrisjr commented on Sep 6, 2017

    @dgmorrisjr

    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.

  15. waylan commented on Sep 6, 2017

    @waylan
    Contributor

    @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.

  16. dgmorrisjr commented on Sep 6, 2017

    @dgmorrisjr
  17. waylan commented on Jun 29, 2018

    @waylan
    Contributor

    Closing this at it is no longer relevant to the current codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions