Skip to content

Improved context/collection configuration #107

@bitprophet

Description

@bitprophet

Currently configuration is 'global' - everything gets merged into a single config dict, with inner/outer collections collapsing, and - specifically - 'siblings' getting walked in a specific order, etc.

This works great until you want to import two 'copies' of a collection into the same level of your namespace, and parameterize them differently (in my case, I now have a project w/ two different Sphinx docroots.)

Feels like a good way to support this while not killing the 'old' use case (wherein an importing collection can override the imported one) is to remove sibling walking and also be 'smarter', looking 'top down' towards the specific collection the invoking task is in.

In other words, this:

from invoke import Collection, task
from invocations import docs

api = Collection.from_module(docs)
site = Collection.from_module(docs)
api.configure({'sphinx.source': 'api'})
site.configure({'sphinx.source': 'site'})

@task
def somelocaltask():
    pass

ns = Collection(somelocaltask, api=api, site=site)

doesn't work right now, because the "give me a single global config" algorithm walks the two siblings 'api' and 'site' and one of them wins over the other.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions