internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: mkdocs/mkdocs

Issue:
Show installed version in command-line
I'd expect `mkdocs help` to display the currently installed version, would be nice to have for the next versions



Discussion:
Good idea, this seems reasonable. I've been asking people to do `pip freeze | grep mkdocs` but including it in the help output seems logical.

Totally yup, good point.

I would have created a pull request, but since the current help dialog displays a format as you would use the commands, I didn't want to mess with it and leave it to you how you format the output ;)

hmm, yeah, I see what you mean. Something like this might be okay.

```
MkDocs (version 0.11.1)
mkdocs [help|new|build|serve|gh-deploy|json] {options}
```

Sounds good.

Yes!


Resolving patch:
diff --git a/mkdocs/main.py b/mkdocs/main.py
--- a/mkdocs/main.py
+++ b/mkdocs/main.py
@@ -4,6 +4,7 @@
 
 import sys
 
+from mkdocs import __version__
 from mkdocs.build import build
 from mkdocs.config import load_config
 from mkdocs.exceptions import ConfigurationError
@@ -44,6 +45,7 @@ def main(cmd, args, options=None):
     elif cmd == 'new':
         new(args, options)
     else:
+        print('MkDocs (version {0})'.format(__version__))
         print('mkdocs [help|new|build|serve|gh-deploy|json] {options}')
 
 


Test patch:
Repository: mkdocs/mkdocs

Issue:
If the mkdocs.yml is completely empty there is a traceback
```
Traceback (most recent call last):
  File "/home/dougalmatthews/.virtualenvs/mkdocs/bin/mkdocs", line 9, in <module>
    load_entry_point('mkdocs==0.11.1', 'console_scripts', 'mkdocs')()
  File "/home/dougalmatthews/.virtualenvs/mkdocs/lib/python3.4/site-packages/mkdocs/main.py", line 60, in run_main
    main(cmd, args=sys.argv[2:], options=dict(opts))
  File "/home/dougalmatthews/.virtualenvs/mkdocs/lib/python3.4/site-packages/mkdocs/main.py", line 32, in main
    config = load_config(options=options)
  File "/home/dougalmatthews/.virtualenvs/mkdocs/lib/python3.4/site-packages/mkdocs/config.py", line 82, in load_config
    user_config.update(options)
AttributeError: 'NoneType' object has no attribute 'update'
```



Discussion:

Resolving patch:
diff --git a/mkdocs/config.py b/mkdocs/config.py
--- a/mkdocs/config.py
+++ b/mkdocs/config.py
@@ -74,11 +74,13 @@
 def load_config(filename='mkdocs.yml', options=None):
     options = options or {}
     if 'config' in options:
-        filename = options['config']
+        filename = options.pop('config')
     if not os.path.exists(filename):
         raise ConfigurationError("Config file '%s' does not exist." % filename)
     with open(filename, 'r') as fp:
         user_config = yaml.load(fp)
+        if not isinstance(user_config, dict):
+            raise ConfigurationError("The mkdocs.yml file is invalid. See http://www.mkdocs.org/user-guide/configuration/ for more information.")
     user_config.update(options)
     return validate_config(user_config)
 


Test patch:
diff --git a/mkdocs/test.py b/mkdocs/test.py
--- a/mkdocs/test.py
+++ b/mkdocs/test.py
@@ -54,6 +54,11 @@ def load_missing_site_name():
             config.validate_config({})
         self.assertRaises(ConfigurationError, load_missing_site_name)
 
+    def test_empty_config(self):
+        def load_empty_config():
+            config.load_config(filename='/dev/null')
+        self.assertRaises(ConfigurationError, load_empty_config)
+
     def test_config_option(self):
         """
         Users can explicitly set the config file using the '--config' option.
Repository: mkdocs/mkdocs

Issue:
`mkdocs serve` doesn't recover from build errors
For example, add a new page to the `pages` setting before you create the file, you then need to manually restart the serve command.



Discussion:

Resolving patch:
diff --git a/mkdocs/serve.py b/mkdocs/serve.py
--- a/mkdocs/serve.py
+++ b/mkdocs/serve.py
@@ -34,8 +34,11 @@ class ConfigEventHandler(BuildEventHandler):
     Perform a rebuild when the config file changes.
     """
     def on_any_event(self, event):
-        if os.path.basename(event.src_path) == 'mkdocs.yml':
-            super(ConfigEventHandler, self).on_any_event(event)
+        try:
+            if os.path.basename(event.src_path) == 'mkdocs.yml':
+                super(ConfigEventHandler, self).on_any_event(event)
+        except Exception as e:
+            print(e)
 
 
 class FixedDirectoryHandler(httpserver.SimpleHTTPRequestHandler):


