Beispiel #1
0
def lectern(ctx: Context, opts: LecternOptions):
    """Plugin that handles markdown files with lectern."""
    document = ctx.inject(Document)

    for pattern in opts.load:
        for path in ctx.directory.glob(pattern):
            document.load(path)

    for arguments in opts.scripts:
        result = subprocess.run(
            arguments,
            cwd=ctx.directory,
            check=True,
            stdout=subprocess.PIPE,
        )
        document.add_text(result.stdout.decode())

    yield

    if opts.snapshot:
        with document.markdown_serializer.use_flat_format(opts.snapshot_flat):
            document.save(
                ctx.directory / opts.snapshot,
                ctx.directory /
                opts.external_files if opts.external_files else None,
            )
Beispiel #2
0
def load_yaml(ctx: Context, opts: LoadYamlOptions):
    """Plugin that loads yaml resources for data packs and resource packs."""
    yaml_pack_loader = ctx.inject(YamlPackLoader)

    for pattern in opts.resource_pack:
        for path in ctx.directory.glob(pattern):
            yaml_pack_loader.load_resource_pack(ctx.directory / path)
    for pattern in opts.data_pack:
        for path in ctx.directory.glob(pattern):
            yaml_pack_loader.load_data_pack(ctx.directory / path)
Beispiel #3
0
def add_greeting(ctx: Context):
    i18n = ctx.inject(Internationalization)
    i18n.set("greeting.hello", en_us="hello", fr_fr="bonjour")

    greeting_count = ctx.meta["greeting_count"]

    ctx.data["greeting:hello"] = Function(
        ['tellraw @a {"translate": "greeting.hello"}'] * greeting_count,
        tags=["minecraft:load"],
    )
Beispiel #4
0
def livereload(ctx: Context):
    link_manager = ctx.inject(LinkManager)
    if not link_manager.data_pack or not ctx.data:
        return

    data = create_livereload_data_pack()
    livereload_path = data.save(link_manager.data_pack)
    link_manager.dirty.append(str(livereload_path))

    with ctx.worker(livereload_server) as channel:
        channel.send((link_manager.minecraft, livereload_path))
Beispiel #5
0
def beet_default(ctx: Context):
    autosave = ctx.inject(Autosave)
    autosave.add_link(livereload)
Beispiel #6
0
def beet_default(ctx: Context):
    document = ctx.inject(Document)
    document.directives["plugin"] = PluginDirective(ctx)
Beispiel #7
0
def beet_default(ctx: Context):
    ctx.inject(HELLO_PATH).thing()
    ctx.inject(WORLD_PATH).thing()
Beispiel #8
0
def beet_default(ctx: Context):
    document = ctx.inject(Document)
    document.loaders.append(RelativeNamespacedResourceLoader(ctx))
Beispiel #9
0
def beet_default(ctx: Context):
    with ctx.inject(JsonReporter).activate():
        yield
Beispiel #10
0
def data_pack_zip(ctx: Context):
    json_reporter = ctx.inject(JsonReporter)
    json_reporter.data.setdefault("data_pack",
                                  {}).update(create_pack_zip(ctx.data))
Beispiel #11
0
def data_pack_listing(ctx: Context):
    json_reporter = ctx.inject(JsonReporter)
    json_reporter.data.setdefault("data_pack", {}).update(
        create_pack_listing(ctx.data, json_reporter.opts.binary_files))
Beispiel #12
0
def resource_pack_zip(ctx: Context):
    json_reporter = ctx.inject(JsonReporter)
    json_reporter.data.setdefault("resource_pack",
                                  {}).update(create_pack_zip(ctx.assets))
Beispiel #13
0
def stdout(ctx: Context):
    json_reporter = ctx.inject(JsonReporter)
    json_reporter.data["stdout"] = json_reporter.stdout.getvalue()
Beispiel #14
0
def beet_default(ctx: Context):
    ctx.inject(Document).directives["custom_directive"] = custom_directive
Beispiel #15
0
def beet_default(ctx: Context):
    document = ctx.inject(Document)
    document.loaders.append(handle_yaml)
Beispiel #16
0
def beet_default(ctx: Context):
    document = ctx.inject(Document)
    document.directives["require"] = RequireDirective(ctx)
Beispiel #17
0
def beet_default(ctx: Context):
    document = ctx.inject(Document)
    document.directives["hello"] = hello
Beispiel #18
0
def beet_default(ctx: Context):
    messages = ctx.inject(MessageManager)
    ctx.template.env.filters["msg"] = messages.get_as_string  # type: ignore
Beispiel #19
0
def beet_default(ctx: Context):
    document = ctx.inject(Document)
    document.directives["script"] = ScriptDirective(ctx)