Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`fab -d` display detailed task info including signature #922

Closed

Conversation

@kevinjqiu
Copy link

@kevinjqiu kevinjqiu commented Jun 27, 2013

Currently, running fab -d <task_name> shows only the docstring. Sometimes, if the task takes arguments, merely listing what's in the docstring isn't enough. You can always read the function definition in the fabfile, but if the fabfile exports tasks from another module, you will have to trace to that module to find the definition.

This PR spares you of all that trouble by making the signature, as well as any information of default arguments available to you through fab -d <task_name>. This works on old style tasks, decorated tasks and class-based tasks.

Kevin Qiu added 4 commits Jun 27, 2013
@bitprophet
Copy link
Member

@bitprophet bitprophet commented Jul 7, 2013

Thanks, this looks awesome! Only thing left undone was a changelog entry but I can add that easily enough.

When testing it by hand I noticed an oddball issue with indentation that I am trying to track down. This is mostly a note to myself for later today when I return from AFK. In master, fab -d indents the docstring uniformly:

» fab -d test                                                             
Displaying detailed information for task 'test':                          

    Run all unit tests and doctests.                                      

    Specify string argument ``args`` for additional args to ``nosetests``.                                                                   

In this ticket's branch, the 2nd line (+ subsequent lines - tested that temporarily) of the docstring is indented an extra indent, which is incorrect:

» fab -d test                                                                 
Displaying detailed information for task 'test':                              

    Run all unit tests and doctests.                                          

        Specify string argument ``args`` for additional args to ``nosetests``.

    Arguments: args=None                                                                                                                                    
so that the docstring and the method signature are uniformly indented.
@kevinjqiu
Copy link
Author

@kevinjqiu kevinjqiu commented Jul 7, 2013

@bitprophet Fixed on the branch. Previously, the method signature (the added bits) and the docstring don't have the same indentation level (the docstring was manually indented), so when the output was produced, the second line of the docstring is indented twice. Now I call textwrap.dedent on task.__doc__ first to bring the indentation level of the docstring back to 0 first before the signature info is added on so they will be indented uniformly by fabric.util.indent. Hope it looks ok:

[show-detailed-task-signature +] $ fab -d test
Displaying detailed information for task 'test':

    Run all unit tests and doctests.

    Specify string argument ``args`` for additional args to ``nosetests``.

    Arguments: args=None
@bitprophet
Copy link
Member

@bitprophet bitprophet commented Jul 7, 2013

Cool, thanks. I added a test for the issue as well, and a changelog entry, and am currently running tests + pushing.

bitprophet added a commit that referenced this pull request Jul 7, 2013
@bitprophet
Copy link
Member

@bitprophet bitprophet commented Jul 7, 2013

Hrm, as usual Github is disagreeing with me (and I didn't rebase; might've been the cherry-pick of the last commit) - it is in fact fully merged to master. Closing manually.

@bitprophet bitprophet closed this Jul 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.