Browse Source

Fixed setup.py to use html from markdown

main
Lakshmi Vyasarajan 13 years ago
parent
commit
bb8e3babec
4 changed files with 31 additions and 9 deletions
  1. +14
    -4
      hyde/ext/plugins/depends.py
  2. +6
    -3
      hyde/generator.py
  3. +1
    -2
      hyde/tests/ext/test_depends.py
  4. +10
    -0
      setup.py

+ 14
- 4
hyde/ext/plugins/depends.py View File

@@ -16,7 +16,18 @@ class DependsPlugin(Plugin):
def __init__(self, site): def __init__(self, site):
super(DependsPlugin, self).__init__(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, If the meta data for the resource contains a depends attribute,
this plugin adds an entry to the depends property of the this plugin adds an entry to the depends property of the
@@ -33,7 +44,7 @@ class DependsPlugin(Plugin):
try: try:
depends = resource.meta.depends depends = resource.meta.depends
except AttributeError: except AttributeError:
pass
return


if not hasattr(resource, 'depends') or not resource.depends: if not hasattr(resource, 'depends') or not resource.depends:
resource.depends = [] resource.depends = []
@@ -46,5 +57,4 @@ class DependsPlugin(Plugin):
resource=resource, resource=resource,
site=self.site, site=self.site,
context=self.site.context)) context=self.site.context))
resource.depends = list(set(resource.depends))
return text
resource.depends = list(set(resource.depends))

+ 6
- 3
hyde/generator.py View File

@@ -124,16 +124,19 @@ class Generator(object):
""" """
Updates the dependencies for the given resource. Updates the dependencies for the given resource.
""" """

if not resource.source_file.is_text:
return []
rel_path = resource.relative_path rel_path = resource.relative_path
deps = [] deps = []
if hasattr(resource, 'depends'): if hasattr(resource, 'depends'):
user_deps = resource.depends user_deps = resource.depends
for dep in user_deps: for dep in user_deps:
deps.append(dep) 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)) deps = list(set(deps))
if None in deps: if None in deps:
deps.remove(None) deps.remove(None)


+ 1
- 2
hyde/tests/ext/test_depends.py View File

@@ -36,8 +36,7 @@ class TestDepends(object):
=== ===
depends: index.html depends: index.html
=== ===
{% set ind = 'index.html' %}
{% refer to ind as index %}

""" """
inc = File(TEST_SITE.child('content/inc.md')) inc = File(TEST_SITE.child('content/inc.md'))
inc.write(text) inc.write(text)


+ 10
- 0
setup.py View File

@@ -13,8 +13,18 @@ import sys


PROJECT = 'hyde' PROJECT = 'hyde'


try:
import markdown
except:
markdown = False

try: try:
long_description = open('README.markdown', 'rt').read() 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: except IOError:
long_description = '' long_description = ''




Loading…
Cancel
Save