Пример #1
0
def build(ctx, less=False, docs=False, js=False, force=False):
    """Build everything and collectstatic.
    """
    specified = any([less, docs, js])
    buildall = not specified

    if buildall or less:
        less_fname = ctx.pkg.source_less / ctx.pkg.name + '.less'
        if less_fname.exists():
            lessc.LessRule(
                ctx,
                src='{pkg.source_less}/{pkg.name}.less',
                dst=
                '{pkg.django_static}/{pkg.name}/css/{pkg.name}-{version}.min.css',
                force=force)
        elif less:
            warnings.warn("WARNING: build --less specified, but no file at: " +
                          less_fname)

    if buildall or docs:
        if WARN_ABOUT_SETTINGS:
            warnings.warn(
                "autodoc might need a dummy settings file in the root of "
                "your package. Since it runs in a separate process you cannot"
                "use settings.configure()")
        doctools.build(ctx, force=force)

    if buildall or js:
        build_js(ctx, force)

    if HAVE_SETTINGS and (force or changed(ctx.pkg.django_static)):
        collectstatic(ctx, DJANGO_SETTINGS_MODULE, force=force)
Пример #2
0
def build(ctx, less=False, docs=False, js=False, force=False):
    """Build everything and collectstatic.
    """
    specified = any([less, docs, js])
    buildall = not specified

    if buildall or less:
        less_fname = ctx.pkg.source_less / ctx.pkg.name + '.less'
        if less_fname.exists():
            lessc.LessRule(
                ctx,
                src='{pkg.source_less}/{pkg.name}.less',
                dst='{pkg.django_static}/{pkg.name}/css/{pkg.name}-{version}.min.css',
                force=force
            )
        elif less:
            warnings.warn(
                "WARNING: build --less specified, but no file at: " + less_fname
            )

    if buildall or docs:
        if WARN_ABOUT_SETTINGS:
            warnings.warn(
                "autodoc might need a dummy settings file in the root of "
                "your package. Since it runs in a separate process you cannot"
                "use settings.configure()"
            )
        doctools.build(ctx, force=force)

    if buildall or js:
        build_js(ctx, force)

    if HAVE_SETTINGS and (force or changed(ctx.pkg.django_static)):
        collectstatic(ctx, DJANGO_SETTINGS_MODULE, force=force)
Пример #3
0
def build(ctx, less=False, docs=False, js=False, force=False):
    """Build everything and collectstatic.
    """
    specified = any([less, docs, js])
    buildall = not specified

    if buildall or less:
        less_fname = ctx.pkg.source_less / ctx.pkg.name + '.less'
        if less_fname.exists():
            lessc.LessRule(
                ctx,
                src='{pkg.source_less}/{pkg.name}.less',
                dst='{pkg.django_static}/{pkg.name}/css/{pkg.name}-{version}.min.css',
                force=force
            )
        elif less:
            warnings.warn(
                "WARNING: build --less specified, but no file at: " + less_fname
            )

    if buildall or docs:
        # output = 'svg'
        output = 'png'

        if WARN_ABOUT_SETTINGS:
            warnings.warn(
                "autodoc might need a dummy settings file in the root of "
                "your package. Since it runs in a separate process you cannot"
                "use settings.configure()"
            )

        # input: ctx.pkg.source / 'models/legal_transitions.py'
        # output: ctx.pkg.docs / 'diagrams/transitions.dot'
        ctx.run('python {transitions2dot} {output}'.format(
            transitions2dot=ctx.pkg.docs / 'transitions2dot.py',
            output=ctx.pkg.docs / 'diagrams/transitions.dot'
        ))

        for fname in ctx.pkg.docs.glob('diagrams/*.puml'):
            ctx.run('java -jar %s %s -t%s -o %s' % (
                PLANTUML_JAR, fname, output, ctx.pkg.docs / '_static'
            ))

        for fname in ctx.pkg.docs.glob('diagrams/*.dot'):
            ctx.run('dot -T%s -o %s %s' % (
                output,
                ctx.pkg.docs / '_static' / fname.basename().switchext('.' + output),
                fname
            ))

        doctools.build(ctx, force=force)

    if buildall or js:
        build_js(ctx, force)

    if HAVE_SETTINGS and (force or changed(ctx.pkg.django_static)):
        collectstatic(ctx, DJANGO_SETTINGS_MODULE, force=force)
Пример #4
0
def build(ctx, less=False, docs=False, js=False, force=False):
    """Build everything and collectstatic.
    """
    specified = any([less, docs, js])
    buildall = not specified

    if buildall or less:
        pass

    if buildall or docs:
        doctools.build(ctx, force=force)

    if buildall or js:
        pass
Пример #5
0
def test_build(ctx):
    files = """
    mypackage:
        package.json: |
            {"version": "1.2.3"}
        docs:
            - conf.py: |
                master_doc = 'index'
            - index.rst: |
                hello *world*
    """
    with create_files(files) as directory:
        os.chdir('mypackage')
        ctx = ctx.init(pkg=Package())
        docs.build(ctx, clean=True)  # cover clean when clean.
        ctx.run('tree')
        assert os.path.exists('build/docs/index.html')
        assert '<p>hello <em>world</em></p>' in open('build/docs/index.html').read()

        # cover clean when dirty
        docs.build(ctx, clean=True, warn=True)
        assert os.path.exists('build/docs/index.html')
        assert '<p>hello <em>world</em></p>' in open('build/docs/index.html').read()