示例#1
0
def test_index_has_correct_links_for_md_files(context):
    "The index file should have correct html links for markdown files"

    project = Project.discover(context.project_path)
    theme = Theme.load_from_path(
        LOCAL_FILE('sandbox_simple', 'themes', 'turbo'))
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path),
                       key=sort_files)
    generated.should.have.length_of(5)
    index = generated[0]
    index.should.contain('index')

    html = open(index).read()
    dom = lhtml.fromstring(html)

    links = dom.cssselect('a')

    links.should.have.length_of(3)

    l1, l2, l3 = links

    l1.attrib.should.have.key('href').being.equal('#python-tutorial')
    l2.attrib.should.have.key('href').being.equal('./docs/output.html')
    l3.attrib.should.have.key('href').being.equal('./docs/strings.html')
def test_second_level_has_correct_links_for_md_files(context):
    "The second_level file should have correct html links for markdown files"

    project = Project.discover(context.project_path)
    theme = Theme.load_from_path(LOCAL_FILE('sandbox_simple', 'themes', 'simple-index'))
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path), key=sort_files)
    generated.should.have.length_of(5)

    second_level = generated[1]
    second_level.should.contain('docs/output.html')

    html = open(second_level).read()
    dom = lhtml.fromstring(html)

    links = dom.cssselect('a.index')

    links.should.have.length_of(4)

    l1, l2, l3, l4 = links

    l1.attrib.should.have.key('href').being.equal('../index.html')
    l2.attrib.should.have.key('href').being.to.match('./\w+.html')
    l3.attrib.should.have.key('href').being.to.match('./\w+.html')
    l4.attrib.should.have.key('href').being.equal('./even/deeper/item.html')
示例#3
0
def test_second_level_has_correct_links_for_md_files(context):
    "The second_level file should have correct html links for markdown files"

    project = Project.discover(context.project_path)
    theme = Theme.load_from_path(
        LOCAL_FILE('sandbox_simple', 'themes', 'simple-index'))
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path),
                       key=sort_files)
    generated.should.have.length_of(5)

    second_level = generated[1]
    second_level.should.contain('docs/output.html')

    html = open(second_level).read()
    dom = lhtml.fromstring(html)

    links = dom.cssselect('a.index')

    links.should.have.length_of(4)

    l1, l2, l3, l4 = links

    l1.attrib.should.have.key('href').being.equal('../index.html')
    l2.attrib.should.have.key('href').being.to.match('./\w+.html')
    l3.attrib.should.have.key('href').being.to.match('./\w+.html')
    l4.attrib.should.have.key('href').being.equal('./even/deeper/item.html')
def test_theme_from_folder_succeeds():
    ("Markment should provide a way to load templates from a folder")

    theme = Theme.load_from_path(LOCAL_FILE('sandbox_simple', 'themes', 'turbo'))

    theme.should_not.be.none
    theme.should.be.a(Theme)
    theme.path.should.equal(LOCAL_FILE('sandbox_simple', 'themes', 'turbo'))
示例#5
0
def test_theme_from_folder_succeeds():
    ("Markment should provide a way to load templates from a folder")

    theme = Theme.load_from_path(
        LOCAL_FILE('sandbox_simple', 'themes', 'turbo'))

    theme.should_not.be.none
    theme.should.be.a(Theme)
    theme.path.should.equal(LOCAL_FILE('sandbox_simple', 'themes', 'turbo'))
def test_theme_render():
    ("markment.ui.Theme should be able to render the template")

    theme = Theme.load_from_path(LOCAL_FILE('sandbox_simple', 'themes', 'turbo'))

    theme.should.be.a(Theme)

    rendered = theme.render(documentation='VERY WELL')
    rendered.should.be.an(unicode)
    rendered.should.look_like('<test>This works VERY WELL</test>')
示例#7
0
def test_theme_render():
    ("markment.ui.Theme should be able to render the template")

    theme = Theme.load_from_path(
        LOCAL_FILE('sandbox_simple', 'themes', 'turbo'))

    theme.should.be.a(Theme)

    rendered = theme.render(documentation='VERY WELL')
    rendered.should.be.an(unicode)
    rendered.should.look_like('<test>This works VERY WELL</test>')
def test_theme_get_template():
    ("markment.ui.Theme should return the template")

    theme = Theme.load_from_path(LOCAL_FILE('sandbox_simple', 'themes', 'turbo'))

    theme.should.be.a(Theme)

    template = theme.get_template()

    template.should.be.a(Template)
    template.render.should.be.callable
示例#9
0
文件: bin.py 项目: jpgimenez/markment
def main():
    args = parser.parse_args()

    if not args.PORCELAIN:
        from markment.plugins import couleur_output
    else:
        from markment.plugins import porcelain_output
    if args.SITEMAP_PREFIX:
        from markment.plugins import sitemap

    if args.AUTOINDEX:
        from markment.plugins import autoindex

    if args.JUST_LIST_THEMES:
        if not args.PORCELAIN:
            print LOGO
        return list_themes(args.PORCELAIN)

    project_path = abspath(args.SOURCE)
    output_path = abspath(args.OUTPUT)
    before.all.shout(args)
    project = Project.discover(project_path)
    if exists(join(args.THEME, 'markment.yml')):
        theme = Theme.load_from_path(args.THEME)
    elif os.sep not in args.THEME:
        try:
            theme = Theme.load_by_name(args.THEME)
        except InvalidThemePackage:
            print "." * 20
            print "\033[1;32m Invalid theme name\033[0m"
            print "." * 20
            print
            print "\033[1;31mMarkment doesn't have a builtin theme called \033[0m'{0}'".format(
                args.THEME)
            print
            return list_themes()
    else:
        print "Invalid theme name:", args.THEME
        print
        return list_themes()

    if args.RUNSERVER:
        print "\033[1;32mMarkment is serving the documentation "
        print "under \033[1;31m'./{0}' \033[1;32mdynamically\033[0m".format(
            relpath(project_path))
        print
        print "\033[1;33mNow you can just change whatever files you want"
        print "and refresh your browser\033[0m"
        print
        return server(project_path, theme).run(debug=True, use_reloader=False)

    destination = Generator(project, theme)
    generated = destination.persist(output_path, gently=True)
    after.all.shout(args, project, theme, generated)
