예제 #1
0
def test_second_level_toc_links_point_to_html_files(context):
    "The second_level file should have correct html links for markdown files"

    project = Project.discover(context.project_path)
    theme = Theme.load_by_name('touch-of-pink')
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path),
                       key=sort_files)
    generated.should.have.length_of(7)

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

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

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

    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')
예제 #2
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')
예제 #3
0
def test_project_should_render_all_markdown_files_with_certain_theme():
    ("core.Project#generate(theme) should return each one "
     "of the markdown files under the given template")

    theme = Theme.load_by_name('touch-of-pink')

    project = Project.discover(os.getcwdu())

    generated = list(sorted(project.generate(theme), key=lambda x: len(x['relative_path'])))

    generated.should_not.be.empty

    readme = generated[0]

    readme.should.be.a(dict)
    readme.should.have.key('markdown')
    readme.should.have.key('indexes')
    readme.should.have.key('documentation')
    readme.should.have.key('html')
    readme.should.have.key('path')
    readme.should.have.key('relative_path')

    len(readme['html']).should.be.above(len(readme['documentation']))
    readme['path'].should.equal(CWD_FILE('index.md'))
    readme['relative_path'].should.equal(relpath(CWD_FILE('index.md')))
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')
예제 #5
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_toc_links_point_to_html_files(context):
    "The second_level file should have correct html links for markdown files"

    project = Project.discover(context.project_path)
    theme = Theme.load_by_name('touch-of-pink')
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path), key=sort_files)
    generated.should.have.length_of(7)

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

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

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

    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')
예제 #7
0
def test_project_should_find_metadata():
    "core.Project.discover() should find metadata in a .markment.yml file"

    project = Project.discover(os.getcwdu())

    project.should.be.a(Project)
    project.should.have.property('name').being.equal('Markment')
    project.should.have.property('version').being.equal('0.2.6')
    project.should.have.property('description').being.equal(
        'A markdown-based automatic documentation generator')
예제 #8
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)
예제 #9
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)
def test_generate_files(context):
    "Markment should find files and generate them"

    project = Project.discover(context.project_path)
    theme = Theme.load_by_name('touch-of-pink')
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path), key=sort_files)
    generated.should.be.a(list)
    map(relpath, generated).should.equal(map(relpath, [
        LOCAL_FILE('output/index.html'),
        LOCAL_FILE('output/assets/style.css'),
        LOCAL_FILE('output/docs/output.html'),
        LOCAL_FILE('output/docs/strings.html'),
        LOCAL_FILE('output/img/logo.png'),
        LOCAL_FILE('output/assets/img/favicon.png'),
        LOCAL_FILE('output/docs/even/deeper/item.html'),
    ]))
예제 #11
0
def test_generate_files(context):
    "Markment should find files and generate them"

    project = Project.discover(context.project_path)
    theme = Theme.load_by_name('touch-of-pink')
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path),
                       key=sort_files)
    generated.should.be.a(list)
    map(relpath, generated).should.equal(
        map(relpath, [
            LOCAL_FILE('output/index.html'),
            LOCAL_FILE('output/assets/style.css'),
            LOCAL_FILE('output/docs/output.html'),
            LOCAL_FILE('output/docs/strings.html'),
            LOCAL_FILE('output/img/logo.png'),
            LOCAL_FILE('output/assets/img/favicon.png'),
            LOCAL_FILE('output/docs/even/deeper/item.html'),
        ]))
def test_index_file(context):
    "The index file should have the assets pointing to the right path"

    project = Project.discover(context.project_path)
    theme = Theme.load_by_name('touch-of-pink')
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path), key=lambda x: len(x.split(os.sep)))
    generated.should.have.length_of(7)

    index = generated[0]

    html = open(index).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/style.css")
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_by_name('touch-of-pink')
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path), key=sort_files)
    generated.should.have.length_of(7)

    second_level = generated[2]
    second_level.should.contain('docs/output.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/style.css")
def test_index_images_point_to_right_place(context):
    "The index file should have correct html paths to images"

    project = Project.discover(context.project_path)
    theme = Theme.load_by_name('touch-of-pink')
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path), key=sort_files)
    generated.should.have.length_of(7)

    index = generated[0]
    index.should.contain('index')

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

    images = dom.cssselect('img')

    images.should.have.length_of(1)

    img = images[0]

    img.attrib.should.have.key('src').being.equal("./img/logo.png")
예제 #15
0
def test_first_level_file(context):
    "The first 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=lambda x: len(x.split(os.sep)))
    generated.should.have.length_of(2)

    first_level = generated[0]
    first_level.should.contain('index.html')

    html = open(first_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_second_level_stylesheets_point_to_right_place(context):
    "The second_level file should have correct html paths to stylesheets"

    project = Project.discover(context.project_path)
    theme = Theme.load_by_name('touch-of-pink')
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path), key=sort_files)
    generated.should.have.length_of(7)

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

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

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

    stylesheets.should.have.length_of(1)

    img = stylesheets[0]

    img.attrib.should.have.key('href').being.equal("../assets/style.css")
예제 #17
0
def test_index_file(context):
    "The index file should have the assets pointing to the right path"

    project = Project.discover(context.project_path)
    theme = Theme.load_by_name('touch-of-pink')
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path),
                       key=lambda x: len(x.split(os.sep)))
    generated.should.have.length_of(7)

    index = generated[0]

    html = open(index).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/style.css")
예제 #18
0
def test_index_images_point_to_right_place(context):
    "The index file should have correct html paths to images"

    project = Project.discover(context.project_path)
    theme = Theme.load_by_name('touch-of-pink')
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path),
                       key=sort_files)
    generated.should.have.length_of(7)

    index = generated[0]
    index.should.contain('index')

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

    images = dom.cssselect('img')

    images.should.have.length_of(1)

    img = images[0]

    img.attrib.should.have.key('src').being.equal("./img/logo.png")
예제 #19
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_by_name('touch-of-pink')
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path),
                       key=sort_files)
    generated.should.have.length_of(7)

    second_level = generated[2]
    second_level.should.contain('docs/output.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/style.css")
예제 #20
0
def test_second_level_stylesheets_point_to_right_place(context):
    "The second_level file should have correct html paths to stylesheets"

    project = Project.discover(context.project_path)
    theme = Theme.load_by_name('touch-of-pink')
    destination = Generator(project, theme)
    generated = sorted(destination.persist(context.output_path),
                       key=sort_files)
    generated.should.have.length_of(7)

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

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

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

    stylesheets.should.have.length_of(1)

    img = stylesheets[0]

    img.attrib.should.have.key('href').being.equal("../assets/style.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')
예제 #22
0
def test_first_level_file(context):
    "The first 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=lambda x: len(x.split(os.sep)))
    generated.should.have.length_of(2)

    first_level = generated[0]
    first_level.should.contain('index.html')

    html = open(first_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")
예제 #23
0
 def get_project():
     g.project = Project.discover(current_dir)
예제 #24
0
 def get_project():
     g.project = Project.discover(current_dir)