Repository: mkdocs/mkdocs

Issue:
Multi-page documentaion does not work on Windows
Multi-page documentation did not work on Windows, possibly because of Windows usage of backward slash instead of forward slash for paths.

![capture](https://cloud.githubusercontent.com/assets/627637/5159293/1d38f74e-732e-11e4-807f-28fd80831b07.PNG)

Should be similar to:

![capture2](https://cloud.githubusercontent.com/assets/627637/5159302/85909c70-732e-11e4-9e6a-e285d13704ee.PNG)



Discussion:
Ah, interesting. Thanks for the report. Can you confirm which versions of MkDocs you are using?

Windows support is currently a 'best effort' as neither I or Tom use windows regularly (as far as I know).

I don't use Windows that often as well, but unfortunately I have to use it as it is my main workstation at work. 

I'm currently using MkDocs version 0.11.1.

Thanks for the quick reply!

Hey guys,

Confirming that on windows mkdocs fails to create proper nested navigation regardless of what theme is used it breaks.

# Version

mkdocs-0.11.1-py3.4.egg

# Repro

Install mkdocs on windows - see https://github.com/tomchristie/mkdocs/issues/187#issuecomment-66014638

```
$ git clone https://github.com/ghuntley/ReactiveUI/
$ cd reactiveui
$ git checkout readthedocs
$ mkdocs serve
```

This repo works fine on osx/windows or on readthedocs

![screencapture-localhost-8000](https://cloud.githubusercontent.com/assets/127353/5335498/4ed8f5a6-7eff-11e4-98c3-a3a4bd663273.png)

Best guess is the hard coding to string.Contains "/" is why it is breaking:

https://github.com/tomchristie/mkdocs/blob/master/mkdocs/nav.py#L84-L104
https://github.com/tomchristie/mkdocs/blob/master/mkdocs/nav.py#L212-L217

On windows this will be "\"; not specifically sure how the python handles this in a xplat way.

Can confirm resolution by monkey-patching nav.py via a search and replace of '/' to '\\' but of course this breaks it on OSX.  

@ghuntley Awesome. Thanks for doing the investigation. Is this broken both with `mkodcs serve` and `mkdocs build`? I can try having a go at fixing this with your pointers, but would appreciate help testing.


Resolving patch:
diff --git a/mkdocs/nav.py b/mkdocs/nav.py
--- a/mkdocs/nav.py
+++ b/mkdocs/nav.py
@@ -210,10 +210,11 @@ def _generate_site_navigation(pages_config, url_context, use_directory_urls=True
             assert False, msg
 
         if title is None:
-            filename = path.split('/')[0]
+            filename = path.split(os.path.sep)[0]
             title = filename_to_title(filename)
-        if child_title is None and '/' in path:
-            filename = path.split('/')[1]
+
+        if child_title is None and os.path.sep in path:
+            filename = path.split(os.path.sep)[-1]
             child_title = filename_to_title(filename)
 
         url = utils.get_url_path(path, use_directory_urls)


Test patch:
diff --git a/mkdocs/test.py b/mkdocs/test.py
--- a/mkdocs/test.py
+++ b/mkdocs/test.py
@@ -6,6 +6,7 @@
 from mkdocs.compat import PY2, zip
 from mkdocs.exceptions import ConfigurationError
 import markdown
+import mock
 import os
 import shutil
 import tempfile
@@ -401,6 +402,44 @@ def test_base_url(self):
         base_url = site_navigation.url_context.make_relative('/')
         self.assertEqual(base_url, '.')
 
+    def test_generate_site_navigation(self):
+        """
+        Verify inferring page titles based on the filename
+        """
+
+        pages = [
+            ('index.md', ),
+            ('api-guide/running.md', ),
+            ('about/notes.md', ),
+            ('about/sub/license.md', ),
+        ]
+
+        url_context = nav.URLContext()
+        nav_items, pages = nav._generate_site_navigation(pages, url_context)
+
+        self.assertEqual([n.title for n in nav_items], ['Api guide', 'About'])
+        self.assertEqual([p.title for p in pages],
+                         ['Home', 'Running', 'Notes', 'License'])
+
+    @mock.patch.object(os.path, 'sep', '\\')
+    def test_generate_site_navigation_windows(self):
+        """
+        Verify inferring page titles based on the filename with a windows path
+        """
+        pages = [
+            ('index.md', ),
+            ('api-guide\\running.md', ),
+            ('about\\notes.md', ),
+            ('about\\sub\\license.md', ),
+        ]
+
+        url_context = nav.URLContext()
+        nav_items, pages = nav._generate_site_navigation(pages, url_context)
+
+        self.assertEqual([n.title for n in nav_items], ['Api guide', 'About'])
+        self.assertEqual([p.title for p in pages],
+                         ['Home', 'Running', 'Notes', 'License'])
+
 
 class BuildTests(unittest.TestCase):
     def test_convert_markdown(self):