Test patch:
Repository: mkdocs/mkdocs

Issue:
Hostname for bitbucket is incorrect
The host name used in the automatic `repo_name` detection is wrong. It should be using `bitbucket.org`, but instead it is `bitbucket.com`. This is found in config.py line 140.



Discussion:
heh, good spot!


Resolving patch:
diff --git a/mkdocs/config.py b/mkdocs/config.py
--- a/mkdocs/config.py
+++ b/mkdocs/config.py
@@ -137,7 +137,7 @@ def validate_config(user_config):
         repo_host = urlparse(config['repo_url']).netloc.lower()
         if repo_host == 'github.com':
             config['repo_name'] = 'GitHub'
-        elif repo_host == 'bitbucket.com':
+        elif repo_host == 'bitbucket.org':
             config['repo_name'] = 'Bitbucket'
         else:
             config['repo_name'] = repo_host.split('.')[0].title()


Test patch:
Repository: mkdocs/mkdocs

Issue:
Missing pages build the previous page rather than being skipped
The output shows a warning and that the page is missing, but we incorrectly re-render the previous page in it's place.



Discussion:
Hey d0ugal, you might have already fixed it, but have you considered just having it raise a `MkDocsException` [here](https://github.com/tomchristie/mkdocs/blob/master/mkdocs/build.py#L163) instead of logging the error and carrying on? That would get caught in main.py, halting the build. The site directory would still be partially completed mind you.

@samhatfield thanks - that is where it needs to be fixed, but we should `continue` rather than raising I think. The idea is that we don't want to stop the build if the page doesn't exist, that is quite annoying when you add new pages.


Resolving patch:
diff --git a/mkdocs/build.py b/mkdocs/build.py
--- a/mkdocs/build.py
+++ b/mkdocs/build.py
@@ -157,10 +157,13 @@ def build_pages(config, dump_json=False):
     for page in site_navigation.walk_pages():
         # Read the input file
         input_path = os.path.join(config['docs_dir'], page.input_path)
+
         try:
             input_content = open(input_path, 'r').read()
         except IOError:
             log.error('file not found: %s' % input_path)
+            continue
+
         if PY2:
             input_content = input_content.decode('utf-8')
 


Test patch:
Repository: mkdocs/mkdocs

Issue:
Add build date and MkDocs version to the output
The date was suggested in #290, but didn't seem useful at the time.

However, it would be really useful to see when the output was built and with what version when helping people debug.



Discussion:
So this just needs to be added to the template context


Resolving patch:
diff --git a/mkdocs/build.py b/mkdocs/build.py
--- a/mkdocs/build.py
+++ b/mkdocs/build.py
@@ -1,7 +1,10 @@
 # coding: utf-8
 from __future__ import print_function
 
+from datetime import datetime
+
 from jinja2.exceptions import TemplateNotFound
+import mkdocs
 from mkdocs import nav, toc, utils
 from mkdocs.compat import urljoin, PY2
 from mkdocs.relative_path_ext import RelativePathExtension
@@ -85,7 +88,10 @@ def get_global_context(nav, config):
         'include_search': config['include_search'],
 
         'copyright': config['copyright'],
-        'google_analytics': config['google_analytics']
+        'google_analytics': config['google_analytics'],
+
+        'mkdocs_version': mkdocs.__version__,
+        'build_date_utc': datetime.utcnow()
     }
 
 


Test patch:
Repository: mkdocs/mkdocs

Issue:
Don't allow the `site_dir` to be within the `docs_dir`
This leads to the output being copied into the output during a build.



Discussion:

Resolving patch:
diff --git a/mkdocs/config.py b/mkdocs/config.py
--- a/mkdocs/config.py
+++ b/mkdocs/config.py
@@ -97,6 +97,18 @@ def validate_config(user_config):
     if not config['site_name']:
         raise ConfigurationError("Config must contain 'site_name' setting.")
 
+    # Validate that the docs_dir and site_dir don't contain the
+    # other as this will lead to copying back and forth on each
+    # and eventually make a deep nested mess.
+    abs_site_dir = os.path.abspath(config['site_dir'])
+    abs_docs_dir = os.path.abspath(config['docs_dir'])
+    if abs_docs_dir.startswith(abs_site_dir):
+        raise ConfigurationError(
+            "The 'docs_dir' can't be within the 'site_dir'.")
+    elif abs_site_dir.startswith(abs_docs_dir):
+        raise ConfigurationError(
+            "The 'site_dir' can't be within the 'docs_dir'.")
+
     # If not specified, then the 'pages' config simply includes all
     # markdown files in the docs dir, without generating any header items
     # for them.


