Skip to content

Commit

Permalink
Experimentation with theme loading
Browse files Browse the repository at this point in the history
  • Loading branch information
d0ugal committed May 16, 2015
1 parent 93a181a commit 9d95d7d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
Empty file added mkdocs/themes/__init__.py
Empty file.
Empty file.
Empty file.
16 changes: 15 additions & 1 deletion mkdocs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
and structure of the site and pages in the site.
"""

from pkg_resources import iter_entry_points
import os
import shutil

Expand Down Expand Up @@ -299,10 +300,23 @@ def convert_markdown(markdown_source, extensions=None, extension_configs=None):
return (html_content, table_of_contents, meta)


def get_themes():
"""Return a dict of theme names and their locations"""

themes = {}

for theme in iter_entry_points(group='mkdocs.themes', name=None):
theme = theme.load()
location = os.path.dirname(theme.__file__)
themes[theme.name] = location

return themes


def get_theme_names():
"""Return a list containing all the names of all the builtin themes."""

return os.listdir(os.path.join(os.path.dirname(__file__), 'themes'))
return get_themes().keys()


def filename_to_title(filename):
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def get_package_data(package):
'console_scripts': [
'mkdocs = mkdocs.cli:cli',
],
'mkdocs.themes': [
'mkdocs = mkdocs.themes.mkdocs',
'readthedocs = mkdocs.themes.readthedocs',
]
},
classifiers=[
'Development Status :: 5 - Production/Stable',
Expand All @@ -106,7 +110,7 @@ def get_package_data(package):
'Topic :: Documentation',
'Topic :: Text Processing',
],
zip_safe=False
zip_safe=False,
)

# (*) Please direct queries to the discussion group:
Expand Down

0 comments on commit 9d95d7d

Please sign in to comment.