Skip to content

Commit

Permalink
Merge pull request #508 from d0ugal/fix-reload-problems
Browse files Browse the repository at this point in the history
Don't load the config outside the serve command
  • Loading branch information
d0ugal committed May 9, 2015
2 parents d78b894 + 54e46a8 commit 1247e3e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions mkdocs/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ def cli(verbose):
@click.option('--theme', type=click.Choice(theme_choices), help=theme_help)
def serve_command(dev_addr, config_file, strict, theme):
"""Run the builtin development server"""
serve.serve(load_config(
serve.serve(
config_file=config_file,
dev_addr=dev_addr,
strict=strict,
theme=theme,
))
)


@cli.command(name="build")
Expand Down
14 changes: 11 additions & 3 deletions mkdocs/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,29 @@
from livereload import Server

from mkdocs.build import build
from mkdocs.config import load_config


def serve(config):
def serve(config_file=None, dev_addr=None, strict=None, theme=None):
"""
Start the devserver, and rebuild the docs whenever any changes take effect.
"""
# Create a temporary build directory, and set some options to serve it
tempdir = tempfile.mkdtemp()
config['site_dir'] = tempdir

def builder():
config = load_config(
config_file=config_file,
dev_addr=dev_addr,
strict=strict,
theme=theme,
)
config['site_dir'] = tempdir
build(config, live_server=True)
return config

# Perform the initial build
builder()
config = builder()

server = Server()

Expand Down

0 comments on commit 1247e3e

Please sign in to comment.