Test patch:
diff --git a/mkdocs/tests/config_tests.py b/mkdocs/tests/config_tests.py
--- a/mkdocs/tests/config_tests.py
+++ b/mkdocs/tests/config_tests.py
@@ -111,3 +111,27 @@ def test_default_pages(self):
             self.assertEqual(conf['pages'], ['index.md', 'about.md'])
         finally:
             shutil.rmtree(tmp_dir)
+
+    def test_doc_dir_in_site_dir(self):
+
+        test_configs = (
+            {'docs_dir': 'docs', 'site_dir': 'docs/site'},
+            {'docs_dir': 'site/docs', 'site_dir': 'site'},
+            {'docs_dir': 'docs', 'site_dir': '.'},
+            {'docs_dir': '.', 'site_dir': 'site'},
+            {'docs_dir': '.', 'site_dir': '.'},
+            {'docs_dir': 'docs', 'site_dir': ''},
+            {'docs_dir': '', 'site_dir': 'site'},
+            {'docs_dir': '', 'site_dir': ''},
+            {'docs_dir': '../mkdocs/docs', 'site_dir': 'docs'},
+        )
+
+        conf = {
+            'site_name': 'Example',
+        }
+
+        for test_config in test_configs:
+
+            c = conf.copy()
+            c.update(test_config)
+            self.assertRaises(ConfigurationError, config.validate_config, c)
Repository: mkdocs/mkdocs

Issue:
problem with config in command line 
If I run the follow command in current development version:

mkdocs serve --config=/home/lf/git/mywork/bb/bog/mkdocs.yml

it will raise error:

```
Config file 'mkdocs.yml' does not exist.
```

But if I run the same command use version 0.11.1

Everything is OK

