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):
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
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.
"""

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)


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

@@ -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)


+ 10
- 0
setup.py View File

@@ -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 = ''



Loading…
Cancel
Save