Repository: mkdocs/mkdocs

Issue:
Title is used as a section if file is in subdirectory
Assuming I have a file at `research/stats.md` and a config line:

```
pages:
- ["research/stats.md", "Stats about Our Collection"]
```

I would assume that it would generate a top-level nav item titled  "Stats about Our Collection".

In reality, it generates a section **Stats about Our Collection** with a sub-item titled **stats**.

I'm 90% sure this has to do with the logic in [nav.py](https://github.com/mkdocs/mkdocs/blob/master/mkdocs/nav.py#L212-L218) around `child_titles`.



Discussion:
Hmm, this is an interesting one :) I've got a failing test case, but not quite figured out a fix yet. It seems that the current logic assumes that if the path contains a `/` that you want it to be nested, which I agree, doesn't seem correct.


Resolving patch:
diff --git a/mkdocs/nav.py b/mkdocs/nav.py
--- a/mkdocs/nav.py
+++ b/mkdocs/nav.py
@@ -209,14 +209,17 @@ def _generate_site_navigation(pages_config, url_context, use_directory_urls=True
             )
             raise exceptions.ConfigurationError(msg)
 
+        # If both the title and child_title are None, then we
+        # have just been given a path. If that path contains a /
+        # then lets automatically nest it.
+        if title is None and child_title is None and os.path.sep in path:
+            filename = path.split(os.path.sep)[-1]
+            child_title = filename_to_title(filename)
+
         if title is None:
             filename = path.split(os.path.sep)[0]
             title = filename_to_title(filename)
 
-        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)
 
         if not child_title:


Test patch:
diff --git a/mkdocs/tests/nav_tests.py b/mkdocs/tests/nav_tests.py
--- a/mkdocs/tests/nav_tests.py
+++ b/mkdocs/tests/nav_tests.py
@@ -63,6 +63,39 @@ def test_indented_toc(self):
         self.assertEqual(len(site_navigation.nav_items), 3)
         self.assertEqual(len(site_navigation.pages), 6)
 
+    def test_nested_ungrouped(self):
+        pages = [
+            ('index.md', 'Home'),
+            ('about/contact.md', 'Contact'),
+            ('about/sub/license.md', 'License Title')
+        ]
+        expected = dedent("""
+        Home - /
+        Contact - /about/contact/
+        License Title - /about/sub/license/
+        """)
+        site_navigation = nav.SiteNavigation(pages)
+        self.assertEqual(str(site_navigation).strip(), expected)
+        self.assertEqual(len(site_navigation.nav_items), 3)
+        self.assertEqual(len(site_navigation.pages), 3)
+
+    def test_nested_ungrouped_no_titles(self):
+        pages = [
+            ('index.md',),
+            ('about/contact.md'),
+            ('about/sub/license.md')
+        ]
+        expected = dedent("""
+        Home - /
+        About
+            Contact - /about/contact/
+            License - /about/sub/license/
+        """)
+        site_navigation = nav.SiteNavigation(pages)
+        self.assertEqual(str(site_navigation).strip(), expected)
+        self.assertEqual(len(site_navigation.nav_items), 2)
+        self.assertEqual(len(site_navigation.pages), 3)
+
     def test_walk_simple_toc(self):
         pages = [
             ('index.md', 'Home'),