mirror of
https://github.com/mkdocs/mkdocs.git
synced 2026-03-28 02:18:31 +07:00
@@ -55,7 +55,7 @@ def main(cmd, args, options=None):
|
||||
build(config, clean_site_dir=clean_site_dir)
|
||||
gh_deploy(config)
|
||||
elif cmd == 'new':
|
||||
new(args, options)
|
||||
new(args)
|
||||
else:
|
||||
print('MkDocs (version {0})'.format(__version__))
|
||||
print('mkdocs [help|new|build|serve|gh-deploy|json] {options}')
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
# coding: utf-8
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
from io import open
|
||||
|
||||
config_text = 'site_name: My Docs\n'
|
||||
index_text = """# Welcome to MkDocs
|
||||
from mkdocs import compat
|
||||
|
||||
config_text = compat.unicode('site_name: My Docs\n')
|
||||
index_text = compat.unicode("""# Welcome to MkDocs
|
||||
|
||||
For full documentation visit [mkdocs.org](http://mkdocs.org).
|
||||
|
||||
@@ -21,10 +24,11 @@ For full documentation visit [mkdocs.org](http://mkdocs.org).
|
||||
docs/
|
||||
index.md # The documentation homepage.
|
||||
... # Other markdown pages, images and other files.
|
||||
"""
|
||||
""")
|
||||
|
||||
|
||||
def new(args, options):
|
||||
def new(args):
|
||||
|
||||
if len(args) != 1:
|
||||
print("Usage 'mkdocs new [directory-name]'")
|
||||
return
|
||||
|
||||
28
mkdocs/tests/new_tests.py
Normal file
28
mkdocs/tests/new_tests.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
|
||||
import tempfile
|
||||
import unittest
|
||||
import os
|
||||
|
||||
from mkdocs import new
|
||||
|
||||
|
||||
class NewTests(unittest.TestCase):
|
||||
|
||||
def test_new(self):
|
||||
|
||||
tempdir = tempfile.mkdtemp()
|
||||
os.chdir(tempdir)
|
||||
|
||||
new.new(["myproject", ])
|
||||
|
||||
expected_paths = [
|
||||
os.path.join(tempdir, "myproject"),
|
||||
os.path.join(tempdir, "myproject", "mkdocs.yml"),
|
||||
os.path.join(tempdir, "myproject", "docs"),
|
||||
os.path.join(tempdir, "myproject", "docs", "index.md"),
|
||||
]
|
||||
|
||||
for expected_path in expected_paths:
|
||||
self.assertTrue(os.path.exists(expected_path))
|
||||
Reference in New Issue
Block a user