Repository: mkdocs/mkdocs

Issue:
current_page.ancestors only contains direct ancestor and not the full path of the page
I'm using the mkdocs theme and tried to enhance it with a breadcrumb trail. The page navigation is created automatically by mkdocs (I don't use the pages confguration since I have almost 300 pages).
I copied and adapted the `breadcrumbs.html` file from the readthedocs theme and integrated it in `content.html`:

```
<ol class="breadcrumb">
<li><a href="{{ homepage_url }}">Docs</a></li>
{% if current_page %}
  {% for doc in current_page.ancestors %}
    {% if doc.link %}
      <li><a href="{{ doc.link|e }}">{{ doc.title }}</a></li>
    {% else %}
      <li>{{ doc.title }}</li>
    {% endif %}
  {% endfor %}
{% endif %}
{% if current_page %}<li>{{ current_page.title }}</li>{% endif %}
</ol>
```

My file path (starting from the `docs_dir`)  is:
`beheerteam/diensten/algemeen/ActiveDirectory.md`
The generated breadcrumb trail is:
`Docs/algemeen/ActiveDirectory`

`algemeen` is the only part that originates from the loop `for doc in current_page.ancestors`.

Maybe this is a stupid question or it is just not possible, but I couldn't find i in the documentation and I'm just starting with mkdocs and couldn't understand the source on how this works.



Discussion:

Resolving patch:
diff --git a/mkdocs/nav.py b/mkdocs/nav.py
--- a/mkdocs/nav.py
+++ b/mkdocs/nav.py
@@ -217,7 +217,7 @@ def _follow(config_line, url_context, use_dir_urls, header=None, title=None):
         page = _path_to_page(path, title, url_context, use_dir_urls)
 
         if header:
-            page.ancestors = [header]
+            page.ancestors = header.ancestors + [header, ]
             header.children.append(page)
 
         yield page


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
@@ -325,6 +325,9 @@ def test_ancestors(self):
                 {'Running': 'api-guide/running.md'},
                 {'Testing': 'api-guide/testing.md'},
                 {'Debugging': 'api-guide/debugging.md'},
+                {'Advanced': [
+                    {'Part 1': 'api-guide/advanced/part-1.md'},
+                ]},
             ]},
             {'About': [
                 {'Release notes': 'about/release-notes.md'},
@@ -338,12 +341,18 @@ def test_ancestors(self):
             [site_navigation.nav_items[1]],
             [site_navigation.nav_items[1]],
             [site_navigation.nav_items[1]],
+            [site_navigation.nav_items[1],
+                site_navigation.pages[4].ancestors[-1]],
             [site_navigation.nav_items[2]],
             [site_navigation.nav_items[2]],
         )
 
-        for page, expected_ancestor in zip(site_navigation.pages, ancestors):
-            self.assertEqual(page.ancestors, expected_ancestor)
+        self.assertEqual(len(site_navigation.pages), len(ancestors))
+
+        for i, (page, expected_ancestor) in enumerate(
+                zip(site_navigation.pages, ancestors)):
+            self.assertEqual(page.ancestors, expected_ancestor,
+                             "Failed on ancestor test {0}".format(i))
 
     def test_nesting(self):