From dc7fee4e64a15d1acac6de155d0fa68307cd327b Mon Sep 17 00:00:00 2001 From: Justin Kinney Date: Tue, 22 Sep 2015 13:49:31 -0700 Subject: [PATCH] fixes https://github.com/mkdocs/mkdocs/issues/728 --- mkdocs/utils/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mkdocs/utils/__init__.py b/mkdocs/utils/__init__.py index 9b85fc0d..c7b6ac56 100644 --- a/mkdocs/utils/__init__.py +++ b/mkdocs/utils/__init__.py @@ -393,6 +393,17 @@ def filename_to_title(filename): return title +def dirname_to_title(dirname): + + title = dirname + title = title.replace('-', ' ').replace('_', ' ') + # Capitalize if the dirname was all lowercase, otherwise leave it as-is. + if title.lower() == title: + title = title.capitalize() + + return title + + def find_or_create_node(branch, key): """ Given a list, look for dictionary with a key matching key and return it's @@ -431,7 +442,7 @@ def nest_paths(paths): branch = nested for part in parts: - part = filename_to_title(part) + part = dirname_to_title(part) branch = find_or_create_node(branch, part) branch.append(path)