Is there any thing wrong with code below in [config](https://github.com/tomchristie/mkdocs/blob/master/mkdocs/config.py#L79)

```
if 'config' in options:
    filename = options.pop('config')
```

Should it be:

```
if 'config' in options:
    filename = options.get('config')
```

Because when we run `mkdocs serve` , we will execute this block of code two times,   filename  will use the default `mkdocs.yml` in the second time,  this file may not exist.



Discussion:
Interesting, I don't think that part of the code is an issue tho' - I'll need to take a look.

Actually, I take that back - you are completely right.


Resolving patch:
diff --git a/mkdocs/config.py b/mkdocs/config.py
--- a/mkdocs/config.py
+++ b/mkdocs/config.py
@@ -76,7 +76,7 @@
 def load_config(filename='mkdocs.yml', options=None):
     options = options or {}
     if 'config' in options:
-        filename = options.pop('config')
+        filename = options['config']
     if not os.path.exists(filename):
         raise ConfigurationError("Config file '%s' does not exist." % filename)
     with open(filename, 'r') as fp:


Test patch:
Repository: mkdocs/mkdocs

Issue:
`mkdocs new` will overwrite an existing index.md file without warning.
If you run the command: `mkdocs new /path/to/dir` and `/path/to/dir/docs/index.md` already exists it will be replaced with out placeholder.



Discussion:

Resolving patch:
diff --git a/mkdocs/new.py b/mkdocs/new.py
--- a/mkdocs/new.py
+++ b/mkdocs/new.py
@@ -45,6 +45,9 @@ def new(args, options):
     print('Writing config file: %s' % config_path)
     open(config_path, 'w').write(config_text)
 
+    if os.path.exists(index_path):
+        return
+
     print('Writing initial docs: %s' % index_path)
     if not os.path.exists(docs_dir):
         os.mkdir(docs_dir)


Test patch:
Repository: mkdocs/mkdocs

Issue:
Publish personal GitHub pages
I've switched over to using mkdocs for [my personal page](http://jiahao.github.io) and am really liking the output.

I'd like to request that `gh-deploy` be extended to support personal GitHub pages also. Unlike project pages, personal pages must have repository names `<username>.github.io`, and the project is published to the `master` branch instead of `gh-pages`. Everything works fine if I do it manually so I presume supporting personal pages automatically should not be too difficult.

Edit: I have a hacky Makefile that emulates `gh-deploy` (assumes that the markdown source is on a branch called `mkdocs` and deploys to `master`):

``` make
site:
    git checkout mkdocs
    mkdocs build
    git checkout master
    cp -R site/* .
    rm -rf site
    echo Ready to commit and push
```



Discussion:
Seems reasonable. Currently our deploy code is really simple. How can we detect if it is a personal repo vs a project repo? By looking at the structure of the remote? I'd be happy to do this, but I don't want it to be a config option, so how can we figure it out automatically?

Thanks for looking into this request. As far as I understand, a GitHub user can only have one personal repo, and that repo must be named `<username>.github.io`. So whether a repo is personal or project should be quite straightforward to determine from the remote GitHub URL.

Publish personal GitHub pages: I would vote for such an option too.

This would also support organization pages!

Ok, by looking at my personal repo, I think this is how we need to do it.

Look at the output of `git config --get remote.origin.url` which has the format `git@github.com:d0ugal/d0ugal.github.com.git`

if it is `USERNAME/USERNAME.github.com.git` - then we can assume it is a personal/repo pages and push to `master`

Or, alternatively, we could just add the branch as an arguement to the gh-deploy command so you specify master. i.e. `mkdocs gh-deploy --remote-branch master`

Agreed. The latter would provide more flexibility.

I also think the latter is also safer. I'm a bit scared about wiping the master branch on a repo by incorrectly guessing the URL. So lets have the user provide it. :)


Resolving patch:
diff --git a/mkdocs/gh_deploy.py b/mkdocs/gh_deploy.py
--- a/mkdocs/gh_deploy.py
+++ b/mkdocs/gh_deploy.py
@@ -4,13 +4,17 @@
 
 
 def gh_deploy(config):
+
     if not os.path.exists('.git'):
         print('Cannot deploy - this directory does not appear to be a git repository')
         return
 
     print("Copying '%s' to `gh-pages` branch and pushing to GitHub." % config['site_dir'])
     try:
-        subprocess.check_call(['ghp-import', '-p', config['site_dir']])
+        command = ['ghp-import', '-p', config['site_dir']]
+        if 'remote_branch' in config:
+            command.extend(['-b', config['remote_branch']])
+        subprocess.check_call(command)
     except:
         return
 


Test patch:
Repository: mkdocs/mkdocs

Issue:
mkdocs build cleaning removes .git when site_dir points to a parent directory
`mkdocs build --clean` wipes out the project when attempting to split doc development and mkdocs' build output across two git branches (gh-pages, gh-pages-dev) with the following layout:

```
<branch: gh-pages-dev>
$PROJ_ROOT/
|- dev
`  |- doc/
   `- mkdoc.yml  \# NOTE: site_dir=../

<branch: gh-pages>
$PROJ_ROOT/
`- ... \# build output
```

This is so I can both keep everything in the same project and also track the dev/ directory on the dev branch and have the output where it should be on the gh-pages branch. It seems obvious now that this would wipe out everything including the .git/ for the project (glad this was a test). Possibly, it could recursively check `site_dir` for a .git, warn and exit. Or just a disclaimer [here](http://www.mkdocs.org/user-guide/configuration/#build-directories) of this possibility would be enough, so no one else tries this and wipes out their project (and maybe you could recommend to new users how to maintain site development and build output in the same repo).

Thanks,
Kris



Discussion:
Fair point, I think we shouldn't delete any `hidden` files or directories, much like we don't copy them from the docs_dir to the build_dir if they are hidden files/directories.

+1 for this


Resolving patch:
diff --git a/mkdocs/utils.py b/mkdocs/utils.py
--- a/mkdocs/utils.py
+++ b/mkdocs/utils.py
@@ -37,13 +37,21 @@ def clean_directory(directory):
     """
     Remove the content of a directory recursively but not the directory itself.
     """
-    if os.path.exists(directory):
-        for entry in os.listdir(directory):
-            path = os.path.join(directory, entry)
-            if os.path.isdir(path):
-                shutil.rmtree(path, True)
-            else:
-                os.unlink(path)
+    if not os.path.exists(directory):
+        return
+
+    for entry in os.listdir(directory):
+
+        # Don't remove hidden files from the directory. We never copy files
+        # that are hidden, so we shouldn't delete them either.
+        if entry.startswith('.'):
+            continue
+
+        path = os.path.join(directory, entry)
+        if os.path.isdir(path):
+            shutil.rmtree(path, True)
+        else:
+            os.unlink(path)
 
 
 def copy_media_files(from_dir, to_dir):


Test patch:
Repository: mkdocs/mkdocs

Issue:
Deprecate the JSON command
Now that #457 has landed we should have people use the JSON it creates and remove the JSON command which is otherwise a bit weird. 

Add a warning for 0.13
Louder warning in 0.14
Remove in 1.0



Discussion:

Resolving patch:
diff --git a/mkdocs/build.py b/mkdocs/build.py
--- a/mkdocs/build.py
+++ b/mkdocs/build.py
@@ -16,7 +16,7 @@
 from mkdocs.relative_path_ext import RelativePathExtension
 import mkdocs
 
-log = logging.getLogger('mkdocs')
+log = logging.getLogger(__name__)
 
 
 def convert_markdown(markdown_source, site_navigation=None, extensions=(), strict=False):
diff --git a/mkdocs/cli.py b/mkdocs/cli.py
--- a/mkdocs/cli.py
+++ b/mkdocs/cli.py
@@ -12,6 +12,8 @@
 from mkdocs import utils
 from mkdocs.config import load_config
 
+log = logging.getLogger(__name__)
+
 
 def configure_logging(is_verbose=False):
     '''When a --verbose flag is passed, increase the verbosity of mkdocs'''
@@ -86,6 +88,11 @@ def json_command(clean, config_file, strict):
     useful if you want to index your documentation in an external
     search engine.
     """
+
+    log.warning("The json command is deprcated and will be removed in a future "
+                "MkDocs release. For details on updating: "
+                "http://www.mkdocs.org/about/release-notes/")
+
     build.build(load_config(
         config_file=config_file,
         strict=strict


Test patch:
Repository: mkdocs/mkdocs

Issue:
Only creating wheels for Python 2.7
Seems I didn't set something up correctly. It looks like this is a limitation of `setup.py bdist_wheel`



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -46,6 +46,22 @@ def get_package_data(package):
                           for filename in filenames])
     return {package: filepaths}
 
+
+if sys.argv[-1] == 'publish':
+    if os.system("pip freeze | grep wheel"):
+        print("wheel not installed.\nUse `pip install wheel`.\nExiting.")
+        sys.exit()
+    if os.system("pip freeze | grep twine"):
+        print("twine not installed.\nUse `pip install twine`.\nExiting.")
+        sys.exit()
+    os.system("python setup.py sdist bdist_wheel")
+    os.system("twine upload dist/*")
+    print("You probably want to also tag the version now:")
+    print("  git tag -a {0} -m 'version {0}'".format(get_version("mkdocs")))
+    print("  git push --tags")
+    sys.exit()
+
+
 setup(
     name="mkdocs",
     version=get_version("mkdocs"),


Test patch:
Repository: mkdocs/mkdocs

Issue:
Site description not working
Hi,

I have the following configuration

``` yml
site_name: embed.js
site_url: http://embedjs.com
site_author: Ritesh Kumar
site_description: A jQuery plugin that analyses the string and automatically embeds emojis, media, maps, tweets, code and services.
pages:
- Home: index.md
- Getting Started: gettingStarted.md
- How to use ?: usage.md
- Documentation: documentation.md
- Working Examples: examples.md
- Changelogs: history.md
theme: readthedocs
extra_css: ["custom/custom.css"]
site_favicon: img/favicon.ico
repo_url: https://github.com/ritz078/embed.js
google_analytics: ['UA-60624235-2', 'rkritesh.in/embed.js']
```

But sadly author and description are not appearing in the served file. other properties are working fine. Any help will be great.



Discussion:
It looks like these were never added to the ReadTheDocs theme.


Resolving patch:
diff --git a/mkdocs/cli.py b/mkdocs/cli.py
--- a/mkdocs/cli.py
+++ b/mkdocs/cli.py
@@ -88,7 +88,6 @@ def cli():
     """
     MkDocs - Project documentation with Markdown.
     """
-    pass
 
 
 @cli.command(name="serve")


Test patch:
Repository: mkdocs/mkdocs

Issue:
MkDocs incorrectly warns that external themes will be removed in a future release.
A warning that was intended for internal non-mkdocs or readthedocs themes only is being displayed for any other themes.



Discussion:

Resolving patch:
diff --git a/mkdocs/config/config_options.py b/mkdocs/config/config_options.py
--- a/mkdocs/config/config_options.py
+++ b/mkdocs/config/config_options.py
@@ -293,7 +293,17 @@ def run_validation(self, value):
         themes = utils.get_theme_names()
 
         if value in themes:
-            if value in ['mkdocs', 'readthedocs']:
+
+            # These themes have been moved to the mkdocs-bootstrap and
+            # mkdocs-bootswatch packages. At some point we wont depend on
+            # these by default.
+            moved_themes = [
+                'bootstrap', 'amelia', 'cerulean', 'cosmo', 'cyborg',
+                'flatly', 'journal', 'readable', 'simplex', 'slate',
+                'spacelab', 'united', 'yeti'
+            ]
+
+            if value not in moved_themes:
                 return value
 
             self.warnings.append(


Test patch: