sphinx-contrib / paverutils

BSD 2-Clause "Simplified" License
0 stars 4 forks source link

html task conflicts with built-in html task #3

Open hoangelos opened 6 years ago

hoangelos commented 6 years ago

In my pavement file I added from sphinxcontrib import paverutils and then when I try to run the html task, it gives me this:

(ht-ingestion-deployment-OGuyO4CE) bash-3.2$ paver html
Build failed: Ambiguous task name html (['paver.doctools.html', 'sphinxcontrib.paverutils.html'])
(ht-ingestion-deployment-OGuyO4CE) bash-3.2$ 
dhellmann commented 6 years ago

Hmm, interesting. I have a local html() task in my pavement file that calls the one from paverutils and then does some extra work, so I suppose that's why I don't see that.

As a work-around you could add something like:

@task
def html(options):
    "Generate HTML files."
    paverutils.html(options)  

I'll have to spend some more time to see if there's a better solution than that.

hoangelos commented 6 years ago

@dhellmann That works, but as you can imagine goes against what we were hoping.

dhellmann commented 6 years ago

Sure. I don't know if paver has any sort of task dependency/hierarchy resolver that would deal with this case. It's likely to be a while before I have time to do that research, so at least you have a work-around for now.

mhadam commented 9 months ago

@hoangelos I realize this is 5 years old, so maybe this explanation doesn't matter anymore...but the issue is that Paver only allows "short names" for tasks if the name is unambiguous.

From the Paver docs:

Tasks that you define in your pavement are always available by their short names. Tasks defined elsewhere are available by their short names unless there is a conflict where two tasks are trying to use the same short name.

So once you import paverutils.doctools into pavement.py there's now two tasks with the same name registered, and if you follow the relevant Paver code here it'll try looking for a task defined in the pavement.py module first, then try importing and finally will try searching through the registry it's tracking through the task decorator. And that "ambiguous" error message happens when there's two tasks with the same name you're trying to call with paver html.

I think just adding a line assigning the function to the name html underneath the paverutils import would fix the error message, like this:

from sphinxcontrib import paverutils
html = paverutils.html

Even more succinct:

from sphinxcontrib.paverutils import html

Hope that helps.