diff --git a/hyde/ext/plugins/depends.py b/hyde/ext/plugins/depends.py index 403b015..b8c7316 100644 --- a/hyde/ext/plugins/depends.py +++ b/hyde/ext/plugins/depends.py @@ -16,7 +16,18 @@ class DependsPlugin(Plugin): def __init__(self, site): super(DependsPlugin, self).__init__(site) - def begin_text_resource(self, resource, text): + def begin_site(self): + """ + Initialize dependencies. + + Go through all the nodes and resources to initialize + dependencies at each level. + """ + for resource in self.site.content.walk_resources(): + self._update_resource(resource) + + + def _update_resource(self, resource): """ If the meta data for the resource contains a depends attribute, this plugin adds an entry to the depends property of the @@ -33,7 +44,7 @@ class DependsPlugin(Plugin): try: depends = resource.meta.depends except AttributeError: - pass + return if not hasattr(resource, 'depends') or not resource.depends: resource.depends = [] @@ -46,5 +57,4 @@ class DependsPlugin(Plugin): resource=resource, site=self.site, context=self.site.context)) - resource.depends = list(set(resource.depends)) - return text \ No newline at end of file + resource.depends = list(set(resource.depends)) \ No newline at end of file diff --git a/hyde/generator.py b/hyde/generator.py index 6977655..d808f35 100644 --- a/hyde/generator.py +++ b/hyde/generator.py @@ -124,16 +124,19 @@ class Generator(object): """ Updates the dependencies for the given resource. """ - + if not resource.source_file.is_text: + return [] rel_path = resource.relative_path deps = [] if hasattr(resource, 'depends'): user_deps = resource.depends for dep in user_deps: deps.append(dep) - deps.extend(self.template.get_dependencies(dep)) + dep_res = self.site.content.resource_from_relative_path(dep) + if dep_res: + deps.extend(self.get_dependencies(dep_res)) - deps.extend(self.template.get_dependencies(resource.relative_path)) + deps.extend(self.template.get_dependencies(rel_path)) deps = list(set(deps)) if None in deps: deps.remove(None) diff --git a/hyde/tests/ext/test_depends.py b/hyde/tests/ext/test_depends.py index 995011f..b7219a4 100644 --- a/hyde/tests/ext/test_depends.py +++ b/hyde/tests/ext/test_depends.py @@ -36,8 +36,7 @@ class TestDepends(object): === depends: index.html === -{% set ind = 'index.html' %} -{% refer to ind as index %} + """ inc = File(TEST_SITE.child('content/inc.md')) inc.write(text) diff --git a/setup.py b/setup.py index c37b337..9318f2e 100644 --- a/setup.py +++ b/setup.py @@ -13,8 +13,18 @@ import sys PROJECT = 'hyde' +try: + import markdown +except: + markdown = False + try: long_description = open('README.markdown', 'rt').read() + if markdown: + long_description = markdown.markdown(long_description) + import re + long_description = re.sub('(.*)', ' \\1', long_description) + long_description ='.. raw:: html\n\n' + long_description except IOError: long_description = ''