示例#10
0
def test_theme_get_template():
    ("markment.ui.Theme should return the template")

    theme = Theme.load_from_path(
        LOCAL_FILE('sandbox_simple', 'themes', 'turbo'))

    theme.should.be.a(Theme)

    template = theme.get_template()

    template.should.be.a(Template)
    template.render.should.be.callable
示例#11
0
def test_theme_get_index():
    ("markment.ui.Theme should return the template content")

    theme = Theme.load_from_path(LOCAL_FILE('sandbox_simple', 'themes', 'turbo'))

    theme.should.be.a(Theme)

    index = theme.index

    index.should.be.a(dict)
    index.should.have.key('index_template').being.equal('base.html')
    index.should.have.key('static_path').being.equal(LOCAL_FILE('sandbox_simple', 'themes', 'turbo', 'media'))
示例#12
0
def main():
    args = parser.parse_args()

    if not args.PORCELAIN:
        from markment.plugins import couleur_output
    else:
        from markment.plugins import porcelain_output
    if args.SITEMAP_PREFIX:
        from markment.plugins import sitemap

    if args.AUTOINDEX:
        from markment.plugins import autoindex

    if args.JUST_LIST_THEMES:
        if not args.PORCELAIN:
            print LOGO
        return list_themes(args.PORCELAIN)

    project_path = abspath(args.SOURCE)
    output_path = abspath(args.OUTPUT)
    before.all.shout(args)
    project = Project.discover(project_path)
    if exists(join(args.THEME, 'markment.yml')):
        theme = Theme.load_from_path(args.THEME)
    elif os.sep not in args.THEME:
        try:
            theme = Theme.load_by_name(args.THEME)
        except InvalidThemePackage:
            print "." * 20
            print "\033[1;32m Invalid theme name\033[0m"
            print "." * 20
            print
            print "\033[1;31mMarkment doesn't have a builtin theme called \033[0m'{0}'".format(args.THEME)
            print
            return list_themes()
    else:
        print "Invalid theme name:", args.THEME
        print
        return list_themes()

    if args.RUNSERVER:
        print "\033[1;32mMarkment is serving the documentation "
        print "under \033[1;31m'./{0}' \033[1;32mdynamically\033[0m".format(
            relpath(project_path))
        print
        print "\033[1;33mNow you can just change whatever files you want"
        print "and refresh your browser\033[0m"
        print
        return server(project_path, theme).run(debug=True, use_reloader=False)

    destination = Generator(project, theme)
    generated = destination.persist(output_path, gently=True)
    after.all.shout(args, project, theme, generated)
示例#13
0
def test_theme_get_index():
    ("markment.ui.Theme should return the template content")

    theme = Theme.load_from_path(
        LOCAL_FILE('sandbox_simple', 'themes', 'turbo'))

    theme.should.be.a(Theme)

    index = theme.index

    index.should.be.a(dict)
    index.should.have.key('index_template').being.equal('base.html')
    index.should.have.key('static_path').being.equal(
        LOCAL_FILE('sandbox_simple', 'themes', 'turbo', 'media'))
示例#14
0
def test_second_level_file(context):
    "The second_level file should have the assets pointing to the right path"

    project = Project.discover(context.project_path)
    theme = Theme.load_from_path(context.theme_path)
    destination = Generator(project, theme)
    generated = sorted(filter_html(destination.persist(context.output_path)), key=sort_files)
    generated.should.have.length_of(2)

    second_level = generated[1]
    second_level.should.contain('docs/index.html')

    html = open(second_level).read()
    dom = lhtml.fromstring(html)

    links = dom.cssselect('link.theme-asset')

    links.should.have.length_of(1)

    style = links[0]

    style.attrib.should.have.key("href").being.equal("../assets/stylesheets/stylesheet.css")
def test_index_has_correct_links_for_md_files(context):
    "The index file should have correct html links for markdown files"

    project = Project.discover(context.project_path)
    theme = Theme.load_from_path(LOCAL_FILE('sandbox_simple', 'themes', 'turbo'))
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path), key=sort_files)
    generated.should.have.length_of(5)
    index = generated[0]
    index.should.contain('index')

    html = open(index).read()
    dom = lhtml.fromstring(html)

    links = dom.cssselect('a')

    links.should.have.length_of(3)

    l1, l2, l3 = links

    l1.attrib.should.have.key('href').being.equal('#python-tutorial')
    l2.attrib.should.have.key('href').being.equal('./docs/output.html')
    l3.attrib.should.have.key('href').being.equal('./docs/strings.html')
示例#16
0
def test_second_level_file(context):
    "The second_level file should have the assets pointing to the right path"

    project = Project.discover(context.project_path)
    theme = Theme.load_from_path(context.theme_path)
    destination = Generator(project, theme)
    generated = sorted(filter_html(destination.persist(context.output_path)),
                       key=sort_files)
    generated.should.have.length_of(2)

    second_level = generated[1]
    second_level.should.contain('docs/index.html')

    html = open(second_level).read()
    dom = lhtml.fromstring(html)

    links = dom.cssselect('link.theme-asset')

    links.should.have.length_of(1)

    style = links[0]

    style.attrib.should.have.key("href").being.equal(
        "../assets/stylesheets/stylesheet.css")